protected function beforeQuery($query, $many)
    {
        // if this->active has been set to something, we add it to the query
        if ($this->active !== null) {
            $query->where('is_active', '=', $this->active);
        }

        // we want to always eager load members and comments.
        $query->with('members', 'comments');

        // let's say guests can only view projects with access level 1 or less.
        if (!$this->user) {
            $query->where('access_level', '<=', 1);
        }

        // unless user is an admin, we restrict every query to only show
        // projects with access_level lower than the logged in user's.
        else if (!$this->user->isAdmin()) {
            $query->where('access_level', '<=', $user->access_level);
        }
    }
protected function beforeQuery($query, $many)
    {
        // if this->active has been set to something, we add it to the query
        if ($this->active !== null) {
            $query->where('is_active', '=', $this->active);
        }

        // we want to always eager load members and comments.
        $query->with('members', 'comments');

        // let's say guests can only view projects with access level 1 or less.
        if (!$this->user) {
            $query->where('access_level', '<=', 1);
        }

        // unless user is an admin, we restrict every query to only show
        // projects with access_level lower than the logged in user's.
        else if (!$this->user->isAdmin()) {
            $query->where('access_level', '<=', $user->access_level);
        }
    }
protected function beforeQuery ( $ query , $ many ) { // if this->active has been set to something, we add it to the query if ( $ this -> active !== null ) { $ query -> where ( 'is_active' , '=' , $ this -> active ) ; } // we want to always eager load members and comments. $ query -> with ( 'members' , 'comments' ) ; // let's say guests can only view projects with access level 1 or less. if ( ! $ this -> user ) { $ query -> where ( 'access_level' , '<=' , 1 ) ; } // unless user is an admin, we restrict every query to only show // projects with access_level lower than the logged in user's. else if ( ! $ this -> user -> isAdmin ( ) ) { $ query -> where ( 'access_level' , '<=' , $ user -> access_level ) ; } }
This method is called before fetchMany and fetchSingle. We use it to add
functionality that should be present on every query.

Renamed from prepareQuery in 0.5
This method is called before fetchMany and fetchSingle . We use it to add functionality that should be present on every query .