Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

nabilhassen/larasense

62 stars
2 code files
View nabilhassen/larasense on GitHub

app/Models/Publisher.php

Open in GitHub
use 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 GitHub
use 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);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.