public function save() { // Get all inputs $input = Input::all(); // Retrive the project details $project = Project::find($input['project_id']); // Assign values $project->name = $input['name']; $project->project_type = $input['project_type']; $project->description = $input['description']; $project->client_name = $input['client_name']; $project->start_at = $input['start_at']; $project->complete_at = $input['complete_at']; // Identify if this project is on hold or not if (isset($input['status'])) { $project->status = 2; } else { $project->status = 1; } // Update the project details $project->save(); // Assign each user in a project foreach (array_merge($input['developers'], $input['qc']) as $key => $value) { $user = ProjectUsers::firstOrCreate(array('project_id' => $input['project_id'], 'user_id' => $value)); $user->key = Crypt::encrypt(time()); $user->save(); } // Redirect to project page with message return Redirect::to('/project/' . $project->slug)->with('flash_msg', 'This project was successfully updated!'); }