dimanche 6 août 2017

polymorphic relationship that is of belongsToMany type so I can attach single record to multiple polymorphic records

I have created table settings and model Setting.

This is definition of the table:

        $table->bigincrements('id');
        $table->string('has_settings_type');
        $table->biginteger('has_settings_id')->unsigned();
        $table->string('key');
        $table->string('value')->nullable();
        $table->string('type')->default('string');

This allows me to attach a setting to a single Model. However I have come up with usercase where I would like to attach setting to multiple models not just one and it still has to be polymorphic relationship.

I know how to create belongsToMany when not using polymorphism but I am not sure how to design the tables when using polymorphism and I need belongsToMany.

Any suggestions how I may do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wjIr3g
via IFTTT

Aucun commentaire:

Enregistrer un commentaire