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

dipherent's avatar

Please help: Boolean Status Change is not working from Index

Dear friends, I really need some urgent help with this:

I am trying to be able to change the Status of a resource from true to false (Boolean) from the index page in nova (without having to go into the resource page).

I used a package - nova-toggle - It works perfectly on my local computer but when I deploy, the feature of the toggle from index does not work. It gives a 404 error.

I thought this has to do with the package, but I tried another package that does the same thing in a different way and I faced the same problem. So, I thought this has to do with Nova or my server rather than with the packages.

Anyone has any tips on how to fix this?

Thanks a lot,

0 likes
3 replies
dipherent's avatar

Or if you kindly can give me another solution or package to be able to change the status of a boolean from the index... like inline editing

Thanks

scadh's avatar
scadh
Best Answer
Level 1

No 3rd party package is required for this. A better solution is to create a Nova Action. This allows you to run the action against one or multiple resource instances concurrently (including all of them you have, even if the number exceeds the pagination value). The docs are here (https://nova.laravel.com/docs/3.0/actions/defining-actions.html). An example action that sets an 'active' boolean (substitute your model property as needed):

class SetActiveStatus extends Action
{
    use InteractsWithQueue, Queueable;

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
        $value = $fields->status;

        foreach($models as $model)
        {
            $model->update([
                'active' => $value
            ]);
        }

        return Action::message('The selected items have been made ' . $value == 1 ? 'active' : 'inactive' . '.');
    }

    /**
     * Get the fields available on the action.
     *
     * @return array
     */
    public function fields()
    {
        return [
            Select::make('Status')
                ->options([
                    1 => 'Active',
                    0 => 'Inactive'
                ])
                ->rules(
                    'required'
                )
        ];
    }
}

The register your action in any Nova resources that you wish (optionally use canSee() to determine which users can run the action):

public function actions(Request $request)
    {
        return [
            (new SetActiveStatus)->canSee(function ($request) {
                return $request->user()->can('Set Active Status');
            })
        ];
    }
dipherent's avatar

Dear @scadh

Thanks a lot for your kind help. I have actually implemented an action last night and seemed OK but was not as efficient as I needed it to be. I will look into your code and add it as a second option for my users.

I was able to solve the problem with the package by removing some text.. I still don't understand why this was the problem, but here is what I did:

In my Nova resource

Before:

Toggle::make(__('Invoice Paid'),'invoice_paid')->editableIndex(),

After:

Toggle::make('invoice_paid')->editableIndex(),

By the way, the package is awesome and make things fast. I was a bit frustrated that It didn't work, but now it is doing what I need.

Do you have any clues why removing the column name from make() solved the issue?

Thanks again for your follow up, highly appreciated.

Please or to participate in this conversation.