小编Kha*_*rul的帖子

Laravel 5.4 - 雄辩的关系更新

我有一个关于更新Laravel中的表的问题.我有一个UserCar模型.示例如下,

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)

php eloquent laravel-5

3
推荐指数
1
解决办法
1万
查看次数

Laravel - 如何将 Vue 组件导入另一个组件

我是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)

html javascript vue.js

0
推荐指数
1
解决办法
2399
查看次数

标签 统计

eloquent ×1

html ×1

javascript ×1

laravel-5 ×1

php ×1

vue.js ×1