mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Http\Requests\Traits\MayContainCustomFields;
|
|
use App\Models\Asset;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateAssetRequest extends ImageUploadRequest
|
|
{
|
|
use MayContainCustomFields;
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return Gate::allows('update', $this->asset);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$rules = array_merge(
|
|
parent::rules(),
|
|
(new Asset)->getRules(),
|
|
// this is to overwrite rulesets that include required, and rewrite unique_undeleted
|
|
[
|
|
'model_id' => ['integer', 'exists:models,id,deleted_at,NULL', 'not_array'],
|
|
'status_id' => ['integer', 'exists:status_labels,id'],
|
|
'asset_tag' => [
|
|
'min:1', 'max:255', 'not_array',
|
|
Rule::unique('assets', 'asset_tag')->ignore($this->asset)->withoutTrashed()
|
|
],
|
|
],
|
|
);
|
|
|
|
return $rules;
|
|
}
|
|
}
|