小编use*_*910的帖子

如何删除Eloquent中的多态关系?

我有这样的模型:

<?php

class Post extends Eloquent {
    protected $fillable = [];


    public function photos()
    {
        return $this->morphMany('Upload', 'imageable');
    }

    public function attachments()
    {
        return $this->morphMany('Upload', 'attachable');
    }

}
Run Code Online (Sandbox Code Playgroud)

我的morphMany表的架构是这样的:

CREATE TABLE `uploads` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`raw_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`size` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`downloads` int(11) NOT NULL DEFAULT '0',
`imageable_id` int(11) DEFAULT NULL,
`imageable_type` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`attachable_id` int(11) DEFAULT NULL,
`attachable_type` …
Run Code Online (Sandbox Code Playgroud)

php polymorphic-associations laravel eloquent

5
推荐指数
2
解决办法
8541
查看次数

标签 统计

eloquent ×1

laravel ×1

php ×1

polymorphic-associations ×1