First commit

This commit is contained in:
Saufi
2026-05-18 08:56:23 +08:00
commit fd3d3a4d2b
147 changed files with 22099 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreCategoryRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->canManageCategories();
}
public function rules(): array
{
$categoryId = $this->route('category')?->id;
return [
'name' => ['required', 'string', 'max:100'],
'slug' => [
'nullable',
'string',
'max:100',
'regex:/^[a-z0-9-]+$/',
Rule::unique('categories', 'slug')->ignore($categoryId)->whereNull('deleted_at'),
],
'description' => ['nullable', 'string', 'max:500'],
'color' => ['nullable', 'string', 'regex:/^#[0-9A-Fa-f]{6}$/'],
'is_active' => ['boolean'],
'sort_order' => ['nullable', 'integer', 'min:0'],
];
}
public function messages(): array
{
return [
'name.required' => 'Nama kategori wajib diisi.',
'slug.unique' => 'Slug ini sudah digunakan.',
'slug.regex' => 'Slug hanya boleh mengandungi huruf kecil, angka, dan tanda (-)',
'color.regex' => 'Warna mesti dalam format hex (contoh: #3b82f6)',
];
}
}