route('ex'); // Determine if the user is authorized to access ex module, if (is_null($ex)) { return $request->user()->canDo('data_table.ex.view'); } // Determine if the user is authorized to create an entry, if ($request->isMethod('POST') || $request->is('*/create')) { return Gate::allows('create', $ex); } // Determine if the user is authorized to update an entry, if ($request->isMethod('PUT') || $request->isMethod('PATCH') || $request->is('*/edit')) { return Gate::allows('update', $ex); } // Determine if the user is authorized to delete an entry, if ($request->isMethod('DELETE')) { return Gate::allows('delete', $ex); } // Determine if the user is authorized to view the module. return Gate::allows('view', $ex); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(Request $request) { // validation rule for create request. if ($request->isMethod('POST')) { return [ 'Full_Name' => 'required', 'Gender' => 'required', 'DOB' => 'required', ]; } // Validation rule for update request. if ($request->isMethod('PUT') || $request->isMethod('PATCH')) { return [ 'Full_Name' => 'required', 'Gender' => 'required', 'DOB' => 'required', ]; } // Default validation rule. return [ ]; } }