我有一个关于更新Laravel中的表的问题.我有一个User和Car模型.示例如下,
user.php的
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $guarded = [];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function cars()
{
return $this->hasMany(Car::class);
}
}
Run Code Online (Sandbox Code Playgroud)
Car.php
<?php
namespace App;
class Car extends Model
{
public function user()
{
return $this->belongsTo(User::class);
}
}
Run Code Online (Sandbox Code Playgroud)
对于更新,我在控制器上使用以下代码,
public function update(Request $request, $id)
{ …Run Code Online (Sandbox Code Playgroud) 我是Vue.js 的新手。我想了解使用component. 我试图将我的组件导入另一个组件,但失败了。我正在使用Laravel 5.8. 以下是我收到的错误。
找不到模块:错误:无法解析'./components/modalAlert.vue
下面是我的代码。
应用程序.js
Vue.component('form-to-do', require('./components/formToDo.vue').default);
Vue.component('modal-alert', require('./components/modalAlert.vue').default);
const app = new Vue({
el: '#app',
});
Run Code Online (Sandbox Code Playgroud)
formToDo.Vue
<template>
// form
<modal-alert></modal-alert>
</template>
<script>
import modalAlert from './components/modalAlert.vue';
export default {
components: {
'modal-alert': modalAlert
},
data() {
return {
setErrors: [],
tasks: [],
task: {
id: '',
name: '',
completed: '',
date_completed: ''
},
result: '',
input: {
name: ''
}
};
},
}
</script>
Run Code Online (Sandbox Code Playgroud)
modalAlert.vue
<template>
<div class="modal fade" …Run Code Online (Sandbox Code Playgroud)