我跑:npm run dev
错误:已知 npm 无法在 Node.js v10.24.1 上运行
我已经研究并知道该命令:npm install -g npm@latest以及其他一些命令来解决问题
但问题是我的项目正在使用nodejs 10所以它不能使用最新的nodejs。那么有什么办法可以修复上述错误呢。谢谢
更新:我用来nvm安装和管理nodejs的版本。我的操作系统是 macOs
我使用 laravel 8 :
public function up()
{
Schema::create('user', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->integer('created_by')->nullable();
$table->string('created_by_user')->nullable();
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)
楷模:
<?php
namespace App\Models\Backend\MySQL;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = 'user';
}
Run Code Online (Sandbox Code Playgroud)
在控制器中:
use App\Models\User;
public function store(Request $request) {
$data = [
'name' => !empty($request->name) ? $request->name : 'Jony',
'created_by' => auth()->user()->id,
'created_by_user' => auth()->user()->name,
];
User::insert($data);
}
Run Code Online (Sandbox Code Playgroud)
我已经插入成功了。但问题是我的created_by 和updated_by 列没有自动更新。有什么办法可以解决这个问题吗?在user模型中我也没有设置protected $timestamps = false,但它不起作用。谢谢。