refactor(backend): reorganize domains into Core, Commerce, Ticketing and Shared
This commit is contained in:
41
app/Domains/Commerce/Cart/Requests/AddCartItemRequest.php
Normal file
41
app/Domains/Commerce/Cart/Requests/AddCartItemRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Cart\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class AddCartItemRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$tenantCode = $this->route('tenant')?->codigo;
|
||||
|
||||
return [
|
||||
'catalog_item_id' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::exists('catalog_items', 'id')->where(
|
||||
fn ($query) => $query->where('tenant_code', $tenantCode)
|
||||
),
|
||||
],
|
||||
'variant_id' => [
|
||||
'sometimes',
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('variantes', 'id')->where(
|
||||
fn ($query) => $query->where('catalog_item_id', $this->input('catalog_item_id'))
|
||||
),
|
||||
],
|
||||
'cantidad' => ['required', 'integer', 'min:1'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user