Add Brand and Category management features with controllers, requests, resources, and API routes
This commit is contained in:
27
app/Domains/Catalog/Requests/StoreBrandRequest.php
Normal file
27
app/Domains/Catalog/Requests/StoreBrandRequest.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Domains/Catalog/Requests/StoreCategoryRequest.php
Normal file
27
app/Domains/Catalog/Requests/StoreCategoryRequest.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Domains/Catalog/Requests/UpdateBrandRequest.php
Normal file
27
app/Domains/Catalog/Requests/UpdateBrandRequest.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Domains/Catalog/Requests/UpdateCategoryRequest.php
Normal file
37
app/Domains/Catalog/Requests/UpdateCategoryRequest.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user