/** * Display a listing of the resource. * * @return Response */ public function index() { //Return all the results $jobs = JobOpportunity::get(); //Passing the Role to use its constants return view('admin.jobopportunity.index', compact('jobs')); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { //This id is passed by the controller that calls the request class $job = JobOpportunity::find($this->id); switch ($this->method()) { case 'GET': case 'DELETE': return []; case 'POST': return ['name' => 'required|unique:job_opportunities,name', 'description' => 'required', 'responsabilities' => 'required', 'requirements' => 'required', 'skills' => 'required']; case 'PUT': case 'PATCH': return ['name' => 'required|unique:job_opportunities,name,' . $job->id, 'description' => 'required', 'responsabilities' => 'required', 'requirements' => 'required', 'skills' => 'required']; default: break; } }