Mar 18, 2024
0
Level 1
morphToMany relationship in current table
Hi I have table "projects" with field BasedOnId And I want to create morphToMany relationsship in current table
In resource Projects I create field
MorphToMany::make(\App\Nova\Projects::label(), 'based', '\App\Nova\Projects') ->searchable() ->singularLabel(\App\Nova\Projects::singularLabel())
And in model Projects I want to create "based" funtion, but how I can do it with same table?
Code
public function based()
{
return $this->belongsToMany('App\Models\Projects', 'projects', 'basedOnId', 'id');
}
not work
How I can do it?
Please or to participate in this conversation.