I have a problem with a query when I use pagination with select in Laravel. However, I found some Laravel Eloquent code but the problem is that it also doesn't work. Can anyone help me with this problem?
public function categoryall($urlid)
{
// Old query
// $procat = DB::select('select * from products where category_id in
// (select id from categories where parent_id = ?)', [$urlid]);
$procat = Product::whereIn('category_id', function ($query) {
$query->select('id')
->from(with(new Category)->getTable())
->where('parent_id', [$urlid]);
})->paginate(5);
return view('products.category')->with(compact('procat'));
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire