Don’t make required encrypted custom fields required if user is not an admin

This commit is contained in:
snipe 2016-08-25 21:03:52 -07:00
parent 96eb832fd3
commit 537ad28a67

View file

@ -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?
}