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
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. 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';
|
|
|
|
|
|
|
|
if($this->number)
|
|
|
|
$rules['number'] = Rule::unique('tax_rates')->where('company_id', auth()->user()->company()->id)->ignore($this->tax_rate->id);
|
|
|
|
|
|
|
|
return $rules;
|
|
|
|
|
2019-10-29 03:55:26 +01:00
|
|
|
}
|
|
|
|
}
|