Controller <> Model Conflict?

Posted 4 months ago by learner1982

i'm considering to use the same import alias, for my models, in all my controllers. Example:


use App\Product as Model;
use App\Customer;
use App\User;
$model= Model::latest()->paginate(20);
$customer = Customer::latest()->paginate(20);
$user = User::latest()->paginate(20);


use App\Product;
use App\Customer as Model;
use App\User;
$product = Product::latest()->paginate(20);
$model = Model::latest()->paginate(20);
$user = User::latest()->paginate(20);

I think this will be good for code-reuse in many of my controllers.

Next I'm thinking that Traits will come in really handy, using the same "self" > Model syntax in all controllers.

Is this a good or bad idea?

Is there any side-effects that I'm not thinking of?

Thanks? :-)

Please sign in or create an account to participate in this conversation.