有时模型并不需要时间字段,比如一些配置项相关的数据表,可以在相应的Model中,添加 public $timestamps = false;
比如:
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
use HasFactory;
protected $primaryKey = 'name';
public $timestamps = false;
protected $fillable = [
'name',
'value'
];
}
网友评论