Files
sam-manage/app/Http/Requests/UpdateProfileRequest.php

48 lines
1.0 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
// 최고관리자만 이름 수정 가능
$nameRule = auth()->user()->isSuperAdmin()
? 'required|string|max:100'
: 'nullable';
return [
'name' => $nameRule,
'phone' => 'nullable|string|max:20',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
*/
public function attributes(): array
{
return [
'name' => '이름',
'phone' => '연락처',
];
}
}