33 lines
830 B
PHP
33 lines
830 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Tenant;
|
|
|
|
use App\Services\Addons\EventAddonCatalog;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class EventAddonCheckoutRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var EventAddonCatalog $catalog */
|
|
$catalog = app(EventAddonCatalog::class);
|
|
$keys = array_keys($catalog->all());
|
|
$inRule = $keys === [] ? 'string' : 'in:'.implode(',', $keys);
|
|
|
|
return [
|
|
'addon_key' => ['required', 'string', $inRule],
|
|
'quantity' => ['nullable', 'integer', 'min:1', 'max:50'],
|
|
'success_url' => ['nullable', 'url'],
|
|
'cancel_url' => ['nullable', 'url'],
|
|
];
|
|
}
|
|
}
|