2021-04-07 18:08:26 +02:00
|
|
|
<?php
|
2023-01-31 22:43:32 +01:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
2021-04-07 18:08:26 +02:00
|
|
|
|
|
|
|
namespace App\Http\Requests\ClientPortal\Subscriptions;
|
|
|
|
|
2023-01-31 22:43:32 +01:00
|
|
|
use App\Exceptions\Ninja\ClientPortalAuthorizationException;
|
2021-04-07 18:08:26 +02:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
class ShowPlanSwitchRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
return (bool) $this->recurring_invoice->subscription->allow_plan_changes;
|
2021-04-07 18:08:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
2023-01-31 22:43:32 +01:00
|
|
|
|
|
|
|
protected function failedAuthorization()
|
|
|
|
{
|
|
|
|
throw new ClientPortalAuthorizationException('Unable to change plans due to a restriction on this product.', 400);
|
|
|
|
}
|
2021-04-07 18:08:26 +02:00
|
|
|
}
|