Search code examples
laravelvue.jsvoyager

"Trying to get property 'type' of non-object" when try to edit admin


Laravel Version: 5.7.14 Voyager Version: 1.1.1 PHP Version: 7.2

"Trying to get property 'type' of non-object"**

1.I am trying to edit admin user

2.there is users nav option when click on it same problem occurring In voyager admin panel. I am getting this issues .

C:\xampp\htdocs\mfscl_website\vendor\tcg\voyager\src\Http\Controllers\Traits\BreadRelationshipParser.php

    $forget_keys = [];
    foreach ($dataType->{$bread_type.'Rows'} as $key => $row) {
        if ($row->type == 'relationship') {
            if ($row->details->type == 'belongsTo') {
                $relationshipField = @$row->details->column;
                $keyInCollection = key($dataType->{$bread_type.'Rows'}->where('field', '=', $relationshipField)->toArray());
                array_push($forget_keys, $keyInCollection);
            }
        }
    }

"Trying to get property 'type' of non-object"


If I try to edit users bread getting this error:

ErrorException (E_ERROR) Trying to get property 'type' of non-object (View: C:\xampp\htdocs\mfscl_website\vendor\tcg\voyager\resources\views\tools\bread\relationship-partial.blade.php) (View: C:\xampp\htdocs\mfscl_website\vendor\tcg\voyager\resources\views\tools\bread\relationship-partial.blade.php) Previous exceptions Trying to get property 'type' of non-object (View: C:\xampp\htdocs\mfscl_website\vendor\tcg\voyager\resources\views\tools\bread\relationship-partial.blade.php) (0) Trying to get property 'type' of non-object (0)

    <div class="relationshipField">
    <div class="relationship_details_content margin_top belongsTo <?php if($relationshipDetails->type == 'belongsTo'): ?><?php echo e('flexed'); ?><?php endif; ?>">
<label><?php echo e(__('voyager::database.relationship.which_column_from')); ?> <span><?php echo e(str_singular(ucfirst($table))); ?></span> <?php echo e(__('voyager::database.relationship.is_used_to_reference')); ?> <span class="label_table_name"></span>?</label>
<select name="relationship_column_belongs_to_<?php echo e($relationship['field']); ?>" class="new_relationship_field select2">

Solution

  • The problem is in the user_belongsto_role_relationship record in the data_rows table. you can refer to this issue: https://github.com/the-control-group/voyager/issues/3871