mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-18 09:11:00 -08:00
31 lines
760 B
PHP
31 lines
760 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Requests\Traits;
|
||
|
|
||
|
trait MayContainCustomFields
|
||
|
{
|
||
|
//public function after()
|
||
|
//{
|
||
|
// dd($this);
|
||
|
// $request_data = $this;
|
||
|
//}
|
||
|
|
||
|
public function withValidator($validator)
|
||
|
{
|
||
|
$validator->after(function ($validator) {
|
||
|
$custom_fields = $this->collect()->keys()->filter(function ($attributes) {
|
||
|
return str_starts_with($attributes, '_snipeit_');
|
||
|
});
|
||
|
if (count($custom_fields) > 0) {
|
||
|
if ($this->method() == 'POST') {
|
||
|
dd($this->model_id);
|
||
|
} elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
|
||
|
dd($this->asset());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|