Add Brand and Category management features with controllers, requests, resources, and API routes

This commit is contained in:
2026-06-24 10:20:13 -03:00
parent 8feaa0051d
commit 6a0080b475
11 changed files with 358 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Domains\Catalog\Requests;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
class StoreBrandRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'tenant_codigo' => ['required', 'string', 'exists:tenants,codigo'],
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
...PropRules::sync(),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Domains\Catalog\Requests;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
class StoreCategoryRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'tenant_code' => ['required', 'string', 'exists:tenants,codigo'],
'categoria_id' => ['nullable', 'integer', 'exists:categorias,id'],
'nombre' => ['required', 'string', 'max:255'],
...PropRules::sync(),
];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Domains\Catalog\Requests;
use App\Domains\Prop\Support\PropRules;
use Illuminate\Foundation\Http\FormRequest;
class UpdateBrandRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'tenant_codigo' => ['required', 'string', 'exists:tenants,codigo'],
'nombre' => ['required', 'string', 'max:255'],
'descripcion' => ['nullable', 'string'],
...PropRules::sync(),
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Domains\Catalog\Requests;
use App\Domains\Catalog\Models\Category;
use App\Domains\Prop\Support\PropRules;
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
{
/** @var Category|null $category */
$category = $this->route('categoria');
return [
'tenant_code' => ['required', 'string', 'exists:tenants,codigo'],
'categoria_id' => [
'nullable',
'integer',
'exists:categorias,id',
Rule::notIn([$category?->id]),
],
'nombre' => ['required', 'string', 'max:255'],
...PropRules::sync(),
];
}
}