Esempio n. 1
0
 /**
  * Scope the user by the given username.
  *
  * @param  Builder $query
  * @param  string $username
  * @return Builder|User
  */
 public function scopeByUsername(Builder $query, string $username)
 {
     $profile = Profile::where('username', $username)->with('user')->first();
     if (!$profile) {
         return $query;
     }
     return $profile->user;
 }