"Trying to get property 'type' of non-object" 尝试编辑管理员时
"Trying to get property 'type' of non-object" when try to edit admin
Laravel版本:5.7.14
航海者版本:1.1.1
PHP版本:7.2
"Trying to get property 'type' of non-object"**
1.I 正在尝试编辑管理员用户
2.there 是用户导航选项,当点击它时在 voyager 管理面板中出现同样的问题。我遇到了这个问题。
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"
如果我尝试编辑用户面包时出现此错误:
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">
问题出在 data_rows table 中的 user_belongsto_role_relationship 记录中。
你可以参考这个问题:
https://github.com/the-control-group/voyager/issues/3871
实际上,我 post 在 https://github.com/the-control-group/voyager/issues/3871 中编辑了一个答案,但在这里为其他用户重新post。
错误的文件:
{"model":"TCG\Voyager\Models\Role","table":"roles","type":"belongsToMany","column":"id","key":"id","label":"name","pivot_table":"user_roles","pivot":"1"}
我的解决方案:
{"model":"TCG\\Voyager\\Models\\Role","table":"roles","type":"belongsToMany","column":"id","key":"id","label":"name","pivot_table":"user_roles","pivot":"1"}
希望对您有所帮助!
Laravel版本:5.7.14 航海者版本:1.1.1 PHP版本:7.2
"Trying to get property 'type' of non-object"**
1.I 正在尝试编辑管理员用户
2.there 是用户导航选项,当点击它时在 voyager 管理面板中出现同样的问题。我遇到了这个问题。
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"
如果我尝试编辑用户面包时出现此错误:
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">
问题出在 data_rows table 中的 user_belongsto_role_relationship 记录中。 你可以参考这个问题: https://github.com/the-control-group/voyager/issues/3871
实际上,我 post 在 https://github.com/the-control-group/voyager/issues/3871 中编辑了一个答案,但在这里为其他用户重新post。
错误的文件:
{"model":"TCG\Voyager\Models\Role","table":"roles","type":"belongsToMany","column":"id","key":"id","label":"name","pivot_table":"user_roles","pivot":"1"}
我的解决方案:
{"model":"TCG\\Voyager\\Models\\Role","table":"roles","type":"belongsToMany","column":"id","key":"id","label":"name","pivot_table":"user_roles","pivot":"1"}
希望对您有所帮助!