Example of HasManyThrough in ploi-deploy/roadmap

File app/Models/Project.php (link to Github)
use Illuminate\Database\Eloquent\Model;

class Project extends Model
{
    //
    public function items()
    {
        return $this->hasManyThrough(Item::class, Board::class);
    }
}
File app/Http/Controllers/ItemController.php (link to Github)
use App\Models\Item;
use App\Models\Project;

class ItemController extends Controller
{
    public function show($projectId, $itemId = null)
    {
        $project = null;

        if (!$itemId) {
            $item = Item::query()->where('slug', $projectId)->firstOrFail();
        } else {
            $project = Project::query()->where('slug', $projectId)->firstOrFail();

            $item = $project->items()->where('items.slug', $itemId)->firstOrFail();
        }

        return view('item', [
            'project' => $project,
            'board' => $item->board,
            'item' => $item,
            'user' => $item->user,
            'comments' => $item->comments()->with('user:id,name,email')->oldest()->get(),
            'activities' => $item->activities()->with('causer')->latest()->limit(10)->get()
        ]);
    }
    //
}

Additional resources on HasManyThrough: