public function findByUser($userId = null)
    {
        $builder = $this->model->select(['tbl_logs.id', 'tbl_logs.priority_id', 'tbl_logs.type_id', 'tbl_logs.brand_id', 'tbl_logs.user_id', 'tbl_logs.owner_type', 'tbl_logs.owner_id', 'tbl_logs.old_value', 'tbl_logs.new_value', 'tbl_logs.related_data', 'tbl_logs.type', 'tbl_logs.name', 'tbl_logs.created_at'])
                ->with('component', 'priority', 'brand')
                ->whereHas('user', function($q) use($userId) {
                    if (!is_null($userId)) {
                        $q->where('user_id', $userId);
                    }
                })->whereHas('component', function($q) {
                    $q->where('active', 1);
                })
                ->where('brand_id', brand_id())
                ->orderBy('created_at', 'desc');
        $builder->withoutGlobalScopes();
        return $builder;
    }
public function findByUser($userId = null)
    {
        $builder = $this->model->select(['tbl_logs.id', 'tbl_logs.priority_id', 'tbl_logs.type_id', 'tbl_logs.brand_id', 'tbl_logs.user_id', 'tbl_logs.owner_type', 'tbl_logs.owner_id', 'tbl_logs.old_value', 'tbl_logs.new_value', 'tbl_logs.related_data', 'tbl_logs.type', 'tbl_logs.name', 'tbl_logs.created_at'])
                ->with('component', 'priority', 'brand')
                ->whereHas('user', function($q) use($userId) {
                    if (!is_null($userId)) {
                        $q->where('user_id', $userId);
                    }
                })->whereHas('component', function($q) {
                    $q->where('active', 1);
                })
                ->where('brand_id', brand_id())
                ->orderBy('created_at', 'desc');
        $builder->withoutGlobalScopes();
        return $builder;
    }
public function findByUser ( $ userId = null ) { $ builder = $ this -> model -> select ( [ 'tbl_logs.id' , 'tbl_logs.priority_id' , 'tbl_logs.type_id' , 'tbl_logs.brand_id' , 'tbl_logs.user_id' , 'tbl_logs.owner_type' , 'tbl_logs.owner_id' , 'tbl_logs.old_value' , 'tbl_logs.new_value' , 'tbl_logs.related_data' , 'tbl_logs.type' , 'tbl_logs.name' , 'tbl_logs.created_at' ] ) -> with ( 'component' , 'priority' , 'brand' ) -> whereHas ( 'user' , function ( $ q ) use ( $ userId ) { if ( ! is_null ( $ userId ) ) { $ q -> where ( 'user_id' , $ userId ) ; } } ) -> whereHas ( 'component' , function ( $ q ) { $ q -> where ( 'active' , 1 ) ; } ) -> where ( 'brand_id' , brand_id ( ) ) -> orderBy ( 'created_at' , 'desc' ) ; $ builder -> withoutGlobalScopes ( ) ; return $ builder ; }
Finds all logs by user id

@param mixed $userId
@return \Illuminate\Database\Eloquent\Builder
Finds all logs by user id