-
app/Models/Publisher.php
Open in GitHubuse Illuminate\Database\Eloquent\Relations\HasManyThrough; class Publisher extends Model { // ... public function materials(): HasManyThrough { return $this->hasManyThrough(Material::class, Source::class); } // ... }
-
app/Livewire/Publishers/Show.php
Open in GitHubuse App\Livewire\Traits\CanLoadMore; use App\Models\Publisher; use Livewire\Component; class Show extends Component { use CanLoadMore; public Publisher $publisher; public function mount(string $slug) { $this->publisher = Publisher::displayed()->where('slug', $slug)->firstOrFail(); } public function render() { return view('livewire.publishers.show', [ 'materials' => $this->publisher ->materials() ->displayed() ->latest('published_at') ->cursorPaginate($this->perPage, [ 'materials.id', 'materials.slug', 'materials.published_at', ]), ])->title($this->publisher->name); } }