【问题标题】:Laravel Illegal offset type in isset or empty Error when updatingLaravel Iset 中的非法偏移类型或更新时为空错误
【发布时间】:2017-07-14 09:48:24
【问题描述】:

我正在做一个项目,我需要更改表上的主键,所以当我搜索如何制作 $variable->save() 方法时,我遇到了我需要添加一个

protected $primaryKey = ['cedula','nacionalidad'];

确实是我在那张桌子上的主键,但现在当我做一个

$variable->save()

我没有返回错误

错误异常 isset 中的非法偏移类型或为空

这是我更新的代码

$person = AVC::where(['nacionalidad'=>Auth::user()->nacionalidad , 'cedula' => Auth::user()->cedula ])->get();

    $person[0]->centro_votacion = Request('centro');

    $person[0]->save();

    dd($person[0]);
    return redirect()->back()->with('message','Se a agregado o Actualizado tu centro de Votacion');

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

    如果你使用 dd($person[0]);并且返回不为空

    尝试使用这个

    $person[0]->update();
    

    ErrorException Illegal offset type in isset 或 empty 出现,因为它的格式不正确。

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2018-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-03
      • 1970-01-01
      • 2013-06-21
      • 1970-01-01
      相关资源
      最近更新 更多