3

i have problem in laravel. i have created multiple morph in one table.

table structure 
table_name : morphicable
id: 
model_id:       eg: '1'
model_type:     eg 'model/comment'

model_one_id:   eg: '1'
model_one_type: eg 'model/order'

in above relationship we can saving the data from comment to order and order to comment like many to manay.

Now the problem is that how to get the both data from one ORM method. like some time we save comment in model type and some time in model typeOne.

i want to get the data from both models in one go.

public function morphicable(): MorphMany
{
    return $this->morphMany(morphicable::class, 'model');
}
  • This is not the correct setup for morph relationships in laravel, please take a look at the documentation it is explained pretty good there: https://laravel.com/docs/8.x/eloquent-relationships#polymorphic-relationships – Aless55 May 06 '21 at 10:54
  • yes but i have a problem where i need many to many morph for the whole project – arsalan ahmad May 06 '21 at 10:56
  • What's the PHP 5 tag doing here? You can't run Laravel 8 on that. – Laurel Nov 06 '21 at 21:44

0 Answers0