mercredi 28 février 2018

Best Practice for pulling data in Laravel

I'm relatively new with Laravel and I'm learning as well as working on Laravel based projects.

My question is what are Laravel Model/Eloquent Best Practices:

Is it better to pull records from the database this way Where I have only one function in my user Model like 'staff()':

$managers = $users->staff()->where('usertype', manager');

Or is better to pull records from the database this way Where I have multiple functions in my user Model like 'staff()', 'managers()', 'clerks()':

$managers = $users->managers();
$clerks = $users->clerks();

So basically, I'm asking if Such database related logic should be handled on Model end or Controller end?

PS: I'm on Laravel 5.5



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

Aucun commentaire:

Enregistrer un commentaire