Sunday, March 19, 2017

Laravel 5.4 Sorting data

I would like to sort the data from two different tables.

I would like to get user data and the role that each of them has, and sort the data the role name.

I know how to sort the data in the table users but do not know how to sort data in a pivot table.

MyDB enter image description here

MyController /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $users = (Data sorted by name role); return view('users.index', compact('users')); }



via chmod

Advertisement