Done
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Categories;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'parent_id' => [
|
||||
'nullable',
|
||||
Rule::exists('categories', 'id')->where('user_id', $this->user()->id),
|
||||
],
|
||||
'feeds' => ['array'],
|
||||
'feeds.*.url' => ['required', 'url', 'max:2048'],
|
||||
'feeds.*.type' => ['required', Rule::in(['rss'])],
|
||||
'feeds.*.paywall' => ['boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Categories;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->route('category')->user_id === $this->user()->id;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'parent_id' => [
|
||||
'nullable',
|
||||
Rule::exists('categories', 'id')->where('user_id', $this->user()->id),
|
||||
Rule::notIn([$this->route('category')->id]),
|
||||
],
|
||||
'feeds' => ['array'],
|
||||
'feeds.*.url' => ['required', 'url', 'max:2048'],
|
||||
'feeds.*.type' => ['required', Rule::in(['rss'])],
|
||||
'feeds.*.paywall' => ['boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user