user())) { return false; } return auth()->check() and auth()->user()->sites and ( $user->isAdmin() or auth()->user()->sites->contains(request()->route()->ticket->site_id) ); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $this->merge([ 'subscribe' => $this->subscribe ? true : false ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { /** @var \App\Models\User */ $user = auth()->user(); return [ 'subscribe' => 'required|boolean', 'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'), 'file_message' => 'sometimes|mimes:jpeg,jpg,png,pdf|max:2048' ]; } }