public function findByAttributes($componentId = null)
    {
        return $this->model->with('component', 'priority', 'user', 'brand')->whereHas('component', function($q) use($componentId) {
                    $q->where('active', 1);
                    if (!is_null($componentId)) {
                        $q->where('id', $componentId);
                    }
                })->where('brand_id', brand_id())->orderBy('created_at', 'desc');
    }
public function findByAttributes($componentId = null)
    {
        return $this->model->with('component', 'priority', 'user', 'brand')->whereHas('component', function($q) use($componentId) {
                    $q->where('active', 1);
                    if (!is_null($componentId)) {
                        $q->where('id', $componentId);
                    }
                })->where('brand_id', brand_id())->orderBy('created_at', 'desc');
    }
public function findByAttributes ( $ componentId = null ) { return $ this -> model -> with ( 'component' , 'priority' , 'user' , 'brand' ) -> whereHas ( 'component' , function ( $ q ) use ( $ componentId ) { $ q -> where ( 'active' , 1 ) ; if ( ! is_null ( $ componentId ) ) { $ q -> where ( 'id' , $ componentId ) ; } } ) -> where ( 'brand_id' , brand_id ( ) ) -> orderBy ( 'created_at' , 'desc' ) ; }
find models by type

@param mixed $componentId
@return \Illuminate\Support\Collection
find models by type