Yes, you can add a standalone button next to the create button in a resource. Here's how you can do it:
-
Open the resource file for the model you want to add the button to. For example, if you want to add the button to the User resource, open the file
app/Nova/User.php. -
In the
fieldsmethod of the resource file, add a new field for the button. You can use theHTMLfield to create a custom HTML element for the button. Here's an example:
use Laravel\Nova\Fields\HTML;
...
public function fields(Request $request)
{
return [
// Your other fields here
HTML::make('Button')->html('<a href="/path/to/other/page" class="btn btn-primary">Go to Other Page</a>'),
];
}
-
Customize the HTML code for the button as needed. In the example above, the button will redirect to
/path/to/other/pagewhen clicked. -
Save the resource file and refresh the Nova page to see the new button next to the create button.
Note: You can also use the Button field instead of the HTML field to create a button, but it requires more configuration. Here's an example:
use Laravel\Nova\Fields\Button;
...
public function fields(Request $request)
{
return [
// Your other fields here
Button::make('Go to Other Page')->link('/path/to/other/page')->style('primary'),
];
}
This will create a button with the label "Go to Other Page" that will redirect to /path/to/other/page when clicked. The style method sets the button color to blue.