Feature #1 : Provinces
This commit is contained in:
33
app/Http/Requests/ProvinceRequest.php
Normal file
33
app/Http/Requests/ProvinceRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Location\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProvinceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
if ($this->method() === 'PUT') {
|
||||
$rules['code'] = 'required|string|max:4|unique:provinces,code,' . $this->id;
|
||||
$rules['name'] = 'required|string|max:2554|unique:provinces,name,' . $this->id;
|
||||
} else {
|
||||
$rules['code'] = 'required|string|max:4|unique:provinces,code';
|
||||
$rules['name'] = 'required|string|max:2554|unique:provinces,name';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user