# Button
This class allows you to generate a button.
Example:
Button::add()
->route('boilerplate.users.edit', $user->id)
->icon('pencil-alt')
->color('primary')
->make();
method | description |
---|---|
add | Creates a new button |
icon | Adds a FontAwesome icon to the button |
color | Sets the button color |
class | Sets additional class |
route | Sets the button link href by using a route |
link | Sets the button link href |
attributes | Sets HTML attributes to the button |
make | Renders the button |
# add
Creates a new button.
Button::add()
You can specify a label:
Button::add('Edit')
# icon
Adds a FontAwesome icon to the button:
Available icons: https://fontawesome.com/v5.15/icons (opens new window)
You only have to specify the name of the icon:
->icon('edit')
For other styles than fas
, specify last letter of the class:
->icon('calendar', 'r')
# color
Sets the button color.
Available colors: https://getbootstrap.com/docs/4.0/utilities/colors/ (opens new window)
Only bootstrap4 colors are supported.
->color('primary')
# class
Sets additional class.
->class('mr-1 text-sm')
# route
Sets the button link href by using a route.
->route('boilerplate.users.edit', $user->id)
# link
Sets the button link href.
->link(route('boilerplate.users.edit', $user->id))
# attributes
Sets HTML attributes.
->attributes(['data-action' => 'delete'])
# make
Renders the button.
->make()
# Button aliases
Button::show('route.to.resource.show', $resource);
Button::edit('route.to.resource.edit', $resource);
Button::delete('route.to.resource.destroy', $resource);
Button::delete
will show a modal to confirm the deletion. You can set another confirmation message by using theDatatable::locale()
method.