Support the ongoing development of Laravel.io →
Eloquent Architecture
Last updated 2 years ago.
0

Finally I got answer myself for polymorphic relation to save in repository.

In create function--

  if($this->validator->isValid($inputs){
      // first store in temp model. $this model will be destroyed.
       $temp_model = $this->model->create($inputs);
      //then Depency Injection comein for polymorphic model
       $this->polymorphicmodel->create($subinputs):
       // link with polymorphic relation with $TEMP_MODEL not this->model. 
       $this->polymorphicmodel->modelable()->save($temp_model);
       return true;
    }
   return false;

really appreciate advanced modification or suggestion for better approached.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

moverly moverly Joined 30 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.