I just realized that I created a lot of static functions. I heard that it is very bad practice. I been putting every function related with a User in the UserModel class. Everything function related with campaigns in my CampaignModel class etc… A lot of these functions I created use a query builder to get data instead of lazy loading because I need database performance. For example getLastCampaignsWithUsers(), getUsersWithAdvertisers(), getUsersInAllCampaigns() all use a query builder and don’t really rely on the model so they are technically static.
My question are:
Is it really bad to create a lot of static functions in your Model? (A lot of my functions are just database queries)
How do you guys go around this? Do you create another class? I like having any function that deals with each model in that model class and I like to share it everywhere.
Or should I just not call these functions static and just instantiate the class every time?:
$user = new User;
$user->getUsersWithAdvertisers(1);
instead of:
User::getUsersWithAdvertisers(1);