/**
  * Shows the owner view.
  *
  * @return \Illuminate\View\View
  */
 public function showAction($path)
 {
     $owner = Owner::findByPath($path);
     if ($owner->type == 'User') {
         $user = User::find($owner->user_id);
         return $this->showUser($user);
     } else {
         return $this->showGroup($owner);
     }
 }
Exemple #2
0
 /**
  * Find by owner_path & project_path, or throw an exception.
  *
  * @param string   $owner_path
  * @param string   $project_path
  * @param string[] $columns
  *
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return \Gitamin\Models\User
  */
 public static function findByPath($owner_path, $project_path, $columns = ['*'])
 {
     $project = Owner::findByPath($owner_path)->project($project_path, $columns);
     /* Another way
        $project = static::leftJoin('owners', function ($join) {
            $join->on('projects.owner_id', '=', 'owners.id');
        })->where('projects.path', '=', $project_path)->where('owners.path', '=', $owner_path)->first($columns);
        */
     if (!$project) {
         throw new ModelNotFoundException();
     }
     return $project;
 }