Voyager 2
2.x
2.x
  • Introduction
  • Javascript
  • Media Manager
  • Plugins
  • Settings
  • bread
    • Actions
    • BREAD Builder
    • Layouts
    • Lists
    • Manipulate data
    • Multilanguage
    • Relationships
    • Validation
    • Views
  • contributing
    • Assets
    • CSS
    • Introduction
  • de
    • index
  • formfields
    • Checkboxes
    • Date & Time
    • Dynamic input
    • Formfields
    • Media Picker
    • Number
    • Password
    • Radios
    • Relationship
    • Repeater
    • Select
    • Simple array
    • Slider
    • Slug
    • Tags
    • Text
    • Toggle
  • getting-started
    • Installation
    • Prerequisites
    • Tips and tricks
    • What is Voyager
  • overriding
    • Overriding formfields
    • Icons
  • plugins
    • Assets
    • Components
    • Features
    • Filter
    • Plugin development
    • Language
    • Menu Items
    • Custom pages
    • Preferences
    • Routes
    • Settings
    • Widgets
Powered by GitBook
On this page

Was this helpful?

  1. plugins

Widgets

You can inject widgets which can be shown on the dashboard by simply implementing the Widgets provider and adding a method provideWidgets to your plugin like this:

<?php

namespace Me\MyPlugin;

use Voyager\Admin\Classes\Widget;
use Voyager\Admin\Contracts\Plugins\GenericPlugin;
use Voyager\Admin\Contracts\Plugins\Features\Provider\Widgets;

class MyPlugin implements GenericPlugin, Widgets
{
    public function provideWidgets(): Collection {
        return collect([
            (new Widget('component-name', 'title'))->icon('academic-cap')
        ]);
    }
}

Available methods

Method

Description

Example

Arguments

__construct

Creates a new Widget

new Widget('component-name', 'My title');

string component: the name of the component, string title: The title

width

Sets the width of the widget

->width(6)

int width: The width between 3 and 12

icon

An icon show next to the title

->icon('academic-cap')

string icon: The name of the icon

parameters

Parameters passed to the component

->parameters(['key' => 'value'])

array parameters: The parameters

permission

Display/Hide the widget based on a permission

->permission('name_of_permission')

string permission: The key of a permission, array args: Additional arguments

PreviousSettings

Last updated 3 years ago

Was this helpful?