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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community