小编S73*_*27B的帖子

如何在雄辩中插入变形相关模型

使用 laravel ducmunet 示例:

有像这样的表

posts
    id - integer
    title - string
    body - text

videos
    id - integer
    title - string
    url - string

comments
    id - integer
    body - text
    commentable_id - integer
    commentable_type - string

And 3 model (post, command and video) .
Comment model has morphTo relation with post and video.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Comment extends Model
{
    /**
     * Get all of the owning commentable models.
     */
    public function commentable()
    {
        return …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5

1
推荐指数
2
解决办法
9391
查看次数

标签 统计

laravel ×1

laravel-5 ×1