public function fillableFieldsByPolicy($fix, $fix_is_prefix = true, $delimiter = '.', $fields = null, $user = null)
    {
        if (!$fields) {
            $fields = $columns = Schema::getColumnListing($this->getTable());
        }

        if (!$user) {
            $user = \Auth::user();
        }

        $current_fillable = $this->getFillable();

        foreach ($fields as $field) {
            // Apply the prefix/suffix
            $field_ability = ($fix_is_prefix) ? $fix.$delimiter.$field : $field.$delimiter.$fix;
            // if field is currently fillable and the user can not access it then remove it from fillable
            if (array_search($field, $current_fillable) != false
                && $user->cannot($field_ability, app(Request::class))) {
                $i = array_search($field, $current_fillable);
                unset($current_fillable[$i]);
            }
        }
        $this->fillable(array_values($current_fillable));

        return $this;
    }
public function fillableFieldsByPolicy($fix, $fix_is_prefix = true, $delimiter = '.', $fields = null, $user = null)
    {
        if (!$fields) {
            $fields = $columns = Schema::getColumnListing($this->getTable());
        }

        if (!$user) {
            $user = \Auth::user();
        }

        $current_fillable = $this->getFillable();

        foreach ($fields as $field) {
            // Apply the prefix/suffix
            $field_ability = ($fix_is_prefix) ? $fix.$delimiter.$field : $field.$delimiter.$fix;
            // if field is currently fillable and the user can not access it then remove it from fillable
            if (array_search($field, $current_fillable) != false
                && $user->cannot($field_ability, app(Request::class))) {
                $i = array_search($field, $current_fillable);
                unset($current_fillable[$i]);
            }
        }
        $this->fillable(array_values($current_fillable));

        return $this;
    }
public function fillableFieldsByPolicy ( $ fix , $ fix_is_prefix = true , $ delimiter = '.' , $ fields = null , $ user = null ) { if ( ! $ fields ) { $ fields = $ columns = Schema :: getColumnListing ( $ this -> getTable ( ) ) ; } if ( ! $ user ) { $ user = \ Auth :: user ( ) ; } $ current_fillable = $ this -> getFillable ( ) ; foreach ( $ fields as $ field ) { // Apply the prefix/suffix $ field_ability = ( $ fix_is_prefix ) ? $ fix . $ delimiter . $ field : $ field . $ delimiter . $ fix ; // if field is currently fillable and the user can not access it then remove it from fillable if ( array_search ( $ field , $ current_fillable ) != false && $ user -> cannot ( $ field_ability , app ( Request :: class ) ) ) { $ i = array_search ( $ field , $ current_fillable ) ; unset ( $ current_fillable [ $ i ] ) ; } } $ this -> fillable ( array_values ( $ current_fillable ) ) ; return $ this ; }
Revoke not authorized fields for a user from model fillable fields.

@param $fix
@param bool   $fix_is_prefix
@param string $delimiter
@param null   $fields
@param null   $user

@return $this
Revoke not authorized fields for a user from model fillable fields .