{"id":13563474,"url":"https://github.com/dillingham/nova-button","last_synced_at":"2025-05-16T06:06:21.792Z","repository":{"id":33964736,"uuid":"164187522","full_name":"dillingham/nova-button","owner":"dillingham","description":"Add buttons on Nova index, detail and lens views.","archived":false,"fork":false,"pushed_at":"2023-12-20T05:11:49.000Z","size":1170,"stargazers_count":265,"open_issues_count":34,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T16:03:01.604Z","etag":null,"topics":["laravel","laravel-nova","laravel-nova-field"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dillingham.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-05T06:10:42.000Z","updated_at":"2024-05-21T08:05:58.000Z","dependencies_parsed_at":"2024-01-14T03:46:46.727Z","dependency_job_id":"12f91e81-1a3b-44e8-9c86-aa4c6c81264d","html_url":"https://github.com/dillingham/nova-button","commit_stats":{"total_commits":179,"total_committers":13,"mean_commits":13.76923076923077,"dds":"0.16759776536312854","last_synced_commit":"b1b4ab0376ce90f341ec259c0bd53b43cc1096fa"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Fnova-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dillingham","download_url":"https://codeload.github.com/dillingham/nova-button/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253650897,"owners_count":21942226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-nova","laravel-nova-field"],"created_at":"2024-08-01T13:01:19.661Z","updated_at":"2025-05-16T06:06:16.781Z","avatar_url":"https://github.com/dillingham.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"## Nova Button\n\nThanks for everyone who used this package and contributed. \n\nI haven't used Nova in many years so I'm unable to maintain this.\n\nI'm so glad to see active forks though!\n\n- https://github.com/dnwjn/nova-button\n- https://github.com/sietse85/nova-button\n\n---\n\n[![Latest Version on Github](https://img.shields.io/github/release/dillingham/nova-button.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-button)\n[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-button.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-button) [![Twitter Follow](https://img.shields.io/twitter/follow/sir_brian_d?color=%231da1f1\u0026label=Twitter\u0026logo=%231da1f1\u0026logoColor=%231da1f1\u0026style=flat-square)](https://twitter.com/sir_brian_d)\n\nNova package for rendering buttons on index, detail and lens views.\n\nUse buttons to trigger backend events, navigate nova routes or visit links.\n\n![nova-button](https://user-images.githubusercontent.com/29180903/50742708-dffeb600-11dc-11e9-9eed-36f42166c7c4.png)\n\n### Installation\n\n```bash\ncomposer require dillingham/nova-button\n```\n\n### Usage\n\n```php\nuse NovaButton\\Button;\n```\n```php\npublic function fields(Request $request)\n{\n    return [\n        ID::make('ID', 'id')-\u003esortable(),\n        Text::make('Name', 'name'),\n        Button::make('Notify'),\n    ];\n}\n```\n\nQuick links: [Button Styles](https://github.com/dillingham/nova-button#button-styles) | [Event text / style](https://github.com/dillingham/nova-button#button-state) | [Navigation](https://github.com/dillingham/nova-button#button-navigation) | [CSS classes](https://github.com/dillingham/nova-button#button-classes) | [Lens example](https://github.com/dillingham/nova-button#example)\n\n---\n\n### Backend events\n\nBy default, clicking the button will trigger a backend event via ajax.\n\nDefault event: `NovaButton\\Events\\ButtonClick`\n\nThe event will receive the resource model it was triggered from \u0026 the key\n\n- `$event-\u003eresource` = `model`\n- `$event-\u003ekey` = `\"notify\"`\n\nAdding a custom key\n\n```php\nButton::make('Notify', 'notify-some-user')\n```\nAdding a custom event\n```php\nButton::make('Notify')-\u003eevent('App\\Events\\NotifyRequested')\n```\n\nYou register listeners in your EventServiceProvider\n\n### Nova Routes\n\nYou can also choose to navigate any of the Nova routes\n\n```php\nButton::make('Text')-\u003eroute('vuejs-route-name', ['id' =\u003e 1])\nButton::make('Text')-\u003eindex('App\\Nova\\User')\nButton::make('Text')-\u003edetail('App\\Nova\\User', $this-\u003euser_id)\nButton::make('Text')-\u003ecreate('App\\Nova\\User')\nButton::make('Text')-\u003eedit('App\\Nova\\User', $this-\u003euser_id)\nButton::make('Text')-\u003elens('App\\Nova\\User', 'users-without-confirmation')\n```\nYou can also enable a resource's filters \n```php\nButton::make('Text')-\u003eindex('App\\Nova\\Order')-\u003ewithFilters([\n    'App\\Nova\\Filters\\UserOrders' =\u003e $this-\u003euser_id,\n    'App\\Nova\\Filters\\OrderStatus' =\u003e 'active',\n])\n```\n\n### Links\n```php\nButton::make('Text')-\u003elink('https://nova.laravel.com')\nButton::make('Text')-\u003elink('https://nova.laravel.com', '_self')\n```\n\n### Visiblity\n\nYou will likely want to show or hide buttons depending on model values\n```php\nButton::make('Activate')-\u003evisible($this-\u003eis_active == false),\nButton::make('Deactivate')-\u003evisible($this-\u003eis_active == true),\n```\n\nAlso [field authorization](https://nova.laravel.com/docs/1.0/resources/authorization.html#fields) via canSee() \u0026 [showing / hiding fields](https://nova.laravel.com/docs/1.0/resources/fields.html#showing-hiding-fields) hideFromIndex(), etc\n\n### Reload\nAfter events are triggered, reload the page. \n\n```php\nButton::make('Notify')-\u003ereload()\n```\nIf you click many buttons, reloading will wait for all buttons to finish.\n\nIf an error occurs, it will not reload the page.\n\n\n### Confirm\nYou can require a confirmation for descructive actions\n\n```php\nButton::make('Cancel Account')-\u003econfirm('Are you sure?'),\nButton::make('Cancel Account')-\u003econfirm('title', 'content'),\n```\n\n### Button state\nWhen using events, you want visual feedback for the end user.\n\nThis is especially useful for long running listeners.\n\n```php\nButton::make('Remind User')-\u003eloadingText('Sending..')-\u003esuccessText('Sent!')\n```\n\n| Event | Text | Style |\n| -- | -- | -- |\n| loading | `loadingText('Loading..')` | `loadingStyle('grey-outline')` |\n| success | `successText('Done!')` | `successStyle('success')` |\n| error | `errorText('Failed')` | `errorStyle('danger')` |\n\nDefaults defined in the `nova-button` config. Add methods when you want to change for specific resources\n\n\n### Button styles\n\nThis package makes use of [tailwind-css](https://tailwindcss.com) classes / default: `link`\n\n```php\nButton::make('Confirm')-\u003estyle('primary')\n```\n\n| Fill  | Outline | Link |\n|---|---|---|\n| primary | primary-outline | primary-link |\n| success | success-outline | success-link |\n| danger | danger-outline | danger-link |\n| warning | warning-outline | warning-link |\n| info | info-outline | info-link |\n| grey | grey-outline | grey-link |\n\nEach key adds classes from the `nova-button` config\n```php\n'primary' =\u003e 'btn btn-default btn-primary'\n```\n\n### Style config\nPublish the nova-button config to add / edit [available styles \u0026 defaults](https://github.com/dillingham/nova-button/blob/master/config/nova-button.php) \n```\nphp artisan vendor:publish --tag=nova-button -- force\n```\n\n### Button classes\n\nYou can also add classes manually\n\n```php\nButton::make('Refund')-\u003eclasses('some-class')\n```\nAlso able to style the following css classes\n\n```css\n.nova-button\n.nova-button-{resource-name}\n.nova-button-success\n.nova-button-error\n.nova-button-loading\n```\n\n---\n\n# Example\n\nUse [lenses](https://nova.laravel.com/docs/1.0/lenses/defining-lenses.html) with buttons for a very focused user experience \n\n![lens-button](https://user-images.githubusercontent.com/29180903/50742642-31f30c00-11dc-11e9-96c2-e0534e963aed.png)\n\n```php\n\u003c?php\n\nnamespace App\\Nova\\Lenses;\n\nclass UsersWithoutConfirmation extends Lens\n{\n    public static function query(LensRequest $request, $query)\n    {\n        return $query\n            -\u003eselect(['users.id', 'users.name'])\n            -\u003ewhereNull('email_verified_at');\n    }\n\n    public function fields(Request $request)\n    {\n        return [\n            ID::make('ID', 'id'),\n            Text::make('Name', 'name'),\n            Button::make('Mark As Confirmed'),\n        ];\n    }\n}\n```\nRegister a listener for `\\NovaButton\\Events\\ButtonClick` in your [EventServiceProvider](https://laravel.com/docs/5.7/events)\n```php\n\u003c?php\n\nnamespace App\\Listeners;\n\nclass ConfirmUser\n{\n    public function handle($event)\n    {\n        if ($event-\u003ekey == 'mark-as-confirmed') {\n            $event-\u003eresource-\u003eemail_verified_at = now();\n            $event-\u003eresource-\u003esave();\n        }\n    }\n}\n```\nNo `key` check required when you register an event for this listener\n\n```php\nButton::make('Confirm')-\u003eevent('App\\Events\\ConfirmClick')\n```\n\n# Telescope inspection\n\n![event-triggered](https://user-images.githubusercontent.com/29180903/50742633-1a1b8800-11dc-11e9-8a2d-5ec70d3fcae4.png)\n\n---\n\n# Author\n\nHi 👋, Im Brian Dillingham, creator of this Nova package [and others](https://novapackages.com/collaborators/dillingham)\n\nHope you find it useful. Feel free to reach out with feedback.\n\nFollow me on twitter: [@sir_brian_d](https://twitter.com/sir_brian_d) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdillingham%2Fnova-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Fnova-button/lists"}