- Introduced a new configuration file for purchase settings, including checkout and payment expiration times. - Added a migration to include a `reservation_status` column in the `compra_items` table, defaulting to 'active' and updating existing records based on purchase status. - Created a migration to add an `expires_at` timestamp to the `compras` table, updating it for existing records based on their status. - Scoped unique indexes in the `carritos` table to only active carts, adding virtual columns for active user and guest tokens. - Implemented a console command to expire overdue purchases and release stock reservations, scheduled to run every minute. - Added tests for Google token exchange and login functionality, ensuring proper cart handling and user authentication. - Updated purchase-related tests to reflect changes in item handling and customer data validation.
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Purchase\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StartCheckoutRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'cart_id' => [
|
|
'required_without:direct_item',
|
|
Rule::prohibitedIf(fn (): bool => $this->has('direct_item')),
|
|
'integer',
|
|
'exists:carritos,id',
|
|
],
|
|
'direct_item' => [
|
|
'required_without:cart_id',
|
|
Rule::prohibitedIf(fn (): bool => $this->has('cart_id')),
|
|
'array',
|
|
],
|
|
'direct_item.catalog_item_id' => [
|
|
'required_with:direct_item',
|
|
'integer',
|
|
],
|
|
'direct_item.variant_id' => [
|
|
'nullable',
|
|
'integer',
|
|
],
|
|
'direct_item.cantidad' => [
|
|
'required_with:direct_item',
|
|
'integer',
|
|
'min:1',
|
|
],
|
|
'dni' => ['prohibited'],
|
|
'telefono' => ['prohibited'],
|
|
'nombre_apellido' => ['prohibited'],
|
|
'email' => ['prohibited'],
|
|
];
|
|
}
|
|
}
|