mirror of
https://github.com/crivion/laranode.git
synced 2026-05-07 22:20:44 +08:00
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class EditAccountRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return auth()->user()->isAdmin();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'id' => ['required', 'integer', 'exists:users,id'],
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->id)],
|
|
'new_password' => ['nullable', Password::defaults()],
|
|
'role' => ['required', 'string', 'in:admin,user'],
|
|
'domain_limit' => ['nullable', 'integer', 'min:1'],
|
|
'database_limit' => ['nullable', 'integer', 'min:1'],
|
|
'ssh_access' => ['required', 'boolean'],
|
|
];
|
|
}
|
|
}
|