56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\System\Setting;
|
|
|
|
use App\Enums\Permission;
|
|
use App\Rules\PhoneNumber;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class SystemRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can(Permission::SETTINGS_UPDATE->value) ?? false;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'app_name' => ['required', 'string', 'max:100'],
|
|
'about_app' => ['required', 'string'],
|
|
'email' => ['required', 'email', 'max:100'],
|
|
'phone' => ['required', 'string', 'max:20', new PhoneNumber],
|
|
'address' => ['required', 'string'],
|
|
'logo' => ['nullable', 'image', 'max:2048'],
|
|
'logo_s3_key' => ['nullable', 'string'],
|
|
'favicon' => ['nullable', 'image', 'max:1024'],
|
|
'favicon_s3_key' => ['nullable', 'string'],
|
|
'login_cover' => ['nullable', 'image', 'max:5120'],
|
|
'login_cover_s3_key' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'app_name' => 'nama aplikasi',
|
|
'about_app' => 'tentang aplikasi',
|
|
'email' => 'email',
|
|
'phone' => 'nomor telepon',
|
|
'address' => 'alamat',
|
|
'logo' => 'logo',
|
|
'logo_s3_key' => 'logo',
|
|
'favicon' => 'favicon',
|
|
'favicon_s3_key' => 'favicon',
|
|
'login_cover' => 'cover login',
|
|
'login_cover_s3_key' => 'cover login',
|
|
];
|
|
}
|
|
}
|