I did got it working turning things around:
public function allPaginate($perPage)
{
$result = $this->model->orderBy('created_at', 'desc')->paginate($perPage);
// adding slug to my collection for every item
$result->each(function ($item) {
if(! isset($item->slug))
{
$slug = Str::slug($item->title);
$item->slug = $slug;
}
});
return $result;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community