diff --git a/app/Http/Requests/CustomerRequest.php b/app/Http/Requests/CustomerRequest.php new file mode 100644 index 0000000..83871cd --- /dev/null +++ b/app/Http/Requests/CustomerRequest.php @@ -0,0 +1,36 @@ + 'required|string|max:20|unique:customers,customer_code', + 'name' => 'required|string|max:100', + 'address' => 'required|string', + 'branch_code' => 'required|string|max:3|exists:branches,code', + 'date_of_birth' => 'nullable|date', + 'email' => 'nullable|string|max:100|email', + ]; + + if ($this->method() == 'PUT') { + $rules['customer_code'] = 'required|string|max:20|unique:customers,customer_code,' . $this->id; + } + + return $rules; + } + + public function authorize() + : bool + { + return true; + } +}