/** * Sets the project object on the class protected var $projectType * * @param object, object * * @return void || function() */ public function setProjectType($route, $request) { $project_type = $route->getParameter('project_type'); $projectType = ProjectType::where('project_id', $this->project->id)->where('type', $project_type)->first(); if ($projectType != null) { $this->projectType = $projectType; } else { return $this->getAPIMissing(); } }
/** * Handles GET requests for /project/{project_id}/{project_type}/edit * * @param int * * @return view */ public function getProjectTypeEdit($project_id, $project_type) { $projectType = ProjectType::where('project_id', $project_id)->where('type', $project_type)->first(); return View::make('layouts.type-edit')->with(['fields' => json_decode($projectType->fields)]); }
/** * ProjectType::deleteTypesData() * */ public function testDeleteTypesData() { $this->setVars(); $projectType = ProjectType::where('project_id', $this->project->id)->first(); $response = ProjectType::deleteTypesData($this->project->id, $projectType->type, 1); $this->assertInternalType('int', $response); $this->assertEquals(1, $response); }
/** * Handles POST requests for /project/ * * @param int, string * * @return redirect */ public function postProjectTypeBulk($project_id, $project_type) { $projectType = ProjectType::where('project_id', $project_id)->where('type', $project_type)->first(); if (is_array($json = json_decode($this->input['json_data']))) { foreach ($json as $data) { $data->id = null; $response = ProjectType::createTypesData($projectType->table_name, (array) $data); if ($response['error'] === true) { break; } } } else { $response = ['error' => true, 'message' => 'Malformed json data.']; } return Redirect::back()->with($response); }