37 lines
839 B
PHP
37 lines
839 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\BannedIps;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateBannedIpRequest extends StoreBannedIpRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return Gate::check('update', $this->route('banned_ip'));
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
/** @var \App\Models\BannedIp */
|
|
$ipToBanModel = $this->route('banned_ip');
|
|
return [
|
|
'ip' => [
|
|
'required', 'ip',
|
|
Rule::unique('banned_ips', 'ip')
|
|
->ignore($ipToBanModel->ip, 'ip')
|
|
],
|
|
];
|
|
}
|
|
}
|