jeudi 28 avril 2016

How to get list of users in laravel 5

I am working over a project. I have required some basic values in different routes. e.g. show the list of users, locations, products in different pages/routes. So i wanted to create a common method for these like where i want to show list of users i will call the method for user and pass this list to view.

I've tried the following method

$usersArr = User::where('loc_id', session('organization'))->where('status', '!=', 'Deleted')->orderBy('id', 'desc')->lists('username', 'id');

So i wanted to know which is best place to define these type of methods. Should i define this in Model,Controller or create some type of common functions.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1QCoPbU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire