Files
bogazici-api/app/Http/Requests/Comment/StoreCommentRequest.php
2026-03-27 10:41:54 +03:00

45 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Comment;
use Illuminate\Foundation\Http\FormRequest;
class StoreCommentRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, array<int, string>>
*/
public function rules(): array
{
return [
'commentable_type' => ['required', 'string', 'in:course,category,announcement'],
'commentable_id' => ['required', 'integer'],
'author_name' => ['required', 'string', 'max:255'],
'content' => ['required', 'string', 'max:1000'],
'rating' => ['nullable', 'integer', 'min:1', 'max:5'],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'commentable_type.required' => 'Yorum tipi zorunludur.',
'commentable_type.in' => 'Geçersiz yorum tipi.',
'commentable_id.required' => 'Yorum hedefi zorunludur.',
'author_name.required' => 'İsim zorunludur.',
'content.required' => 'Yorum içeriği zorunludur.',
'content.max' => 'Yorum en fazla 1000 karakter olabilir.',
'rating.min' => 'Puan en az 1 olabilir.',
'rating.max' => 'Puan en fazla 5 olabilir.',
];
}
}