コード例 #1
0
 private function linkToUser(Project $project, array $input)
 {
     if (isset($input['created_by'])) {
         $id = $input['created_by']['id'];
         $user = User::find($id);
         $project->createdBy()->dissociate()->save();
         $project->createdBy()->associate($user)->save();
     } else {
         /* @var User $user */
         $user = $project->createdBy;
         if ($user) {
             $user = User::find($user->id);
             $user->createProject()->detach($project->id);
         }
     }
 }
コード例 #2
0
 private function linkToCurrentUser(Project $project, array $input)
 {
     $user = Auth::user();
     if ($user) {
         $project->createdBy()->associate($user)->save();
     }
     return $project;
 }