updade and fix service and request for create user
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Requests\V3\Dashboard\UserManagement;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreExrtraRequest extends FormRequest
|
||||
{
|
||||
@@ -23,17 +24,29 @@ class StoreExrtraRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'edarate_ostani_id' => 'nullable|exists:edarate_ostanis,id|required_without:edarate_shahri_id',
|
||||
'edarate_shahri_id' => 'nullable|exists:edarate_shahris,id|required_without:edarate_ostani_id',
|
||||
'edarate_ostani_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_ostani', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_shahri_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_shahri_id'))),
|
||||
],
|
||||
'edarate_shahri_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_shahri', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_ostani_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_ostani_id'))),
|
||||
],
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'city_id' => 'exists:cities,id',
|
||||
'username' => 'required|unique:users,username',
|
||||
'national_code' => 'unique:users,national_code',
|
||||
'password' => 'required|string|confirmed|min:8',
|
||||
'national_code' => 'unique:users,national_code|digits:10',
|
||||
'password' => 'required|confirmed|min:8',
|
||||
'first_name' => 'required|string',
|
||||
'last_name' => 'required|string',
|
||||
'position' => 'string',
|
||||
'mobile' => 'required|string',
|
||||
'mobile' => 'required|regex:/^09\d{9}$/|numeric|digits:11',
|
||||
'degree' => 'string',
|
||||
'major' => 'string',
|
||||
'avatar' => 'required|file|mimes:pdf,jpg,jpeg,png',
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Requests\V3\Dashboard\UserManagement;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
@@ -23,13 +24,25 @@ class StoreRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'edarate_ostani_id' => 'nullable|exists:edarate_ostanis,id|required_without:edarate_shahri_id',
|
||||
'edarate_shahri_id' => 'nullable|exists:edarate_shahris,id|required_without:edarate_ostani_id',
|
||||
'edarate_ostani_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_ostani', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_shahri_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_shahri_id'))),
|
||||
],
|
||||
'edarate_shahri_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_shahri', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_ostani_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_ostani_id'))),
|
||||
],
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'city_id' => 'exists:cities,id',
|
||||
'username' => 'required|unique:users,username',
|
||||
'national_code' => 'unique:users,national_code',
|
||||
'password' => 'required|string|confirmed|min:8',
|
||||
'national_code' => 'unique:users,national_code|digits:10',
|
||||
'password' => 'required|confirmed|min:8',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,21 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'province_id' => 'required|exists:provinces,id',
|
||||
'edarate_ostani_id' => 'nullable|exists:edarate_ostanis,id|required_without:edarate_shahri_id',
|
||||
'edarate_shahri_id' => 'nullable|exists:edarate_shahris,id|required_without:edarate_ostani_id', 'city_id' => 'exists:cities,id',
|
||||
'edarate_ostani_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_ostani', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_shahri_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_shahri_id'))),
|
||||
],
|
||||
'edarate_shahri_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('edarate_shahri', 'id'),
|
||||
Rule::prohibitedIf(fn () => filled($this->input('edarate_ostani_id'))),
|
||||
Rule::requiredIf(fn () => blank($this->input('edarate_ostani_id'))),
|
||||
],
|
||||
'city_id' => 'exists:cities,id',
|
||||
'username' => [Rule::unique('users', 'username')->ignore($this->user->id)],
|
||||
'national_code' => ['required', Rule::unique('users', 'national_code')->ignore($this->user->id)],
|
||||
'first_name' => 'required|string',
|
||||
|
||||
Reference in New Issue
Block a user