1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 14:42:42 +01:00
invoiceninja/app/Http/Requests/CompanyGateway/UpdateCompanyGatewayRequest.php
David Bomba 37a826374b
Remove settings from invoice table (#3051)
* Implement client/group/company level counters clientCounter, groupCounter and counter

* Implement functionalityfor customising the timing of invoice_number creation

* Add Jobs

* adjustments

* clean line items at the request layer

* Clean line items at the request layer

* minor formatting for notification

* Schema Fixes

* schema changes, cast country_id to stirng

* Fixes for tests

* force line item ids to string

* Map company gateway fees and limits

* Schema changes

* Remove id from invoice item stdClass

* Remove settings object from invoice table
2019-11-10 23:06:30 +11:00

67 lines
2.5 KiB
PHP

<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\CompanyGateway;
use App\Http\Requests\Request;
use App\Models\Company;
class UpdateCompanyGatewayRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->user()->isAdmin();
}
public function rules()
{
$this->sanitize();
$rules = [
];
return $rules;
}
public function sanitize()
{
$input = $this->all();
$input['config'] = encrypt($input['config']);
$input['min_limit'] = isset($input['fees_and_limits']['min_limit']) ? $input['fees_and_limits']['min_limit'] : null;
$input['max_limit'] = isset($input['fees_and_limits']['max_limit']) ? $input['fees_and_limits']['max_limit'] : null;
$input['fee_amount'] = isset($input['fees_and_limits']['fee_amount']) ? $input['fees_and_limits']['fee_amount'] : null;
$input['fee_percent'] = isset($input['fees_and_limits']['fee_percent']) ? $input['fees_and_limits']['fee_percent'] : null;
$input['fee_tax_name1'] = isset($input['fees_and_limits']['fee_tax_name1']) ? $input['fees_and_limits']['fee_tax_name1'] : '';
$input['fee_tax_name2'] = isset($input['fees_and_limits']['fee_tax_name2']) ? $input['fees_and_limits']['fee_tax_name2'] : '';
$input['fee_tax_name3'] = isset($input['fees_and_limits']['fee_tax_name3']) ? $input['fees_and_limits']['fee_tax_name3'] : '';
$input['fee_tax_rate1'] = isset($input['fees_and_limits']['fee_tax_rate1']) ? $input['fees_and_limits']['fee_tax_rate1'] : 0;
$input['fee_tax_rate2'] = isset($input['fees_and_limits']['fee_tax_rate2']) ? $input['fees_and_limits']['fee_tax_rate2'] : 0;
$input['fee_tax_rate3'] = isset($input['fees_and_limits']['fee_tax_rate3']) ? $input['fees_and_limits']['fee_tax_rate3'] : 0;
$input['fee_cap'] = isset($input['fees_and_limits']['fee_cap']) ? $input['fees_and_limits']['fee_cap'] : null;
$input['adjust_fee_percent'] = isset($input['fees_and_limits']['adjust_fee_percent']) ? $input['fees_and_limits']['adjust_fee_percent'] : 0;
$this->replace($input);
return $this->all();
}
}