Lugi
2 years ago
56
8
Tips

Controller or Model method

Posted 2 years ago by Lugi

Let's say there is a model Holiday.

There are also methods getHolidaysForCountry, getHolidaysBetweenDates etc.. which looks like this:

public function getHolidaysForCountry($date_from, $date_to, $country)
{
    // query DB
    // do some logic, modify some data, etc..
    
    return $holidays;
}

public function getHolidaysBetweenDates($date_from, $date_to)
{
    // query DB
    // do some logic, modify some data, etc..
    
    return $holidays;
}

Where (and why) would be the proper way to put this methods to follow the best design principles ?

  1. make it static and put it in the model

  2. put it in the controller

  3. create a repository (but this could overkill for simple classes)

  4. something else

Thanks.

Update: here is the holidays table. there is no country - let's say it would be an overkill...

holidays
-----
name
country_code
date

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