Support the ongoing development of Laravel.io →
Database Eloquent Architecture
Last updated 2 years ago.
0

make an abstract model BaseModel extending the laravel Model. then make your other models extend your BaseModel. define your protected attributes on the base model.

0

Thanks for your reply but I was questioning the design principle; I think you misunderstood the question.

A simple example just to illustrate the problem:

// When $perPage is static:
$perPage = Request::get('perPage', User::$perPage);
$users = User::paginate($perPage);

// Current ugly sitiuation:
$utilityModel = new User();
$perPage = Request::get('perPage', $utilityModel->getPerPage());
$users = User::paginate($perPage);
Last updated 8 years ago.
0

oh i see, imo it's more like user preference.. in this case i would go with ->getPerPage()

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.