删除表时间戳()时如何摆脱错误未知列updated_at

Brad_Fresh

我有这两个功能。当我尝试插入数据时出现此错误

Column not found: 1054 Unknown column 'updated_at&#039 

所以它一直在搜索“created at”和“updated at”表,但我之前已经摆脱了它,并将其替换为“joined”和“leaved”。如何解决?

在广播服务提供者中

Broadcast::channel('chat', function ($user) {
        $ip = Request::ip();
        $time = now();        
        if (auth()->check() && !session()->has('name'))  { 
            UserInfo::storeUser();
            session()->put('name',$user->name);
            return [
                'id' => $user->id,
                'ip' => $ip,
                'name' => $user->name,
                'joined' => $time,
            ];
        }
    });

架构

   Schema::create('user_info', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('ip');
        $table->string('joined');
        $table->string('leaved');
    });

在登录控制器中

 public function logout() {
    auth()->logout();
    session()->forget('name');
    session()->put('leaved',now());
       return redirect('/');
}
瑞安·奈兰

默认情况下,Eloquent 期望created_atupdated_at列存在于您的表中。

如果您不希望 Eloquent 自动管理这些列,请将$timestamps模型上属性设置false

/**
 * Indicates if the model should be timestamped.
 *
 * @var bool
 */
public $timestamps = false;

如果您需要自定义用于存储时间戳的列的名称,您可以在模型中设置CREATED_ATUPDATED_AT常量:

const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';

也可以看看:

雄辩的模型约定

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

从 updated_at 时间戳列中获取过去 X 天的表中的 MIN 聚合字段

在插入或更新时,我想用当前时间戳更新 UPDATED_AT 列

Laravel未知列'updated_at'

如何将 updated_at 从时间戳类型更改为日期时间?

如何在Hive中记录created_at和updated_at时间戳?

错误:找不到列:1054“字段列表”中的未知列“ updated_at”

Laravel API:时间戳(updated_at,created_at)为空

Laravel 4.2 DB类的Updated_at时间戳

领域 created_at 和 updated_at 时间戳

Laravel合并了created_at和updated_at时间戳

Laravel SQLSTATE [22007]:无效的日期时间格式:1292错误的日期时间值:'updated_at'列的'2019-03-10 02:00:39'(夏令时?)

保存到db时,laravel中的默认时间戳(create_at和updated_at)具有什么格式?

创建带有两个时间戳列的表时出现Laravel错误

如何从刀片数据库视图中的created_at或updated_at字段在刀片视图中显示unix时间戳?

如何从插入查询中删除`created_at`、`updated_at`(创建模型记录时)?

使用Rails迁移创建表时如何添加created_at和Updated_at

在时代转换时的“未知”时间戳格式

如何使用迁移在Laravel中创建不带created_at和Updated_at列的表

1292不正确的日期时间值列“的updated_at”

时间未知时如何按日期删除行

修改子表时如何更新父表时间戳?

强制将其转换为唯一列表时,熊猫时间戳会转换为整数-可能的错误?

NodeJS sequelize 时间戳被禁用但仍然出现未知列“createdAt”错误

自定义时间戳在 $model->save() 上复制 updated_at

使用Heroku,Rails排序在“ updated_at”时间戳列上不正确

如何从表中找到时间戳列

修改多列时如何输入多个时间戳?

如何摆脱 rsync 的 .d..t (时间戳更改)输出?

未知的时间戳格式