I want to add a filter for all application queries to get the result by a specific year.
I am putting the current year into the session as shown below:
public function postLogin()
{
Session::put('currentYear', date("Y"));
}
I have many controllers in my application. I want any model's query result to filter by session year => Session::get('currentYear')
I have a lot of models; for example I have one route to view all users, teachers and students.
public function getList()
{
$data['students'] = User::where('group_id', '=', 4)->get();
return View::make('students.list', $data);
}
Can I put __construct in BaseController to filter all app queries by Session::get('currentYear')?