I have a question pertaining querying an eloquent model using a custom attribute.
I have a class/model Item and i have created an attribute:
function getWeeklySalesCountAttribute()
{
return rand(3, 1000); //real logic is in db
}
So in my controller I want to pick items that have the highest weekly sales first and paginate them
$items = Item::where(function($item){
//find the items with highest weekly sales
})->paginate(10);
How do i achieve that given I manage to pull the $item->weekly_sales_count attribute