Search code examples
laravellaravel-nova

Laravel Nova - Modify/Remove Actions Log UI Section


I want to remove the default action log UI section below a model's details.

If I remove the "Actionable" trait, then the action log is completely unavailable, including the tabbed pane.

So, I tried making a new class extending the ActionResource class to handle the UI, but I cannot find an interface that controls the UI section. What class/traits/interfaces control the Action log, and how can I hide it from view?

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Actions\ActionResource;


class BetterActionResource extends ActionResource
{
    public static $polling = false;

    public static $showPollingToggle = true;

    /**
     * Get the displayable label of the resource.
     *
     * @return string
     */
    public static function label()
    {
        return __('History');
    }

    /**
     * Get the displayable singular label of the resource.
     *
     * @return string
     */
    public static function singularLabel()
    {
        return __('Event');
    }
}

How can I hide the action log while using an Actionable model?

Here is a screenshot to better describe the outcome I am going for. enter image description here


Solution

  • Yes you can.

    Add this to your resource class:

    class User extends Resource
    {
    
        /**
         * Determine if the resource should have an Action field.
         *
         * @param \Laravel\Nova\Http\Requests\NovaRequest $request
         * @return bool
         */
        protected function shouldAddActionsField($request)
        {
            return false;
        }
    }
    

    It overwrites the shouldAddActionsField method from the Laravel\Nova\ResolvesFields which is added via the parent model (Laravel\Nova\Resource). This method determines whether the action field is shown by returning a bool.

    In the background, actions_events will still be stored in the database and you should be able to access those. I'm not sure how you are accessing them, but I think this should not interfere with that.