50 lines
992 B
PHP
50 lines
992 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Comment;
|
|
|
|
use App\Http\Requests\InvalidDataResponseTrait;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreCommentRequest extends FormRequest
|
|
{
|
|
use InvalidDataResponseTrait;
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function all($keys = null): array
|
|
{
|
|
$request = parent::all($keys);
|
|
|
|
$request['post_id'] = $this->route('post_id');
|
|
|
|
return $request;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return static::rulesDefinition();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public static function rulesDefinition()
|
|
{
|
|
return [
|
|
'content' => 'required|string',
|
|
'post_id' => 'required|exists:posts,id',
|
|
];
|
|
}
|
|
}
|