ujang7654321 ujang7654321 ujang7654321 ujang7654321 - 1 year ago 239
PHP Question

Method orderBy does not exist - laravel

How can i use the orderBy method with this script:

public function getProposalByUser($userId)
return ProposalModel::where('user_id', '=', $userId)->paginate(4)->orderBy('desc');

the script is to select the proposal where user have. and i want to arrange it for the top is newest.
Thanks in advance, and sorry for my bad english..

Answer Source

Try this:

return ProposalModel::where('user_id', '=', $userId)->orderBy('user_id', 'desc')->paginate(4);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download