コード例 #1
0
 protected function registerUserWithUrlCode(Request $request)
 {
     $array = Input::all();
     $validator = Validator::make($array, ['urlcode' => 'min:39|max:40|required', 'password' => 'min:6|required']);
     if ($validator->fails()) {
         return Response::json('wrong urlcode or password', 400);
     } else {
         $invitation = Invitation::where('urlcode', '=', $request->input('urlcode'))->first();
         if (empty($invitation)) {
             return Response::json('no invitation found', 400);
         }
         $projectId = $invitation->owner;
         $type = $invitation->type;
         $invitation->delete();
         $user = new User();
         $user->firstname = $invitation->firstname;
         $user->lastname = $invitation->lastname;
         $user->email = $invitation->email;
         $user->password = \Illuminate\Support\Facades\Hash::make($request->input('password'));
         $user->save();
         $users_projects_rel = new UserOwnsProjectRel();
         $users_projects_rel->User_FK = $user->id;
         $users_projects_rel->Project_FK = $projectId;
         $users_projects_rel->type = $type;
         $users_projects_rel->save();
     }
 }
コード例 #2
0
 protected function createProject(Request $request)
 {
     $array = Input::all();
     $validator = Validator::make($array, ['name' => 'required|min:2|max:150|unique:projects', 'description' => 'required|min:10|max:300']);
     if ($validator->fails()) {
         return Response::json('validation failed', 400);
     } else {
         $user_id = Authorizer::getResourceOwnerId();
         $project = new Project();
         $UserOwnsProjectRel = new UserOwnsProjectRel();
         $project->name = $request->input('name');
         $project->description = $request->input('description');
         $project->acronym = $request->input('acronym');
         $project->save();
         $UserOwnsProjectRel->User_FK = $user_id;
         $UserOwnsProjectRel->Project_FK = $project->id;
         $UserOwnsProjectRel->type = '2';
         $UserOwnsProjectRel->save();
         return Response::json($project->id);
     }
 }