尝试编辑管理员时“尝试获取非对象的属性'类型'”

时间:2019-01-06 13:55:00

标签: laravel vue.js voyager

Laravel版本:5.7.14 航海家版本:1.1.1 PHP版本:7.2

  

“试图获取非对象的属性'type'” **

1。我正在尝试编辑管理员用户

2。单击“用户导航”选项时,在航海家管理面板中发生了同样的问题。我遇到了这个问题。

  

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);
            }
        }
    }
  

“试图获取非对象的属性'type'”


如果我尝试编辑用户,就会遇到此错误:

  

ErrorException(E_ERROR)试图获取非对象的属性“类型”   (视图:   C:\ xampp \ htdocs \ mfscl_website \ vendor \ tcg \ voyager \ resources \ views \ tools \ bread \ relationship-partial.blade.php)   (视图:   C:\ xampp \ htdocs \ mfscl_website \ vendor \ tcg \ voyager \ resources \ views \ tools \ bread \ relationship-partial.blade.php)   以前的异常尝试获取非对象的属性“类型”(查看:   C:\ xampp \ htdocs \ mfscl_website \ vendor \ tcg \ voyager \ resources \ views \ tools \ bread \ relationship-partial.blade.php)   (0)试图获取非对象(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">

2 个答案:

答案 0 :(得分:0)

问题出在data_rows表的user_belongsto_role_relationship记录中。 您可以参考此问题: https://github.com/the-control-group/voyager/issues/3871

答案 1 :(得分:0)

实际上,我在https://github.com/the-control-group/voyager/issues/3871中发布了答案,但在此处为其他用户重新发布了答案。

错误的文件: {"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"}

希望有帮助!