route('artwork'); if (is_null($artwork)) { // Determine if the user is authorized to access artwork module, return $request->user('api')->canDo('artwork.artwork.view'); } if ($request->isMethod('POST') || $request->is('*/create')) { // Determine if the user is authorized to create an entry, return $request->user('api')->can('create', $artwork); } if ($request->isMethod('PUT') || $request->isMethod('PATCH') || $request->is('*/edit')) { // Determine if the user is authorized to update an entry, return $request->user('api')->can('update', $artwork); } if ($request->isMethod('DELETE')) { // Determine if the user is authorized to delete an entry, return $request->user('api')->can('delete', $artwork); } // Determine if the user is authorized to view the module. return $request->user('api')->can('view', $artwork); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(Request $request) { if ($request->isMethod('POST')) { // validation rule for create request. return [ 'artist_id' => 'required', 'category_id' => 'required', 'title' => 'required', 'price' => 'required', ]; } if ($request->isMethod('PUT') || $request->isMethod('PATCH')) { // Validation rule for update request. return [ 'artist_id' => 'required', 'category_id' => 'required', 'title' => 'required', 'price' => 'required', ]; } // Default validation rule. return [ ]; } }