2021-11-06 00:28:48 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @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)
|
2021-11-06 00:28:48 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\User;
|
|
|
|
|
|
|
|
use App\Http\Requests\Request;
|
|
|
|
use App\Http\ValidationRules\Ninja\CanRestoreUserRule;
|
|
|
|
use App\Http\ValidationRules\UniqueUserRule;
|
|
|
|
use App\Utils\Ninja;
|
|
|
|
|
|
|
|
class BulkUserRequest 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()
|
|
|
|
{
|
|
|
|
$rules = [];
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (Ninja::isHosted() && $this->action && $this->action == 'restore') {
|
2021-11-06 00:28:48 +01:00
|
|
|
$rules['ids'] = new CanRestoreUserRule();
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2021-11-06 00:28:48 +01:00
|
|
|
|
|
|
|
return $rules;
|
|
|
|
}
|
|
|
|
|
2022-06-24 03:55:41 +02:00
|
|
|
public function prepareForValidation()
|
2021-11-06 00:28:48 +01:00
|
|
|
{
|
|
|
|
$input = $this->all();
|
|
|
|
|
|
|
|
$this->replace($input);
|
|
|
|
}
|
|
|
|
}
|