Marshmallow/nova-resource-click

This Laravel Nova package package allows you to define the click action on a Nova resource's index row.

Downloads

463

Stars

2

Version

v1.0.0

Nova Sortable

Latest Version on Packagist Total Downloads

This Laravel Nova package allows you to define the click action on a Nova resource's index row.

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0

Features

  • Define the action of the click on the index page of the Resource Table row

Screenshots

ResourceClick

Installation

Install the package in a Laravel Nova project via Composer:

# Install package
composer require marshmallow/nova-resource-click

Config

Publish the config file with

php artisan vendor:publish --provider="Marshmallow\NovaResourceClick\ToolServiceProvider" --tag="config"

This is the default content of the config file:


  return [

      /**
       * Default action for all resources when click is applied;
       */
      'default' => 'view',
  ];

Usage

When the resource does not have a click action configuratored, the default action will be used: 'view' .

Note: This package extends the default TableResourceRow component from Laravel Nova. Any other package that overwrites this component may cause this package to break.

Add the row click action to Nova resource

To apply the 'clickAction' on the individual Resource by adding the HasClickAction trait and adding the $clickAction variable.


use Marshmallow\NovaResourceClick\Traits\HasClickAction;

class MyResource extends Resource
{
  use HasClickAction;

  public static $clickAction = 'update';  // Options: view, update, select, ignore

  ...
}

Or by using use the additionalInformation feature:


class MyResource extends Resource
{

  /**
   * Get meta information about this resource for client side consumption.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return array<string, mixed>
   */
  public static function additionalInformation(Request $request)
  {
    return [
        'clickAction' => 'update' // Options: view, update, select, ignore
    ];
  }

  ...
}

Credits

License

Nova Resource Click is open-sourced software licensed under the MIT license.

marshmallow-packages

Author

marshmallow-packages