How to sort items by field to the related table in Laravel?

Have a model `Product` and `Brand`. And the model `Brand` has properties `position`.
How to obtain the sorted elements in the field `position` of the model `Brand`?

I tried this:
$items = Product::with([
 'brand' => function ($query) {
 $query->orderBy('position', 'ASC');

More like this:
$items = Product::join('brands', 'product.brand_id', '=', '')
 ->orderBy('brands.position', 'ASC')
July 9th 19 at 11:04
2 answers
July 9th 19 at 11:06
July 9th 19 at 11:08

Find more questions by tags PHPMySQLLaravelSQL