php - Laravel ordering a eloquent call, orderBy() -


i have line

$entries = $company->sheet_entries->where('date', $this->gettoday())->take(5); 

i order 'date','desc'

once assume done this.

$entries = $company->sheet_entries->where('date', $this->gettoday())->orderby('date','desc')->take(5); 

but returns error

method orderby not exist. 

i've used orderby before when calling eloquent brakets; example have line below works:

$last = $user->sheet_entries()->where('company_id', $user->company_privileges->company_id)->orderby('created_at', 'desc')->first(); 

what difference why wont second example work?

dd($entries = $company->sheet_entries()->orderby('date', 'desc')->take(5)->get()); 

works!

i still don't understand difference between using $company-> , $company()-> clarification appreciated.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -