2022-06-16 07:58:11 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Account;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
|
|
|
use App\Http\ValidationRules\Account\BlackListRule;
|
|
|
|
use App\Http\ValidationRules\Account\EmailBlackListRule;
|
|
|
|
use App\Http\ValidationRules\NewUniqueUserRule;
|
|
|
|
use App\Utils\Ninja;
|
|
|
|
|
|
|
|
class UpdateAccountRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
return (auth()->user()->isAdmin() || auth()->user()->isOwner()) && (int) $this->account->id === auth()->user()->account_id;
|
2022-06-16 07:58:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
2022-06-21 11:57:17 +02:00
|
|
|
'set_react_as_default_ap' => 'required|bail|bool',
|
2022-06-16 07:58:11 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-06-16 07:59:36 +02:00
|
|
|
/* Only allow single field to update account table */
|
2022-06-16 07:58:11 +02:00
|
|
|
protected function prepareForValidation()
|
|
|
|
{
|
|
|
|
$input = $this->all();
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
$cleaned_input = array_intersect_key($input, array_flip(['set_react_as_default_ap']));
|
2022-06-16 07:58:11 +02:00
|
|
|
|
|
|
|
$this->replace($cleaned_input);
|
|
|
|
}
|
|
|
|
}
|