mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Don’t make required encrypted custom fields required if user is not an admin
This commit is contained in:
parent
96eb832fd3
commit
537ad28a67
|
@ -2,6 +2,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Gate;
|
||||
|
||||
class CustomFieldset extends Model
|
||||
{
|
||||
|
@ -30,16 +31,21 @@ class CustomFieldset extends Model
|
|||
{
|
||||
$rules=[];
|
||||
foreach ($this->fields as $field) {
|
||||
$rule=[];
|
||||
if ($field->pivot->required) {
|
||||
$rule[]="required";
|
||||
$rule = [];
|
||||
|
||||
if (($field->field_encrypted!='1') ||
|
||||
(($field->field_encrypted =='1') && (Gate::allows('admin')) ))
|
||||
{
|
||||
|
||||
if ($field->pivot->required) {
|
||||
$rule[]="required";
|
||||
}
|
||||
}
|
||||
|
||||
array_push($rule, $field->attributes['format']);
|
||||
$rules[$field->db_column_name()]=$rule;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
//requiredness goes *here*
|
||||
//sequence goes here?
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue