laravel 时间戳不起作用,删除模型但仍然可以检索值?

laravel timestamps not working, delete the model but still can retrieve value?

这是我的控制器

<?php

namespace App\Http\Controllers\HR;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\models\HR\attendance;

class attendanceController extends Controller
{
    public function select()
    {
        return attendance::get();
    }
}

这是我的路线web.php

Route::get('attendance/select/','HR\attendanceController@select');

这是我的模型attendance.php

<?php

namespace App\models\HR;

use Illuminate\Database\Eloquent\Model;

class attendance extends Model
{
    public $timestamps = false;
}

当我更新出勤模型时我有错误未知列 updated_at 这意味着我必须禁用时间戳然后我添加

public $timestamps = false;

但它没有用,我仍然得到未知列 updated_at。然后我删除它

这是我的目录结构 laravel,HR 文件夹中没有 attendance.php,其他地方也没有。但是,我可以从中检索值,这怎么可能?

By default, Eloquent expects created_at and updated_at columns to exist on your tables. If you do not wish to have these columns automatically managed by Eloquent, set the $timestamps property on your model to false:

您的 table attendance

中缺少 update_atcreated_at

laravel中,当你updatecreate数据时,laravel会默认添加这样的东西set update_at="YYYY-mm-dd HH:ii:ss"

因此,您应该将 update_atcreated_at 添加到每个 table。

laravel 5.6 document

对不起。这是我的错误,我已将 attendance.php 复制到其他文件夹,似乎作曲家 autoload_classmap.php 将其指向该文件夹