Did make any progress with this @ffischer ? I'm getting the same error
Laravel Nova Tags
Hello, I have problems with Laravel Nova to make the "tags" functional. I always get errors.
I have two entities, both in Laravel and Nova. Both work for themselves without problems. And the Laravel BelongsToMany relation is working.
Let's say I have tthese entities:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class MyCustomType extends Model
{
protected $table = 'my_custom_type_table';
public function entities(): BelongsToMany
{
return $this->belongsToMany(MyEntity::class, 'my_entity_type_table', 'type_id', 'entity_id');
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class MyEntity extends Model
{
protected $table = 'my_entity_table';
public function types(): BelongsToMany
{
return $this->belongsToMany(MyCustomType::class, 'my_entity_type_table', 'entity_id', 'type_id');
}
}
and in Laravel Nova I have this configuration within MyEntityto add tags:
<?php
namespace App\Nova\Models;
use App\Nova\Resource;
use Laravel\Nova\Fields\Tag;
class MyEntity extends Resource
{
public function fields(NovaRequest $request)
{
return [
Tag::make('MyCustomType', 'types'),
];
}
this results in this error message:
Call to a member function map() on null
The Nova documentation states only "The Tag field allows you to search and attach BelongsToMany relationships using a tag selection interface.", and is silent about further configuration ... so I assumed that my config above is sufficient. But it's not.
Do you have a tip for me?
One addition/edit:
When using the BelongsToMany-Type of Nova, everything is working:
BelongsToMany::make('MyCustomType', 'types', \App\Nova\Models\MyCustomType::class),
Please or to participate in this conversation.