code: public function scopeFindByUser($query, $userId, $statusCode = null) {
          if (!empty($status)) {
              $query = $query->whereStatus($status);
          }
          return $query->whereUser($userId)->get();
      }
docs: 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