Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LancyBark's avatar

Call to a member function map() on null on spatie tags field

I get ```call to a member function map() on null`` when i use this spatie tag field package. I'm using Laravel 7.x version and Nova 3.x. Is neccessary to create table for tags?

namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Benjacho\BelongsToManyField\BelongsToManyField;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Date;
use Spatie\TagsField\Tags;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;

  public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            BelongsTo::make('Brand', 'brand', 'App\Nova\Brand'),
            Text::make('Name', 'name')->rules('required'),

            Textarea::make('Statement', 'statement')->rules('required'),
	   Tags::make('Search Tags', 'search_tags');

	    Number::make('Priority', 'priority')->min(1)->max(10)->rules('required'),
            Select::make('Time frame', 'time_frame')->options([
                'Next Month' => 'Next Month',
                'Next 3 Months' => 'Next 3 Months',
                'Next 6 Months' => 'Next 6 Months',
                'Next 12 Months' => 'Next 12 Months',
            ])->rules('required'),
            Select::make('Successive meassure', 'success_measure')->options([
                'New Unique Visitors' => 'New Unique Visitors',
                'Beverages Sold' => 'Beverages Sold',
                'New Unique Customers' => 'New Unique Customers',
            ])->rules('required'),
            BelongsToManyField::make('Objective Owner', 'users', 'App\Nova\User')->relationModel(\App\Objectives::class)->rules('required'),
            Date::make('Review date', 'review_date')->rules('required'),
            Select::make('Status', 'status')->options([
                'Proposed' => 'Proposed',
                'Active' => 'Active',
                'Achieved' => 'Achieved'
            ])->rules('required'),
0 likes
2 replies
LancyBark's avatar

But if I use tags field for more than one table, must I defined relationship beetwen them in general? Edit: Everything works alright but I can't preview all records I get Argument 1 passed to Spatie\TagsField\Tags::Spatie\TagsField\{closure}() must be an instance of Spatie\Tags\Tag, instance of App\Tag given Only hideFromIndex, hideFromDetail prevents from this error, but i want to see tags on previewing all records or seperatly.

Please or to participate in this conversation.