我不知道这个方法有什么用,我在某人的代码上看到了这样的东西。
$user = JWTAuth::parseToken()->authenticate();
$new_car = new Car();
$new_car->name = $request->name;
$new_car->age = $request->age;
$new_car->model = $request->model;
$new_car->save();
$time = new Reservation();
$time->from_date = $request->from_date;
$time->to_date = $request->to_date;
$time->from_time= $request->from_time;
$time->to_time = $request->to_time;
$time->save();
// Attach the reservation to the car's reservations
$new_car->Reservation()->attach($time->id);
// Attach the car to the user cars
$user->cars()->attach($new_car->id);
Run Code Online (Sandbox Code Playgroud)
希望有人能很好地解释我。
你好,我正在npm install我的 laravel 项目中安装,但出现错误
npm ERR! code EJSONPARSE
npm ERR! path C:\xampp\htdocs\laravel_project/package.json
npm ERR! JSON.parse Unexpected token "}" (0x7D) in JSON at position 98 while parsing near "...: \"vite
build\",\n },\n \"devDependenc..."
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\my_PC\AppData\Local\npm-cache\_logs\2022-11-16T13_59_50_980Z-debug-0.log
PS C:\xampp\htdocs\laravel_project>
Run Code Online (Sandbox Code Playgroud)
我已经尝试删除我的node_modulepackage-lock.json中的内容并且已经做了这些
npm cache clear --force
npm …Run Code Online (Sandbox Code Playgroud)