e3da625927
- Backend Laravel 11 (API REST, JWT auth, PostgreSQL) - Frontend Next.js 14 (React, TypeScript, Tailwind CSS) - Docker Compose (PostgreSQL, backend, frontend) - Modules : auth, profil, tracker émotions, informations, admin
39 lines
904 B
PHP
39 lines
904 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreFeedRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'titre' => 'required|string|max:255',
|
|
'contenu' => 'required|string',
|
|
'image_url' => 'nullable|string|max:500',
|
|
'est_publie' => 'boolean',
|
|
'ordre' => 'integer|min:0',
|
|
];
|
|
|
|
if ($this->isMethod('POST')) {
|
|
$rules['slug'] = 'nullable|string|max:255|unique:feeds,slug';
|
|
} else {
|
|
$rules['slug'] = [
|
|
'nullable',
|
|
'string',
|
|
'max:255',
|
|
Rule::unique('feeds', 'slug')->ignore($this->route('id')),
|
|
];
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
}
|