├── .gitignore ├── LICENSE.md ├── composer.json ├── config └── widget.php ├── readme.md ├── src └── Widget │ ├── MakeWidget.php │ ├── Widget.php │ ├── WidgetContractInterface.php │ └── WidgetServiceProvider.php ├── stubs └── widget.stub └── tests └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .phpstorm.meta.php 3 | _ide_helper.php 4 | composer.lock 5 | build 6 | vendor 7 | .DS_Store 8 | .lock 9 | node_modules 10 | package-lock.json 11 | public/css/orchid.css.map 12 | public/js/orchid.js.map 13 | public/js/manifest.js.map 14 | public/js/vendor.js.map 15 | tatus 16 | logs -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Orchid 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "orchid/widget", 3 | "description": "Widget for The Laravel Framework", 4 | "type": "library", 5 | "license": "MIT", 6 | "homepage": "https://orchid.software", 7 | "keywords": [ 8 | "laravel", 9 | "view", 10 | "widget", 11 | "menu" 12 | ], 13 | "authors": [ 14 | { 15 | "name": "Alexandr Chernyaev", 16 | "email": "bliz48rus@gmail.com", 17 | "homepage": "https://tabuna.github.io", 18 | "role": "Developer" 19 | } 20 | ], 21 | "require": { 22 | "php": ">=7.1", 23 | "laravel/framework": ">=5.0" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "Orchid\\Widget\\": "src/Widget/" 28 | } 29 | }, 30 | "extra": { 31 | "laravel": { 32 | "providers": [ 33 | "Orchid\\Widget\\WidgetServiceProvider" 34 | ] 35 | } 36 | }, 37 | "minimum-stability": "stable", 38 | "prefer-stable": true 39 | } 40 | -------------------------------------------------------------------------------- /config/widget.php: -------------------------------------------------------------------------------- 1 | [], 16 | ]; 17 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Warning this repository is no longer supported 2 | 3 | ### If you are looking for a good way to use widgets on laravel please see how to use [directive](https://laravel.com/docs/blade#extending-blade). This provides a better experience than package. 4 | 5 | ---- 6 | 7 | 8 | 9 | 10 | # Orchid Widget 11 | 12 | Widgets embedded in the representation to form a complex, but at the same time independent of the user interface. 13 | 14 | ## Installation 15 | 16 | install wia composer 17 | 18 | ```php 19 | composer require orchid/widget 20 | ``` 21 | publish package 22 | 23 | ```php 24 | php artisan vendor:publish 25 | ``` 26 | 27 | ### Create : 28 | 29 | To create a new widget, you need to 30 | ```php 31 | php artisan orchid:widget NameClassWidget 32 | ``` 33 | 34 | In the folder `app/Http/Widgets` create a class widget template 35 | Like a controller, a widget can also have its own view. 36 | Recommended siting widget files in a subdirectory views. 37 | 38 | To register your new widget, you must bring it to the `config/widget.php` 39 | 40 | ```php 41 | // 42 | 'widgets' => [ 43 | 'test' => App\Widgets\NameClassWidget::class 44 | ], 45 | ``` 46 | 47 | ## Usage 48 | 49 | "Run" method is executed when the call widget defaul. 50 | you must perform in the code to connect the widget using Blade syntax: 51 | ```php 52 | @widget('test') 53 | ``` 54 | 55 | ## License 56 | 57 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 58 | -------------------------------------------------------------------------------- /src/Widget/MakeWidget.php: -------------------------------------------------------------------------------- 1 | getWidgetFromConfig($key); 21 | 22 | return $widget->handler($arg); 23 | } 24 | 25 | /** 26 | * @param string $key 27 | * 28 | * @return \Orchid\Widget\Widget 29 | */ 30 | private function getWidgetFromConfig(string $key): self 31 | { 32 | $class = config('widget.widgets.' . $key); 33 | 34 | return new $class; 35 | } 36 | 37 | /** 38 | * Soother. 39 | */ 40 | public function handler() 41 | { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Widget/WidgetContractInterface.php: -------------------------------------------------------------------------------- 1 | publishes([ 22 | __DIR__ . '/../../config/widget.php' => config_path('widget.php'), 23 | ], 'config'); 24 | 25 | 26 | Blade::directive('widget', function ($expression) { 27 | $segments = explode(',', preg_replace("/[\(\)\\\]/", '', $expression)); 28 | 29 | if (!array_key_exists(1, $segments)) { 30 | return 'get(' . $segments[0] . '); ?>'; 31 | } 32 | 33 | return 'get(' . $segments[0] . ',' . $segments[1] . '); ?>'; 34 | }); 35 | } 36 | 37 | /** 38 | * Register the commands. 39 | */ 40 | public function register() 41 | { 42 | if (!$this->app->runningInConsole()) { 43 | return; 44 | } 45 | 46 | $this->commands(MakeWidget::class); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /stubs/widget.stub: -------------------------------------------------------------------------------- 1 |