How to filter all query results in laravel 4.2 app by year

Viewed 570

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')?

1 Answers
Related