duandong1869 2016-06-21 16:05
浏览 140

Laravel - 数据库在保存时不更新

I can't figure out why this isn't working. I checked all the fields in the object and they are being changed fine. The function completes without errors and the Session::flash gets changed but the save is not updating the database. Any help would be great.

public function confirmLeague($id, $authToken)
{
    $league = League::find($id);

    if ($league == null || $league->AuthToken != $authToken || $league->Validated)
    {
        Session::flash('error', 'The league does not exist.');
        return redirect('/');
    }

    $league->Validated = true;
    $league->save();

    Session::flash('success', 'The league has been added.');
    return redirect('/');
}

Table script:

        Schema::create('leagues', function (Blueprint $table) {
        $table->increments('Id');
        $table->string('LeagueName', 250);
        $table->string('City', 50);
        $table->string('Province', 50);
        $table->string('Sport', 50);
        $table->string('Type', 10);
        $table->string('Website')->nullable();
        $table->string('Person', 100);
        $table->string('Phone', 20);
        $table->string('Email', 100);
        $table->string('Description', 250)->default('');
        $table->boolean('Validated')->default(FALSE);
    });
  • 写回答

2条回答 默认 最新

  • doubeng3412 2016-06-22 14:54
    关注

    Managed to fix the issue. Turns out laravel doesn't like capital letters in the column names in the database. I just renamed all my columns to lowercase and it worked

    评论

报告相同问题?

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离