ldc-mesbr-app/app/Http/Requests/Bo/Coupons/StoreCouponRequest.php
2023-11-24 15:09:54 +00:00

67 lines
2.1 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Coupons;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
class StoreCouponRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return auth('backend')->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->mergePicture('decoration');
$this->mergePicture('gs1');
$this->mergePicture('website_picture');
$this->mergePicture('website_picture_mobile');
$this->merge([
'status' => $this->status ? true : false
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name' => 'required|string|min:3|max:255',
'status' => 'required|boolean',
'brand_id' => 'required|exists:brands,id',
'process_code' => 'required|string|min:3|max:255',
'amount' => 'required|numeric|min:0.1|max:3',
'valid_on' => 'required|string',
'validity_period' => 'required|numeric|min:1|max:31',
'legal_notices' => 'required|string',
'limit_qty' => 'required|numeric|digits_between:1,3',
'limit_period' => 'required|numeric|digits_between:1,3',
'start_diffusion_date' => 'nullable|date|before:end_diffusion_date',
'end_diffusion_date' => 'nullable|date|after:start_diffusion_date'
];
return \array_merge(
$rules,
$this->pictureRules('decoration', 280, 160, 280, 160, false),
$this->pictureRules('gs1', 628, 360, 628, 360, true),
$this->pictureRules('website_picture', 580, 190, 580, 1900, true),
$this->pictureRules('website_picture_mobile', 570, 560, 570, 560, true),
);
}
}