{"id":22447101,"url":"https://github.com/imajkumar/laravel-themes-creator","last_synced_at":"2025-03-27T11:25:59.945Z","repository":{"id":62490603,"uuid":"265481654","full_name":"imajkumar/laravel-themes-creator","owner":"imajkumar","description":"laravel theme and assest management","archived":false,"fork":false,"pushed_at":"2020-05-22T06:09:12.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T16:09:32.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imajkumar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-20T07:12:02.000Z","updated_at":"2020-05-22T06:09:14.000Z","dependencies_parsed_at":"2022-11-02T11:03:11.846Z","dependency_job_id":null,"html_url":"https://github.com/imajkumar/laravel-themes-creator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Flaravel-themes-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Flaravel-themes-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Flaravel-themes-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Flaravel-themes-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imajkumar","download_url":"https://codeload.github.com/imajkumar/laravel-themes-creator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245834556,"owners_count":20680027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T04:14:24.350Z","updated_at":"2025-03-27T11:25:59.918Z","avatar_url":"https://github.com/imajkumar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Theme Management for Laravel\n\nLaravel-Theme is a theme management for Laravel 7.x+, it is the easiest way to organize your skins, layouts and assets.\n\nThis package is based on [teepluss\\theme](https://github.com/teepluss/laravel-theme/)\n\n\u003e##### Differences with teepluss version:\n\u003e- Compatible with laravel 5.4+.\n\u003e- Removed twig compatibility (Reduces the package by 94%).\n\u003e- Blade directives\n\u003e- Better base template.\n\u003e- Simplified configuration.\n\u003e- More commands and helper functions.\n\u003e- Better README file.\n\u003e- Manifest file (Get and set theme info)\n\u003e- Middleware to define theme and layout\n\n## Usage\n\nTheme has many features to help you get started with Laravel\n\n- [Installation](#installation)\n- [Create new theme](#create-new-theme)\n- [Basic usage](#basic-usage)\n- [Configuration](#configuration)\n- [Basic usage of assets](#basic-usage-of-assets)\n- [Partials](#partials)\n- [Magic methods](#magic-methods)\n- [Preparing data to view](#preparing-data-to-view)\n- [Breadcrumb](#breadcrumb)\n- [Widgets](#widgets)\n- [Using theme global](#using-theme-global)\n- [Middleware](#middleware)\n- [Helpers](#helpers)\n- [Cheatsheet](#cheatsheet)\n\n\n## Installation\n\nTo get the latest version of laravel-themes simply require it in your `composer.json` file.\n\n~~~json\n\"composer require ayra/laravel-themes-creator\"\n~~~\n\nYou'll then need to run `composer install` to download it and have the autoloader updated.\n\nOnce Theme is installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.\n\n~~~php\n'providers' =\u003e [\n\t...\n\tAyra\\Theme\\ThemeServiceProvider::class,\n\n]\n~~~\n\nTheme also ships with a facade which provides the static syntax for creating collections. You can register the facade in the `aliases` key of your `config/app.php` file.\n\n~~~php\n'aliases' =\u003e [\n\t...\n\t'Theme' =\u003e Ayra\\Theme\\Facades\\Theme::class,\n\n]\n~~~\nPublish config using artisan CLI.\n\n~~~\nphp artisan vendor:publish --provider=\"Ayra\\Theme\\ThemeServiceProvider\"\n~~~\n\nIt's recommended to add to the `.env` file the theme that we are going to use\n~~~\nAPP_THEME=default\n~~~\n\n\n\n## Create new theme\n\nThe first time you have to create theme \"default\" structure, using the artisan command:\n\n~~~\nphp artisan theme:create default\n~~~\n\u003e If you change the facade name you can add an option --facade=\"Alias\".\n\n\nThis will create the following directory structure:\n\n```\n├── public/\n    └── themes/\n\t└── default/\n\t\t├── assets\n        \t|\t├── css/\n\t\t|\t├── img/\n            \t|\t└── js/\n            \t├── layouts/\n            \t├── partials/\n           \t|\t└── sections/\n            \t├── views/\n\t        └── widgets/\n```\n\nTo delete an existing theme, use the command:\n\n~~~\nphp artisan theme:destroy default\n~~~\n\nIf you want to list all installed themes use the command:\n\n~~~\nphp artisan theme:list\n~~~\n\nYou can duplicate an existing theme:\n~~~\nphp artisan theme:duplicate name new-theme\n~~~\n\n\n\nCreate from the application without CLI.\n\n~~~php\nArtisan::call('theme:create', ['name' =\u003e 'foo']);\n~~~\n\n## Basic usage\n\nTo display a view from the controller:\n\n~~~php\nnamespace App\\Http\\Controllers;\n\nuse Theme;\n\nclass HomeController extends Controller {\n\n\tpublic function getIndex()\n\t{\n\t\treturn Theme::view('index');\n\t}\n\t...\n}\n~~~\n\u003eThis will use the theme and layout set by default on `.env`\n\n\t\t\nYou can add data or define the theme and layout:\n\n~~~php\n...\t\t\nTheme::uses('themename');\n        \n$data['info'] = 'Hello World'; \n\nreturn Theme::view('index', $data);\n...\n~~~\n\nOr you can do:\n~~~php\n$cookie = Cookie::make('name', 'Tee');\n\nreturn Theme::view([\n\t\t    'view' =\u003e 'index',\n\t\t    'theme' =\u003e 'default',\n\t\t    'layout' =\u003e 'layout',\n\t\t    'statusCode' =\u003e 200,\n\t\t    'cookie'  =\u003e $cookie,\n\t\t    'args' =\u003e $data\n\t\t   ]);\n~~~\n\u003eAll values except `'view'` are optional\n\nTo check whether a theme exists.\n\n~~~php\nTheme::exists('themename');\n~~~\n\nEach theme must come supplied with a manifest file `theme.json` stored at the root of the theme, which defines supplemental details about the theme. \n~~~json\n{\n    \"slug\": \"default\",\n    \"name\": \"Default\",\n    \"author\": \"John Doe\",\n    \"email\": \"johndoe@example.com\",\n    \"description\": \"This is an example theme.\",\n    \"web\": \"www.example.com\",\n    \"license\": \"MIT\",\n    \"version\": \"1.0\"\n}\n~~~\n\nThe manifest file can store any property that you'd like. These values can be retrieved and even set through a couple helper methods:\n\n~~~php\n// Get all: (array)\nTheme::info(); \n// Get:\nTheme::info(\"property\"); \n// Set:\nTheme::info(\"property\", \"new data\"); \n~~~\n\n#### Other ways to display a view:\n~~~php\n$theme = Theme::uses('default')-\u003elayout('mobile');\n\n$data = ['info' =\u003e 'Hello World'];\n~~~\n\n~~~php\n// It will look up the path 'resources/views/home/index.php':\nreturn $theme-\u003eof('home.index', $data)-\u003erender();\n~~~\n\n~~~php\n// Specific status code with render:\nreturn $theme-\u003eof('home.index', $data)-\u003erender(200);\n~~~\n\n~~~php\n// It will look up the path 'resources/views/mobile/home/index.php':\nreturn $theme-\u003eofWithLayout('home.index', $data)-\u003erender();\n~~~\n\n~~~php\n// It will look up the path 'public/themes/default/views/home/index.php':\nreturn $theme-\u003escope('home.index', $data)-\u003erender();\n~~~\n\n~~~php\n// It will look up the path 'public/themes/default/views/mobile/home/index.php':\nreturn $theme-\u003escopeWithLayout('home.index', $data)-\u003erender();\n~~~\n\n~~~php\n// Looking for a custom path:\nreturn $theme-\u003eload('app.somewhere.viewfile', $data)-\u003erender();\n~~~\n\n~~~php\n// Working with cookie:\n$cookie = Cookie::make('name', 'Tee');\nreturn $theme-\u003eof('home.index', $data)-\u003ewithCookie($cookie)-\u003erender();\n~~~\n\n~~~php\n// Get only content:\nreturn $theme-\u003eof('home.index')-\u003econtent();\n~~~\n\nFinding from both theme's view and application's view:\n~~~php\n$theme = Theme::uses('default')-\u003elayout('default');\n\nreturn $theme-\u003ewatch('home.index')-\u003erender();\n~~~\n\nTo find the location of a view:\n\n~~~php\n$which = $theme-\u003escope('home.index')-\u003elocation();\n\necho $which; // theme::views.home.index\n\n$which = $theme-\u003escope('home.index')-\u003elocation(true);\n\necho $which; // ./public/themes/name/views/home/index.blade.php\n~~~\n\n#### Render from string:\n\n~~~php\nreturn $theme-\u003estring('\u003ch1\u003e{{ $name }}\u003c/h1\u003e', ['name' =\u003e 'Teepluss'], 'blade')-\u003erender();\n~~~\n\nCompile string:\n\n~~~php\n$template = `\u003ch1\u003eName: {{ $name }}\u003c/h1\u003e\n\t\t     \u003cp\u003e\n\t\t      {{ Theme::widget(\"WidgetIntro\", [\"title\" =\u003e \"Demo Widget\"])-\u003erender() }}\n\t\t     \u003c/p\u003e`;\n\necho Theme::blader($template, ['name' =\u003e 'Teepluss']);\n~~~\n\n#### Symlink from another view\n\nThis is a nice feature when you have multiple files that have the same name, but need to be located as a separate one.\n\n~~~php\n// Theme A : /public/themes/a/views/welcome.blade.php\n// Theme B : /public/themes/b/views/welcome.blade.php\n\n// File welcome.blade.php at Theme B is the same as Theme A, so you can do link below:\n\nTheme::symlink('a'); \n// Location: public/themes/b/views/welcome.blade.php\n~~~\n\n## Configuration\n\nAfter the config is published, you will see a global config file `/config/theme.php`, all the configuration can be replaced by a config file inside a theme: `/public/themes/[theme]/config.php`\n\nThe config is convenient for setting up basic CSS/JS, partial composer, breadcrumb template and also metas.\n\n~~~php\n'events' =\u003e [\n\n\t/* \n\t * Before event inherit from package config and the theme that call\n\t * before, you can use this event to set meta, breadcrumb\n\t * template or anything you want inheriting.\n\t */\n\t'before' =\u003e function($theme)\n\t{\n\t\t// You can remove this lines anytime.\n\t\t$theme-\u003esetTitle('Title Example');\n\t\t$theme-\u003esetAuthor('John Doe');\n\t\t$theme-\u003esetKeywords('Example, Web');\n\t\n\t\t// Breadcrumb template.\n\t\t$theme-\u003ebreadcrumb()-\u003esetTemplate(`        \n\t\t\t \u003cul class=\"breadcrumb\"\u003e\n\t\t\t @foreach($crumbs as $i =\u003e $crumb)\n\t\t\t\t @if($i != (count($crumbs) - 1))\n\t\t\t\t\t\u003cli\u003e\n                    \t\u003ca href=\"{{ $crumb[\"url\"] }}\"\u003e{{ $crumb[\"label\"] }}\u003c/a\u003e\n                        \u003cspan class=\"divider\"\u003e/\u003c/span\u003e\n\t\t\t\t\t\u003c/li\u003e\n\t\t\t\t @else\n\t\t\t\t\t\u003cli class=\"active\"\u003e{{ $crumb[\"label\"] }}\u003c/li\u003e\n\t\t\t\t @endif\n\t\t\t @endforeach\n\t\t\t \u003c/ul\u003e             \n\t\t `);\n\t },\n    \n    /*\n\t * Listen on event before render a theme, this\n\t * event should call to assign some assets.\n\t */\n\t'asset' =\u003e function($asset)\n\t{\n\t\t$asset-\u003ethemePath()-\u003eadd([\n\t\t\t\t\t['style', 'css/style.css'],\n\t\t\t\t\t['script', 'js/script.js']\n\t\t\t\t\t ]);\n\n\t\t// You may use elixir to concat styles and scripts.\n\t\t$asset-\u003ethemePath()-\u003eadd([\n\t\t\t\t\t['styles', 'dist/css/styles.css'],\n\t\t\t\t\t['scripts', 'dist/js/scripts.js']\n\t\t\t\t\t ]);\n\n\t\t// Or you may use this event to set up your assets.\n\t\t$asset-\u003ethemePath()-\u003eadd('core', 'core.js');\t\t\t\n\t\t$asset-\u003eadd([\n\t\t\t['jquery', 'vendor/jquery/jquery.min.js'],\n\t\t\t['jquery-ui', 'vendor/jqueryui/jquery-ui.min.js', ['jquery']]\n\t\t\t ]);\n\t},\n   \n\n\t/*\n\t * Listen on event before render a theme, this event should\n\t * call to assign some partials or breadcrumb template.\n\t */\n\t'beforeRenderTheme' =\u003e function($theme)\n\t{\n\t\t$theme-\u003epartialComposer('header', function($view){\n\t\t\t$view-\u003ewith('auth', Auth::user());\n\t\t});\n\t},\n\n\t/*\n\t * Listen on event before render a layout, this should \n\t * call to assign style, script for a layout.\n\t */\n\t'beforeRenderLayout' =\u003e [\n\t\t'mobile' =\u003e function($theme){\n\t\t\t$theme-\u003easset()-\u003eusePath()-\u003eadd('ipad', 'css/layouts/ipad.css');\n\t\t}\n\t]\n];\n~~~\n\n## Basic usage of assets\n\nYou can add assets on the `asset` method of the config file. If yo want to add assets in your route you can get `$asset` variable from `$theme-\u003easset()`.\n\n~~~php\n$asset-\u003eadd('core-style', 'css/style.css');\n// path: public/css/style.css\n\n$asset-\u003econtainer('footer')-\u003eadd('core-script', 'js/script.js');\n// path: public/js/script.css\n\n$asset-\u003ethemePath()-\u003eadd('custom', 'css/custom.css', ['core-style']);\n// path: public/themes/[current-theme]/assets/css/custom.css\n// This case has dependency with \"core-style\".\n\n$asset-\u003econtainer('footer')-\u003ethemePath()-\u003eadd('custom', 'js/custom.js', array('core-script'));\n// path: public/themes/[current theme]/assets/js/custom.js\n// This case has dependency with \"core-script\".\n~~~\n\u003e You can force use theme to look up existing theme by passing parameter to method: `$asset-\u003ethemePath('default')`\n\nWriting in-line style or script:\n\n~~~php\n// Dependency with.\n$dependencies = [];\n\n// Writing an in-line script.\n$asset-\u003ewriteScript('inline-script', '\n\t$(function() {\n\t\tconsole.log(\"Running\");\n\t})', $dependencies);\n\n// Writing an in-line style.\n$asset-\u003ewriteStyle('inline-style', 'h1{ font-size: 0.9em; }', $dependencies);\n\n// Writing an in-line script, style without tag wrapper.\n$asset-\u003ewriteContent('custom-inline-script', '\n\t\u003cscript\u003e\n\t\t$(function() {\n\t\t\tconsole.log(\"Running\");\n\t\t});\n\t\u003c/script\u003e', $dependencies);\n~~~\n\nRender styles and scripts in your blade layout:\n\n~~~php\n// Without container\n@styles()\n\n// With \"footer\" container\n@scripts('footer')\n\n// Get a specific path from the asset folder\n@asset('img/image.png')\n~~~\n\u003e Scripts and Style can be used with or without container\n\nor a more complex way:\n\n~~~php\n{!! Theme::asset()-\u003estyles() !!}\n\n{!! Theme::asset()-\u003econtainer('footer')-\u003escripts() !!}\n~~~\n\nDirect path to theme asset:\n\n~~~php\n{!! Theme::asset()-\u003eurl('img/image.png') !!}\n~~~\n\n#### Preparing group of assets:\n\nSome assets you don't want to add on a page right now, but you still need them sometimes, so `cook` and `serve` is your magic.\n\nCook your assets.\n~~~php\nTheme::asset()-\u003ecook('backbone', function($asset)\n{\n\t$asset-\u003eadd('backbone', '//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js');\n\t$asset-\u003eadd('underscorejs', '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js');\n});\n~~~\n\nYou can prepare on a global in package config:\n\n~~~php\n// Location: config/theme/config.php\n....\n\t'events' =\u003e array(\n\t\t....\n\t\t// This event will fire as a global you can add any assets you want here.\n\t\t'asset' =\u003e function($asset)\n\t\t{\n\t\t\t// Preparing asset you need to serve after.\n\t\t\t$asset-\u003ecook('backbone', function($asset)\n\t\t\t{\n\t\t\t\t$asset-\u003eadd('backbone', '//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js');\n\t\t\t\t$asset-\u003eadd('underscorejs', '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js');\n\t\t\t});\n\t\t}\n\t)\n....\n~~~\n\nServe theme when you need:\n~~~php\n// At the controller.\nTheme::asset()-\u003eserve('backbone');\n~~~\n\nThen you can get output:\n~~~php\n\u003chtml\u003e\n  \u003chead\u003e\n      @styles()\n      @styles('your-container')\n  \u003c/head\u003e\n  \u003cbody\u003e\n      ...\n      @scripts()\n      @scripts('your-container')\n  \u003c/body\u003e\n\u003chtml\u003e\n~~~\n\n## Partials\n\nRender a partial in your layouts or views:\n~~~php\n@partial('header', ['title' =\u003e 'Header']);\n~~~\n\n\u003e This will look up to `/public/themes/[theme]/partials/header.php`, and will add a variable `$title` (optional)\n\nPartial with current layout specific:\n~~~php\nTheme::partialWithLayout('header', ['title' =\u003e 'Header']);\n~~~\n\u003e This will look up up to `/public/themes/[theme]/partials/[CURRENT_LAYOUT]/header.php`\n\nFinding from both theme's partial and application's partials:\n\n~~~php\nTheme::watchPartial('header', ['title' =\u003e 'Header']);\n~~~\n\n##### Partial composer:\n\n~~~php\n$theme-\u003epartialComposer('header', function($view)\n{\n\t$view-\u003ewith('key', 'value');\n});\n\n// Working with partialWithLayout.\n$theme-\u003epartialComposer('header', function($view)\n{\n\t$view-\u003ewith('key', 'value');\n}, 'layout-name');\n~~~\n\n### Sections\n\nThe `@sections` blade directive simplify the access to `/partials/sections/` path:\n~~~php\n@sections('main')\n~~~\n\nIt's the same as:\n~~~php\n@partial('sections.main')\n~~~\n\n\n## Magic methods\n\nMagic methods allow you to set, prepend and append anything.\n\n~~~php\n$theme-\u003esetTitle('Your title');\n\n$theme-\u003eappendTitle('Your appended title');\n\n$theme-\u003eprependTitle('Hello: ....');\n\n$theme-\u003esetAnything('anything');\n\n$theme-\u003esetFoo('foo');\n\n$theme-\u003eset('foo', 'foo');\n~~~\n\nRender in your blade layout or view:\n\n~~~php\n@get('foo')\n\n@get('foo', 'Default msj')\n\nTheme::getAnything();\n\nTheme::getFoo();\n\nTheme::get('foo', 'Default msj');\n~~~\n\n##### Check if the place exists or not:\n~~~php\n@getIfHas('title')\n~~~\nIt's the same as:\n~~~php\n@if(Theme::has('title'))\n\t{{ Theme::get('title') }}\n@endif\n~~~\n~~~php\n@if(Theme::hasTitle())\n\t{{ Theme::getTitle() }}\n@endif\n~~~\n\nGet argument assigned to content in layout or region:\n\n~~~php\nTheme::getContentArguments();\nTheme::getContentArgument('name');\n~~~\nTo check if it exists:\n~~~php\nTheme::hasContentArgument('name');\n~~~\n\n\u003e Theme::place('content') is a reserve region to render sub-view.\n\n## Preparing data to view\n\nSometimes you don't need to execute heavy processing, so you can prepare and use when you need it.\n\n~~~php\n$theme-\u003ebind('something', function()\n{\n\treturn 'This is bound parameter.';\n});\n~~~\n\nUsing bound data on view:\n\n~~~php\necho Theme::bind('something');\n~~~\n\n## Breadcrumb\n\nIn order to use breadcrumbs, follow the instruction below:\n\n~~~php\n$theme-\u003ebreadcrumb()-\u003eadd('label', 'http://...')-\u003eadd('label2', 'http:...');\n\n// or\n\n$theme-\u003ebreadcrumb()-\u003eadd([[\n\t\t\t 'label' =\u003e 'label1',\n\t\t\t 'url'   =\u003e 'http://...'\n\t\t\t],[\n\t\t\t 'label' =\u003e 'label2',\n\t\t\t 'url'   =\u003e 'http://...'\n\t\t\t]]);\n~~~\n\nTo render breadcrumbs:\n~~~php\n{!! $theme-\u003ebreadcrumb()-\u003erender() !!}\n~~~\nor\n~~~php\n{!! Theme::breadcrumb()-\u003erender() !!}\n~~~\n\nYou can set up breadcrumbs template anywhere you want by using a blade template.\n\n~~~php\n$theme-\u003ebreadcrumb()-\u003esetTemplate('\n\t\u003cul class=\"breadcrumb\"\u003e\n\t  @foreach ($crumbs as $i =\u003e $crumb)\n\t\t  @if ($i != (count($crumbs) - 1))\n\t\t\t  \u003cli\u003e\u003ca href=\"{{ $crumb[\"url\"] }}\"\u003e{{ $crumb[\"label\"] }}\u003c/a\u003e\u003cspan class=\"divider\"\u003e/\u003c/span\u003e\u003c/li\u003e\n\t\t  @else\n\t\t\t  \u003cli class=\"active\"\u003e{{ $crumb[\"label\"] }}\u003c/li\u003e\n\t\t  @endif\n\t  @endforeach\n\t\u003c/ul\u003e\n');\n~~~\n\n## Widgets\n\nTheme has many useful features called \"widget\" that can be anything.\nYou can create a global widget class using artisan command:\n\n~~~bash\nphp artisan theme:widget demo --global\n~~~\n\u003e Widget tpl is located in \"resources/views/widgets/{widget-tpl}.blade.php\"\n\nCreating a specific theme name.\n~~~\nphp artisan theme:widget demo default \n~~~\n\u003e Widget tpl is located in \"public/themes/[theme]/widgets/{widget-tpl}.blade.php\"\n\nNow you will see a widget class at /app/Widgets/WidgetDemo.php\n\n~~~html\n\u003ch1\u003eUser Id: {{ $label }}\u003c/h1\u003e\n~~~\n\n##### Calling your widget in layout or view:\n\n~~~php\n@widget('demo', ['label' =\u003e 'Hi!'])\n~~~\n\nor\n\n~~~php\n{!! Theme::widget('demo', ['label' =\u003e 'Hi!'])-\u003erender() !!}\n~~~\n\n## Using theme global\n~~~php\nuse Ayra\\Theme\\Contracts\\Theme;\nuse App\\Http\\Controllers\\Controller;\n\nclass BaseController extends Controller {\n\n\t/**\n\t * Theme instance.\n\t *\n\t * @var \\Ayra\\Theme\\Theme\n\t */\n\tprotected $theme;\n\n\t/**\n\t * Construct\n\t *\n\t * @return void\n\t */\n\tpublic function __construct(Theme $theme)\n\t{\n\t\t// Using theme as a global.\n\t\t$this-\u003etheme = $theme-\u003euses('default')-\u003elayout('ipad');\n\t}\n\n}\n~~~\n\nTo override theme or layout.\n~~~php\npublic function getIndex()\n{\n\t$this-\u003etheme-\u003euses('newone');\n\n\t// or just override layout\n\t$this-\u003etheme-\u003elayout('desktop');\n\n\t$this-\u003etheme-\u003eof('somewhere.index')-\u003erender();\n}\n~~~\n## Middleware:\n\nA middleware is included out of the box if you want to define a theme or layout per route. For Laravel 5.4+ the middleware is installed by default.\n\n##### To install it in Laravel before 5.4:\n\nOnly register it in `app\\Http\\Kernel.php`\n~~~php\nprotected $routeMiddleware = [\n    ...\n    'setTheme' =\u003e \\Ayra\\Theme\\Middleware\\ThemeLoader::class,\n];\n~~~\n\n##### Usage:\nYou can apply the middleware to a route or route-group with the string `'theme:[theme],[layout]'`\n~~~php\nRoute::get('/', function () {\n\t...\n\treturn Theme::view('index');\n})-\u003emiddleware('theme:default,layout');\n~~~\n\nOr using groups:\n\n~~~php\nRoute::group(['middleware'=\u003e'theme:default,layout'], function() {\n    ...\n});\n~~~\n\n## Helpers\n##### Protect emails:\nProtect the email address against bots or spiders that index or harvest addresses for sending you spam.\n~~~php\n{!! protectEmail('email@example.com') !!}\n~~~\nor shorter\n~~~php\n@protect('email@example.com')\n~~~\n##### Metadata init:\nPrint meta tags with common metadata.\n~~~php\n{!! meta_init() !!}\n~~~\n\u003e Returns: `\u003cmeta charset=\"utf-8\"\u003e \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"\u003e \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e`\n  \n## Cheatsheet\n##### Commands:\nCommand | Description \n------------ | -------------\n`artisan theme:create name` | Generate theme structure.\n`artisan theme:destroy name` | Remove a theme.\n`artisan theme:list` | Show a list of all themes.\n`artisan theme:duplicate name new` | Duplicate theme structure from other theme.\n`artisan theme:widget demo default` | Generate widget structure.\n\n##### Blade Directives:\nBlade | Description \n------------ | -------------\n`@get('value')` |  Magic method for get. \n`@getIfHas('value')` | Like `@get` but show only if exist.\n`@partial('value', ['var'=\u003e 'optional'])` | Load the partial from current theme.\n`@section('value', ['var'=\u003e 'optional'])` | Like `@partial` but load from sections folder.\n`@content()` | Load the content of the selected view.\n`@styles('optional')` | Render styles declared in theme config.\n`@scripts('optional')` | Render scripts declared in theme config.\n`@widget('value', ['var'=\u003e 'optional'])` | Render widget.\n`@protect('value')` | Protect the email address against bots or spiders.\n`@dd('value')` | Dump and Die. \n`@d('value')` | Only dump.\n`@dv()` | Dump, Die and show all defined variables.\n\n##### Helpers:\nHelper | Description \n------------ | -------------\n`protectEmail('email')` | Protect the email address against bots or spiders.\n`meta_init()` | Print meta tags with common metadata.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimajkumar%2Flaravel-themes-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimajkumar%2Flaravel-themes-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimajkumar%2Flaravel-themes-creator/lists"}