app/Notification.php
/**
     * scope to get only private notifications for a user
     */
scope to get only private notifications for a user
scope to get only private notifications for a user
public function scopePrivate(Builder $query)
    {
        $user = JWTAuth::parseToken()->authenticate();
        return $query->whereHas('users', function ($q) use ($user) {
            $q->where('id', $user->id);
        });
    }
public function scopePrivate ( Builder $ query ) { $ user = JWTAuth :: parseToken ( ) -> authenticate ( ) ; return $ query -> whereHas ( 'users' , function ( $ q ) use ( $ user ) { $ q -> where ( 'id' , $ user -> id ) ; } ) ; }
scope to get only private notifications for a user
scope to get only private notifications for a user
//$user = User::find(2); //return $user->notifications();