add frontend/admin links dynamically from module service provider

This commit is contained in:
Nabeel Shahzad
2017-12-01 17:21:48 -06:00
parent 5e2bbe69dc
commit ca6c5cbc0a
5 changed files with 133 additions and 15 deletions

View File

@@ -9,24 +9,23 @@ use Route;
class SampleServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
protected $moduleSvc;
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->moduleSvc = app('App\Services\ModuleService');
$this->registerRoutes();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->registerLinks();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
}
@@ -39,6 +38,18 @@ class SampleServiceProvider extends ServiceProvider
//
}
/**
* Add module links here
*/
public function registerLinks()
{
// Show this link if logged in
$this->moduleSvc->addFrontendLink('Sample', '/sample', '', $logged_in=true);
// Admin links:
$this->moduleSvc->addAdminLink('Sample', '/sample/admin');
}
/**
* Register the routes
*/