44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\V1;
|
|
|
|
use App\Enums\PressReleaseStatus;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StorePressReleaseRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->tokenCan('press-releases:write') === true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'company_id' => ['required', 'integer', 'exists:companies,id'],
|
|
'category_id' => ['required', 'integer', 'exists:categories,id'],
|
|
'language' => ['required', 'string', 'size:2'],
|
|
'title' => ['required', 'string', 'max:255'],
|
|
'text' => ['required', 'string'],
|
|
'backlink_url' => ['nullable', 'url', 'max:255'],
|
|
'keywords' => ['nullable', 'string', 'max:255'],
|
|
'status' => ['nullable', Rule::in([
|
|
PressReleaseStatus::Draft->value,
|
|
PressReleaseStatus::Review->value,
|
|
])],
|
|
'teaser_begin' => ['nullable', 'integer', 'min:0'],
|
|
'teaser_end' => ['nullable', 'integer', 'min:0'],
|
|
'no_export' => ['nullable', 'boolean'],
|
|
];
|
|
}
|
|
}
|