2019-10-29 03:55:26 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-10-29 03:55:26 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2022-04-27 05:20:41 +02:00
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-10-29 03:55:26 +01:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-10-29 03:55:26 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\TaxRate;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
2021-03-19 23:51:52 +01:00
|
|
|
use Illuminate\Validation\Rule;
|
2019-10-29 03:55:26 +01:00
|
|
|
|
|
|
|
class UpdateTaxRateRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize() : bool
|
|
|
|
{
|
|
|
|
return auth()->user()->isAdmin();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
2021-03-19 23:51:52 +01:00
|
|
|
$rules = [];
|
|
|
|
|
|
|
|
$rules['rate'] = 'numeric';
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if ($this->number) {
|
2021-03-19 23:51:52 +01:00
|
|
|
$rules['number'] = Rule::unique('tax_rates')->where('company_id', auth()->user()->company()->id)->ignore($this->tax_rate->id);
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2021-03-19 23:51:52 +01:00
|
|
|
|
|
|
|
return $rules;
|
2019-10-29 03:55:26 +01:00
|
|
|
}
|
|
|
|
}
|