PHP code example of chargefield / laravel-widget

1. Go to this page and download the library: Download chargefield/laravel-widget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chargefield / laravel-widget example snippets


@widget('ExampleWidget')

@widget('ExampleWidget', ['four' => 'Four'])

namespace App\Http\Widgets;

use Chargefield\LaravelWidget\BaseWidget;

class ExampleWidget extends BaseWidget
{
    public $title = 'Hello World';

    public function numbers()
    {
        return [
            'One', 'Two', 'Three', $this->four,
        ];
    }
}
bash
php artisan make:widget ExampleWidget
bash
php artisan widget:make ExampleWidget