compacted and sent to the blade template file with compact(). But I'm receiving no results from the database. Any ideas why? Also when I try to add {{ $reviews->links() }} I'm getting the following error:
Call to undefined method Illuminate\Database\Eloquent\Builder::links()
Any ideas? I've done this in other pages in my project but never faced these problems.
$reviews = Reviews::query(); // here we make an instance of the Builder class
if(!empty($request->stars)) {
foreach($request->stars as $star) {
$reviews->orWhere('review_stars', '=', $star); // here we change stuff inside the builder class. Same as if you have a User class and you did $user->name = 'foobar';
}
}
$reviews->orderBy('created_at', 'desc') //again we change stuff inside the the Builder class
->paginate(6); //and here we call a method that prepares the Builder class for pagination internally... and then returns a new result.. But you never get that result (you get that by assigning it to something)