mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 04:31:06 +03:30
Structor CSSD
This commit is contained in:
@@ -1,53 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
||||
|
||||
class StoreUserRequest extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
if ($this->method() == 'POST') {
|
||||
return auth('api')->check() && auth('api')->user()->can('store', User::class);
|
||||
} else {
|
||||
$User = $this->route('User');
|
||||
return auth('api')->check() && $User && auth('api')->user()->can('update', $User);
|
||||
}
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
switch ($this->method()) {
|
||||
case 'POST': {
|
||||
return [
|
||||
'name'=>'required|string|max:255',
|
||||
'cell_number'=>'required|digits_between:10,11|unique:users',
|
||||
'password'=>'required|string|min:6',
|
||||
'medical_center_id' => 'required|numeric|exists:medical_centers,id',
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'PUT':
|
||||
case 'PATCH': {
|
||||
$User = $this->route('User');
|
||||
return [
|
||||
'name'=>'required|string|max:255',
|
||||
'cell_number'=>'required|digits_between:10,11|unique:users,id,'.$User->id,
|
||||
'password'=>'required|string|min:6',
|
||||
'medical_center_id' => 'required|numeric|exists:medical_centers,id',
|
||||
];
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
<?php␍
|
||||
␍
|
||||
namespace App\Http\Requests;␍
|
||||
␍
|
||||
use App\User;␍
|
||||
use Illuminate\Validation\Rule;␍
|
||||
use Illuminate\Foundation\Http\FormRequest;␍
|
||||
use Illuminate\Contracts\Validation\Validator;␍
|
||||
␍
|
||||
␍
|
||||
class StoreUserRequest extends FormRequest␍
|
||||
{␍
|
||||
public function authorize()␍
|
||||
{␍
|
||||
if ($this->method() == 'POST') {␍
|
||||
return auth('api')->check() && auth('api')->user()->can('store', User::class);␍
|
||||
} else {␍
|
||||
$User = $this->route('User');␍
|
||||
return auth('api')->check() && $User && auth('api')->user()->can('update', $User);␍
|
||||
}␍
|
||||
}␍
|
||||
␍
|
||||
public function rules()␍
|
||||
{␍
|
||||
switch ($this->method()) {␍
|
||||
case 'POST': {␍
|
||||
return [␍
|
||||
'name'=>'required|string|max:255',␍
|
||||
'cell_number'=>'required|digits_between:10,11|unique:users',␍
|
||||
'password'=>'required|string|min:6',␍
|
||||
'medical_center_id' => 'required|numeric|exists:medical_centers,id',␍
|
||||
];␍
|
||||
break;␍
|
||||
}␍
|
||||
case 'PUT':␍
|
||||
case 'PATCH': {␍
|
||||
$User = $this->route('User');␍
|
||||
return [␍
|
||||
'name'=>'required|string|max:255',␍
|
||||
'cell_number'=>'required|digits_between:10,11|unique:users,id,'.$User->id,␍
|
||||
'password'=>'required|string|min:6',␍
|
||||
'medical_center_id' => 'required|numeric|exists:medical_centers,id',␍
|
||||
];␍
|
||||
break;␍
|
||||
␍
|
||||
}␍
|
||||
default:␍
|
||||
break;␍
|
||||
}␍
|
||||
␍
|
||||
}␍
|
||||
␍
|
||||
}␍
|
||||
|
||||
Reference in New Issue
Block a user