Question: 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: 
It seems the main problem is that you have used the methods in the wrong order.

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

```

`paginate` actually returns the query results in a collection, and the collection doesn't have an `orderBy` method, so you can't chain it like you can with the other query builder methods.

Secondly, it looks like the orderBy method needs another argument, unless your entity actually does have a property called `'desc'`.
Try this:

```
return ProposalModel::where('user_id', '=', $userId)->orderBy('created_date', 'desc')->paginate(4);

```