protonemedia/laravel-splade

how to bulk action in Splade-dataTable?

Adel-Kazem opened this issue · 2 comments

I need help, I tried to implement the codes inside the docs but it's not working..I am using SPLADE data table but I can't figure out how to implement bulk action functionality into multiple of rows with the specific column, for example if I want to translate the column of post description using bulk action and allow instant update?

any idea or clear guidance? thanks.

@pascalbaljet
here's where I'm trying to add the bulk action functionality (as per official docs) but it's failing:

public function index()
    {
        return view('users.index', [
            'users' => SpladeTable::for(User::class)
                ->withGlobalSearch(columns: ['name', 'email'])
                ->column('name', label: 'User Name', canBeHidden: false, sortable: true, searchable: true)
                ->column('email', sortable: true, searchable: true)
                ->column('country_code', label: 'Country')
                ->column(label: 'Actions')
                ->selectFilter('country_code', [
                    'HK' => 'HK only',
                    'nl' => 'Dutch',
                ])->bulkAction('Test action', function (User $user) {
                    info('Bulk action test');
                })
                ->paginate(5)
        ]);
    }

and the error that I get is this get_class(): Argument #1 ($object) must be of type object, null given

I was able to resolve it through the official docs. I wasn't knowing that I should create a dedicated class for the data table, for future reference for anyone who might search for this this is the page (under Table Class): link

And by the way this package is really awesome!