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

Amfetaminf's avatar

Filament Jobs Database notification error.

Hi. I have an error when i try to add some Filament database notification from Job. Code from Job:

 <?php

namespace App\Jobs;

use App\Filament\Resources\VideosResource;
use App\Models\User;
use App\Services\VideoService;
use Exception;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;

class ImportVideoDataJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $video;

    /**
     * Create a new job instance.
     */
    public function __construct($video)
    {
        $this->video = $video;
    }

    /**
     * Execute the job.
     * @throws Exception
     */
    public function handle(): void
    {
        //$user = User::where('id', $this->video->admin)->firstOrFail();
        $user = User::find($this->video->admin);
        Notification::make()
            ->title('Some text')
            ->danger()
            ->actions([
                Action::make('Edit')
                    ->url(VideosResource::getUrl('edit', ['record' => $this->video])),
            ])
            ->sendToDatabase($user);
}
}

Job dispatched in Filament resource / CreateVideos Code:

protected function mutateFormDataBeforeCreate(array $data): array
    {
        $data['admin'] = auth()->user()->id;

        return $data;
    }

    protected function afterCreate()
    {
        Notification::make()
            ->title('importing...Or something text.')
            ->success()
            ->send();

        ImportVideoDataJob::dispatch($this->getRecord());
    }

After run job it`s not show me notification because job was failed. Error in failed jobs and laravel.log:

[2023-10-12 20:08:30] local.ERROR: Filament\Notifications\Notification::Filament\Notifications\{closure}(): Argument #1 ($action) must be of type Filament\Notifications\Actions\Action|Filament\Notifications\Actions\ActionGroup, Filament\Actions\Action given {"exception":"[object] (TypeError(code: 0): Filament\Notifications\Notification::Filament\Notifications\{closure}(): Argument #1 ($action) must be of type Filament\Notifications\Actions\Action|Filament\Notifications\Actions\ActionGroup, Filament\Actions\Action given at E:\OSPanel\domains\project.loc\vendor\filament\notifications\src\Notification.php:73)
[stacktrace]

What i doing wrong? Sorry for bad English.

0 likes
1 reply
Amfetaminf's avatar

It`s my mistake. Sorry. I just needed to rerun the php artisan queue:work command

Please or to participate in this conversation.