skip to Main Content

I have a table function in a custom Filament page:

I have initialized the page like this:


<?php

namespace AppFilamentAppResourcesOIPRequestResourcePages;

use AppFilamentAppResourcesOIPRequestResource;
use FilamentResourcesPagesPage;
use FilamentTablesContractsHasTable;
use FilamentFormsContractsHasForms;
use FilamentTablesTable;
use IlluminateDatabaseEloquentBuilder;
use AppModelsOIPRequest;
use FilamentTablesFiltersSelectFilter;
use FilamentTablesFiltersFilter;
use FilamentResourcesPagesListRecordsTab;
use FilamentTablesColumnsTextColumn;
use FilamentTablesColumnsIconColumn;
use FilamentTablesConcernsInteractsWithTable;
use CarbonCarbon;
use FilamentFormsComponentsSelect;
use FilamentFormsConcernsInteractsWithForms;
use FilamentResourcesConcernsHasTabs;
use IlluminateSupportFacadesDB;
use IlluminateSupportCollection;
use FilamentTablesActionsAction;
use FilamentActionsConcernsInteractsWithActions;
use FilamentActionsContractsHasActions;
use IlluminateDatabaseEloquentModel;
use FilamentTablesActionsActionGroup;

class IncentiveOverview extends Page implements HasTable, HasForms, HasActions
{
    use InteractsWithTable;
    use InteractsWithForms;
    use InteractsWithActions;
    use HasTabs;
    
    //...

And my table like below:

public function table(Table $table): Table
    {
        return $table
        ->query(function (): Builder {
                return $this->getIncentiveRequests()->groupBy(['branch_id', 'department_id']);
            })
            ->modifyQueryUsing($this->modifyQueryWithActiveTab(...))
            ->columns([
                TextColumn::make('department.name')
                    ->label('Department')
                    ->sortable(),
                TextColumn::make('gp')
                    ->label('GP')
                    ->money('eur', true)
                    ->state(function ($record) {
                        return $this->calculateGP($record);
                    })
                    ->sortable(),
            ])
            ->actions([
                Action::make('view_incentive_details')
                    ->label('View Incentive Details')
                    ->action(function ($record) {
                        dd($record);
                    })
                ]);
    }

Then, the blade view is looking like this:

<x-filament::page>
    <div class="flex flex-col gap-4">
        <x-filament-panels::resources.tabs />
        <div class="relative">
            {{ $this->table }}
        </div>
         <x-filament-actions::modals />
    </div>
</x-filament::page>

When I try to trigger the view_incentive_details, I would for now, expect that it would just dd the $record, however, when I click it, a spinner is just shown briefly:

image

2

Answers


  1. oliverbj

    ->please add bellow code to your code :

    use FilamentTablesActionsAction;
    
    • I think you are using wrong import for making action that’s why it’s not working correctly.
    Login or Signup to reply.
  2. First of ALL, clear the cache using this cammand

    php artisan clear:cache
    

    then update the Action section of Table

    ->action(function ($record) {
    Log::info('View Incentive Details', ['record' => $record]);
    Notification::make()
        ->title('Action Triggered')
        ->body('The record has been processed.')
        ->success()
        ->send();
    })
    

    This is Filament’s notification system with Laravel logs.
    after running this code update, check Telescope logs section.

    In case If you don’t use telescope. By default, Laravel stores log files in the storage/logs directory of your project. The default log file is named laravel.log

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search