ldc-mesbr-app/app/Http/Requests/Bo/Campaigns/StoreCampaignRequest.php

51 lines
1.1 KiB
PHP
Raw Normal View History

2023-09-14 16:00:27 +02:00
<?php
namespace App\Http\Requests\Bo\Campaigns;
use App\Enums\CampaignTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class StoreCampaignRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return auth('backend')->check();
}
2023-09-21 10:32:22 +02:00
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'status' => $this->status ? true : false
]);
}
2023-09-14 16:00:27 +02:00
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name' => 'required|string|min:3|max:255',
'type' => [new Enum(CampaignTypes::class)],
'status' => 'required|boolean',
'brand_id' => 'required|exists:brands,id',
'coupons' => 'required|array',
'coupons.*.id' => 'required|exists:coupons,id'
2023-09-14 16:00:27 +02:00
];
2023-09-21 10:32:22 +02:00
return $rules;
2023-09-14 16:00:27 +02:00
}
}