added view components support for modules

This commit is contained in:
Denis Duliçi 2020-11-11 14:26:30 +03:00
parent 1cff173824
commit 1deeece33a
3 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace $NAMESPACE$;
use Illuminate\View\Component;
class $CLASS$ extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('$ALIAS$::$VIEW_NAME$');
}
}

View File

@ -2,6 +2,7 @@
namespace $NAMESPACE$; namespace $NAMESPACE$;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider as Provider; use Illuminate\Support\ServiceProvider as Provider;
class $NAME$ extends Provider class $NAME$ extends Provider
@ -14,6 +15,7 @@ class $NAME$ extends Provider
public function boot() public function boot()
{ {
$this->loadViews(); $this->loadViews();
$this->loadViewComponents();
$this->loadTranslations(); $this->loadTranslations();
$this->loadMigrations(); $this->loadMigrations();
//$this->loadConfig(); //$this->loadConfig();
@ -39,6 +41,16 @@ class $NAME$ extends Provider
$this->loadViewsFrom(__DIR__ . '/../Resources/views', '$ALIAS$'); $this->loadViewsFrom(__DIR__ . '/../Resources/views', '$ALIAS$');
} }
/**
* Load view components.
*
* @return void
*/
public function loadViewComponents()
{
Blade::componentNamespace('$COMPONENT_NAMESPACE$', '$ALIAS$');
}
/** /**
* Load translations. * Load translations.
* *

View File

@ -111,7 +111,7 @@ return [
'resource' => ['path' => 'Http/Resources', 'generate' => false], 'resource' => ['path' => 'Http/Resources', 'generate' => false],
'asset' => ['path' => 'Resources/assets', 'generate' => false], 'asset' => ['path' => 'Resources/assets', 'generate' => false],
'lang' => ['path' => 'Resources/lang/en-GB', 'generate' => true], 'lang' => ['path' => 'Resources/lang/en-GB', 'generate' => true],
'views' => ['path' => 'Resources/views', 'generate' => true], 'view' => ['path' => 'Resources/views', 'generate' => true],
'test' => ['path' => 'Tests', 'generate' => false], 'test' => ['path' => 'Tests', 'generate' => false],
'repository' => ['path' => 'Repositories', 'generate' => false], 'repository' => ['path' => 'Repositories', 'generate' => false],
'event' => ['path' => 'Events', 'generate' => false], 'event' => ['path' => 'Events', 'generate' => false],
@ -122,6 +122,7 @@ return [
'email' => ['path' => 'Emails', 'generate' => false], 'email' => ['path' => 'Emails', 'generate' => false],
'notification' => ['path' => 'Notifications', 'generate' => false], 'notification' => ['path' => 'Notifications', 'generate' => false],
'route' => ['path' => 'Routes', 'generate' => true], 'route' => ['path' => 'Routes', 'generate' => true],
'component' => ['path' => 'View/Components', 'generate' => false],
], ],
], ],