I tried to define a local scope in my project to show popular(most downloaded)in my Home Page...so this is my File Model codes:
public function scopePopular($query)
{
return $query->orderBy('file_download_num');
}
As you know "file_download_num" is the field in database im trying to get data from... so this is how I used this scope in my HomeController:
$popularFiles = File::Popular()->get();
I didn't use count()
method in my Controller or Model!But still getting Error!so any suggestion?
notice:php version is 7.3