skl/app/Http/Requests/PostRequest.php

37 lines
1005 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class PostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'KategoriId' => 'required|exists:Kategori,KategoriId',
'SubKategoriId' => [
'required',
Rule::exists('SubKategori', 'SubKategoriId')->where('KategoriId', $this->KategoriId),
],
'JudulPost' => ['required', 'string', 'max:255'],
'DescPost' => ['required', 'string'],
'ImagePost' => ['nullable', 'image', 'mimes:jpg,png,webp', 'max:2048'],
];
}
}