64 lines
2.8 KiB
PHP
64 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class SettingRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::check() && is_role(['1']);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'app_name' => ['required', 'string', 'max:255'],
|
|
'app_title' => ['required', 'string', 'max:255'],
|
|
'app_description' => ['required', 'string'],
|
|
'app_keywords' => ['required'],
|
|
'app_icon' => ['nullable', 'file', 'mimes:png,jpg,jpeg', 'max:4096'],
|
|
'app_logo' => ['nullable', 'file', 'mimes:png,jpg,jpeg', 'max:4096'],
|
|
'contact_address' => ['nullable'],
|
|
'contact_address_link' => ['nullable'],
|
|
'contact_phone' => ['nullable', 'regex:/^[0-9+\s-]+$/'],
|
|
'contact_email' => ['nullable', 'email', 'max:255'],
|
|
'contact_facebook' => ['nullable', 'max:100'],
|
|
'contact_twitter' => ['nullable', 'max:100'],
|
|
'contact_instagram' => ['nullable', 'max:100'],
|
|
'contact_youtube' => ['nullable', 'max:100'],
|
|
'contact_whatsapp' => ['nullable', 'max:100'],
|
|
'contact_telegram' => ['nullable', 'max:100'],
|
|
'about_us' => ['required', 'string'],
|
|
];
|
|
}
|
|
|
|
protected function prepareForValidation()
|
|
{
|
|
$this->merge([
|
|
'app_icon' => filled($this->app_icon) ? $this->app_icon : null,
|
|
'app_logo' => filled($this->app_logo) ? $this->app_logo : null,
|
|
'contact_address' => filled($this->contact_address) ? $this->contact_address : null,
|
|
'contact_address_link' => filled($this->contact_address_link) ? $this->contact_address_link : null,
|
|
'contact_phone' => filled($this->contact_phone) ? $this->contact_phone : null,
|
|
'contact_email' => filled($this->contact_email) ? $this->contact_email : null,
|
|
'contact_facebook' => filled($this->contact_facebook) ? $this->contact_facebook : null,
|
|
'contact_twitter' => filled($this->contact_twitter) ? $this->contact_twitter : null,
|
|
'contact_instagram' => filled($this->contact_instagram) ? $this->contact_instagram : null,
|
|
'contact_youtube' => filled($this->contact_youtube) ? $this->contact_youtube : null,
|
|
'contact_whatsapp' => filled($this->contact_whatsapp) ? $this->contact_whatsapp : null,
|
|
'contact_telegram' => filled($this->contact_telegram) ? $this->contact_telegram : null,
|
|
]);
|
|
}
|
|
}
|