public function scopeFindByUser($query, $userId, $statusCode = null) {
        if (!empty($status)) {
            $query = $query->whereStatus($status);
        }
        return $query->whereUser($userId)->get();
    }
public function scopeFindByUser($query, $userId, $statusCode = null) {
        if (!empty($status)) {
            $query = $query->whereStatus($status);
        }
        return $query->whereUser($userId)->get();
    }
public function scopeFindByUser ( $ query , $ userId , $ statusCode = null ) { if ( ! empty ( $ status ) ) { $ query = $ query -> whereStatus ( $ status ) ; } return $ query -> whereUser ( $ userId ) -> get ( ) ; }
Scopes class by user ID and returns object.
Optionally, scopes by status.

@param \Illuminate\Database\Eloquent\Builder $query      Query.
@param mixed                                 $userId     User ID.
@param string                                $statusCode Status.

@return this
Scopes class by user ID and returns object . Optionally scopes by status .