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

kieferjs's avatar

Nova Pivot Date fields not Displaying in Index

I updated to 3.30 Nova and noticed my implementation of a BelongsToMany is not properly displaying the date values in the index or edit mode. Hoping someone can point me in the right direction -- tried methods in the internet to resolve it.

Test Model File:

protected $dates = [
    'created_at',
    'updated_at',
    'due_date'

// 'test_user.invited_date' => 'datetime' ];

protected $casts = ['other_question_types' => 'boolean',
    'due_date' => 'date',

// 'test_user.invited_date' => 'date:Y-m-d' ];

public function user()
{
    return $this->belongsToMany(User::class,'test_user')->using(TestUser::class);
}

User Model File: protected $casts = [ 'email_verified_at' => 'datetime', // 'test_user.invited_date' => 'date:Y-m-d' ];

public function tests()
{
    return $this->belongsToMany(Test::class,'test_user')->withPivot(['invited_date']);
}

Test NOVA Resource: public function fields(Request $request) { return [ ID::make(__('ID'), 'id')->sortable(), BelongsToMany::make('User')->fields(new TestUserFields()), BelongsTo::make('Category')->rules('required')->withoutTrashed(), Text::make('Name'), Text::make('Description')->hideFromIndex(), Date::make('Due Date','due_date')->sortable(), Boolean::make('Other Question Types'),

    ];
}

User Nova Resource: BelongsToMany::make('Tests')->fields(new TestUserFields())

TestUsersFields Class:

public function __invoke()
{
    return [
        Date::make('Invited Date')->displayUsing(function(){
                return isset($this->pivot) ? \Carbon\Carbon::parse($this->pivot->invited_date)->format('M d, Y') : NULL;
            }),
        Date::make('Completed Date')->displayUsing(function(){
            return isset($this->pivot) ? \Carbon\Carbon::parse($this->pivot->completed_date)->format('M d, Y'): NULL;
        }),
    ];
}
0 likes
1 reply
kieferjs's avatar

Both date columns are there on the index, but it is null on the form and also in the Edit Mode form. It does not pull properly from the database column which has this definition..

        $table->date('invited_date');
        $table->date('completed_date')->nullable();

The commented out code in the initial post does not make it work when uncommented.

Please or to participate in this conversation.