ldc-mesbr-app/app/Http/Requests/Fo/Basket/PrintRequest.php

49 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests\Fo\Basket;
use App\Enums\CampaignTypes;
use Illuminate\Foundation\Http\FormRequest;
class PrintRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
// FIXME: Docblock
protected function prepareForValidation()
{
$campagne = $this->basket->campagne;
if (!$campagne->camp_type->equals(CampaignTypes::panier())) {
throw new \Exception('Campaign is not basket.');
}
if ($campagne->camp_published === 0) {
throw new \Exception('Campaign is not published.');
}
if ($campagne->site->crm_token === null) {
throw new \Exception('CRM Token is missing.');
}
if ($campagne->site->crm_password === null) {
throw new \Exception('CRM Password is missing.');
}
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [];
}
}