first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'parent_id' => ['nullable', 'exists:categories,id'],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['nullable', 'string', 'max:255', Rule::unique('categories', 'slug')],
|
||||
'description' => ['nullable', 'string'],
|
||||
'meta_title' => ['nullable', 'string', 'max:60'],
|
||||
'meta_description' => ['nullable', 'string', 'max:160'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Enums\PostStatus;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StorePostRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => ['nullable', 'exists:categories,id'],
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['nullable', 'string', 'max:255', Rule::unique('posts', 'slug')],
|
||||
'excerpt' => ['nullable', 'string', 'max:255'],
|
||||
'body' => ['required', 'string'],
|
||||
'featured_image' => ['nullable', 'string'],
|
||||
'status' => ['required', new Enum(PostStatus::class)],
|
||||
'published_at' => ['nullable', 'date'],
|
||||
'meta_title' => ['nullable', 'string', 'max:60'],
|
||||
'meta_description' => ['nullable', 'string', 'max:160'],
|
||||
'tags' => ['sometimes', 'array'],
|
||||
'tags.*' => ['integer', 'exists:tags,id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreTagRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['nullable', 'string', 'max:255', Rule::unique('tags', 'slug')],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreToolRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'slug' => ['nullable', 'string', 'max:255', Rule::unique('tools', 'slug')],
|
||||
'description' => ['required', 'string'],
|
||||
'url' => ['required', 'url', 'max:255'],
|
||||
'logo_url' => ['nullable', 'url', 'max:255'],
|
||||
'category' => ['required', Rule::in(array_keys(config('tools.categories')))],
|
||||
'subcategory' => ['nullable', 'string', 'max:255'],
|
||||
'tags' => ['sometimes', 'array'],
|
||||
'tags.*' => ['string', 'max:50'],
|
||||
'pricing' => ['nullable', 'string', 'max:255'],
|
||||
'features' => ['sometimes', 'array'],
|
||||
'features.*' => ['string', 'max:255'],
|
||||
'featured' => ['sometimes', 'boolean'],
|
||||
'approved' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateCategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'parent_id' => ['nullable', 'exists:categories,id', Rule::notIn([$this->route('category')?->id])],
|
||||
'name' => ['sometimes', 'required', 'string', 'max:255'],
|
||||
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('categories', 'slug')->ignore($this->route('category'))],
|
||||
'description' => ['nullable', 'string'],
|
||||
'meta_title' => ['nullable', 'string', 'max:60'],
|
||||
'meta_description' => ['nullable', 'string', 'max:160'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Enums\PostStatus;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class UpdatePostRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => ['nullable', 'exists:categories,id'],
|
||||
'title' => ['sometimes', 'required', 'string', 'max:255'],
|
||||
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('posts', 'slug')->ignore($this->route('post'))],
|
||||
'excerpt' => ['nullable', 'string', 'max:255'],
|
||||
'body' => ['sometimes', 'required', 'string'],
|
||||
'featured_image' => ['nullable', 'string'],
|
||||
'status' => ['sometimes', 'required', new Enum(PostStatus::class)],
|
||||
'published_at' => ['nullable', 'date'],
|
||||
'meta_title' => ['nullable', 'string', 'max:60'],
|
||||
'meta_description' => ['nullable', 'string', 'max:160'],
|
||||
'tags' => ['sometimes', 'array'],
|
||||
'tags.*' => ['integer', 'exists:tags,id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateTagRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['sometimes', 'required', 'string', 'max:255'],
|
||||
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('tags', 'slug')->ignore($this->route('tag'))],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateToolRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['sometimes', 'required', 'string', 'max:255'],
|
||||
'slug' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('tools', 'slug')->ignore($this->route('tool'))],
|
||||
'description' => ['sometimes', 'required', 'string'],
|
||||
'url' => ['sometimes', 'required', 'url', 'max:255'],
|
||||
'logo_url' => ['nullable', 'url', 'max:255'],
|
||||
'category' => ['sometimes', 'required', Rule::in(array_keys(config('tools.categories')))],
|
||||
'subcategory' => ['nullable', 'string', 'max:255'],
|
||||
'tags' => ['sometimes', 'array'],
|
||||
'tags.*' => ['string', 'max:50'],
|
||||
'pricing' => ['nullable', 'string', 'max:255'],
|
||||
'features' => ['sometimes', 'array'],
|
||||
'features.*' => ['string', 'max:255'],
|
||||
'featured' => ['sometimes', 'boolean'],
|
||||
'approved' => ['sometimes', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user