php - Generic methods in Laravel controller -


i have controllers split in 2 sections: app/http/controllers & app/api/controllers. of these controllers have 4/5 methods in common, , nothing changes between them apart eloquent model name e.g. user

how can abstract these methods away own controller other controllers can extend , still use eloquent? there method i've missed can provide eloquent name of parent controller?

i thought setting var `modelname = 'user' , using var vars, prefer "lazy" solution don't have variable change.

pseudo example:

<?php class apicontroller extends controller {     public function index()     {         $model = parentmodelname::all();          return response()->json($model);     } } 


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -