user()->isAdmin(); } public function rules() { $rules = [ 'id' => 'required|bail', 'invoice_ids' => 'nullable|string|sometimes', 'ninja_category_id' => 'nullable|string|sometimes' ]; if(isset($this->vendor_id)) $rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0'; return $rules; } public function prepareForValidation() { $input = $this->all(); $input = $this->decodePrimaryKeys($input); $this->replace($input); } }