66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\PaymentMode;
|
|
|
|
use App\Http\Requests\Bo\UpdateMiniCrudRequest;
|
|
|
|
class UpdatePaymentModeRequest extends UpdateMiniCrudRequest
|
|
{
|
|
/**
|
|
* The model parameter name
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $modelName = 'payment_mode';
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
/** @var \App\Models\User|null */
|
|
$user = \auth('backend')->user();
|
|
return ($user and $user->can('update', $this->payment_mode)) && parent::authorize();
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'status' => $this->status ? true : false
|
|
]);
|
|
parent::prepareForValidation();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return array_merge([
|
|
'status' => 'required|boolean'
|
|
], parent::rules());
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes()
|
|
{
|
|
return [
|
|
'data.payment_mode_label.value' => \trans('texte du mode'),
|
|
'data.payment_mode_logo.value' => \trans('logo du mode'),
|
|
'data.payment_mode_logo_display.value' => \trans('afficher l\'îcone'),
|
|
];
|
|
}
|
|
}
|