我有这两个功能。当我尝试插入数据时出现此错误
Column not found: 1054 Unknown column 'updated_at'
所以它一直在搜索“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_at
和updated_at
列存在于您的表中。
如果您不希望 Eloquent 自动管理这些列,请将$timestamps
模型上的属性设置为false
:
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
如果您需要自定义用于存储时间戳的列的名称,您可以在模型中设置CREATED_AT
和UPDATED_AT
常量:
const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';
也可以看看:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句