Closed manuele89 closed 1 year ago
I have this error: "Call to undefined method App \ Models \ Tags:: newModel () "
I need this: associate tags (already present in the tags table) to the user, storing the association in the pivot_user_tags table
this is my code:
Schema::create('ad_tag_pivot', function (Blueprint $table) { $table->id(); $table->text('title', 255); $table->timestamps(); });
Schema::create('pivot_user_tags table', function (Blueprint $table) { $table->id(); $table->integer('user_id')->unsigned(); $table->integer('tag_id')->unsigned(); $table->timestamps(); });
in app/Nova/User.php fields: SelectPlus::make('Tags', 'tags', 'App\Models\Tags')->label('title'),
SelectPlus::make('Tags', 'tags', 'App\Models\Tags')->label('title'),
in app/Models/Tags.php
public function tags() { return $this->belongsToMany('App\Models\Tags', 'pivot_user_tags table', 'user_id', 'tag_id'); }
when i go to edit user, i get the error: Call to undefined method App \ Models \ Tags:: newModel ()
can you help me?
+1
Try changing the 3rd parameter to SelectPlus::make(...) to App\Nova\Tags or Tags::class where Tags is the Nova Resource. The resources goes there, not the Model itself.
SelectPlus::make(...)
App\Nova\Tags
Tags::class
I have this error: "Call to undefined method App \ Models \ Tags:: newModel () "
I need this: associate tags (already present in the tags table) to the user, storing the association in the pivot_user_tags table
this is my code:
Schema::create('ad_tag_pivot', function (Blueprint $table) { $table->id(); $table->text('title', 255); $table->timestamps(); });
Schema::create('pivot_user_tags table', function (Blueprint $table) { $table->id(); $table->integer('user_id')->unsigned(); $table->integer('tag_id')->unsigned(); $table->timestamps(); });
in app/Nova/User.php fields:
SelectPlus::make('Tags', 'tags', 'App\Models\Tags')->label('title'),
in app/Models/Tags.php
when i go to edit user, i get the error: Call to undefined method App \ Models \ Tags:: newModel ()
can you help me?