src/Repository/StackRepository.php
public function fetchOne(int $id): Builder
    {
        return $this->makeModel()->newQuery()->withoutGlobalScopes()->distinct()
                        ->select(['tbl_notifications_stack.*'])->with('content')->with('content.lang')->with('notification.type')
                        ->where(function ($query) {
                            $query->whereNull('author_id')->orWhere('author_id', user()->id)->orWhereHas('author', function($subquery) {
                                $subquery->whereHas('roles', function($rolesQuery) {
                                    $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds());
                                });
                            });
                        })
                        ->with('author')->with('author.roles')->with('content')
                        ->whereId($id);
    }
public function fetchOne(int $id): Builder
    {
        return $this->makeModel()->newQuery()->withoutGlobalScopes()->distinct()
                        ->select(['tbl_notifications_stack.*'])->with('content')->with('content.lang')->with('notification.type')
                        ->where(function ($query) {
                            $query->whereNull('author_id')->orWhere('author_id', user()->id)->orWhereHas('author', function($subquery) {
                                $subquery->whereHas('roles', function($rolesQuery) {
                                    $rolesQuery->whereIn('tbl_roles.id', user()->roles->first()->getChilds());
                                });
                            });
                        })
                        ->with('author')->with('author.roles')->with('content')
                        ->whereId($id);
    }
public function fetchOne ( int $ id ) : Builder { return $ this -> makeModel ( ) -> newQuery ( ) -> withoutGlobalScopes ( ) -> distinct ( ) -> select ( [ 'tbl_notifications_stack.*' ] ) -> with ( 'content' ) -> with ( 'content.lang' ) -> with ( 'notification.type' ) -> where ( function ( $ query ) { $ query -> whereNull ( 'author_id' ) -> orWhere ( 'author_id' , user ( ) -> id ) -> orWhereHas ( 'author' , function ( $ subquery ) { $ subquery -> whereHas ( 'roles' , function ( $ rolesQuery ) { $ rolesQuery -> whereIn ( 'tbl_roles.id' , user ( ) -> roles -> first ( ) -> getChilds ( ) ) ; } ) ; } ) ; } ) -> with ( 'author' ) -> with ( 'author.roles' ) -> with ( 'content' ) -> whereId ( $ id ) ; }
Fetch one stack item

@param int $id
@return Builder
Fetch one stack item