azhar_hussain
6 months ago

save to laravel polymorphic relationship

Posted 6 months ago by azhar_hussain

when im trying to submit then following error comes

"message": "Method Illuminate\Support\Collection::likes does not exist. 100"

my code looks like this


 $type=ModelType::whereId($input['likeable_type'])->pluck('title');
                $this->model=$type;
                $model=new $this->model;
                $model->likes()->create([
                    'user_id'=>Auth::user()->id,
                    'likeable_id'=>$model['likeable_id']
                ]);



willl be appriciated

Please sign in or create an account to participate in this conversation.