PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 4, 2022

[FIXED] Laravel Nova - Modify/Remove Actions Log UI Section

 February 04, 2022     laravel, laravel-nova     No comments   

Issue

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.



Answered By - Martijn Imhoff
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing