FEATURE: init module for static pages

This commit is contained in:
Michal Kváček
2016-01-21 11:41:26 +01:00
parent a615b20ae8
commit 629a5491e7
24 changed files with 208 additions and 0 deletions
View File
View File
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'name' => 'StaticPages'
];
@@ -0,0 +1,20 @@
<?php namespace Modules\Staticpages\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class StaticPagesDatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}
@@ -0,0 +1,12 @@
<?php namespace Modules\Staticpages\Http\Controllers;
use Pingpong\Modules\Routing\Controller;
class StaticPagesController extends Controller {
public function index()
{
return view('staticpages::index');
}
}
+6
View File
@@ -0,0 +1,6 @@
<?php
Route::group(['middleware' => 'web', 'prefix' => 'staticpages', 'namespace' => 'Modules\StaticPages\Http\Controllers'], function()
{
Route::get('/', 'StaticPagesController@index');
});
@@ -0,0 +1,97 @@
<?php namespace Modules\Staticpages\Providers;
use Illuminate\Support\ServiceProvider;
class StaticPagesServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('staticpages.php'),
]);
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', 'staticpages'
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = base_path('resources/views/modules/staticpages');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath
]);
$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/staticpages';
}, \Config::get('view.paths')), [$sourcePath]), 'staticpages');
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = base_path('resources/lang/modules/staticpages');
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'staticpages');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'staticpages');
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}
}
@@ -0,0 +1,11 @@
@extends('staticpages::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>
This view is loaded from module: {!! config('staticpages.name') !!}
</p>
@stop
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Module StaticPages</title>
</head>
<body>
@yield('content')
</body>
</html>
View File
+15
View File
@@ -0,0 +1,15 @@
{
"name": "pingpong-modules/staticpages",
"description": "",
"authors": [
{
"name": "Pingpong Labs",
"email": "pingpong.labs@gmail.com"
}
],
"autoload": {
"psr-4": {
"Modules\\StaticPages\\": ""
}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"name": "StaticPages",
"alias": "staticpages",
"description": "",
"keywords": [],
"active": 1,
"order": 0,
"providers": [
"Modules\\StaticPages\\Providers\\StaticPagesServiceProvider"
],
"aliases":{},
"files": [
"start.php"
]
}
+15
View File
@@ -0,0 +1,15 @@
<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces And Routes
|--------------------------------------------------------------------------
|
| When a module starting, this file will executed automatically. This helps
| to register some namespaces like translator or view. Also this file
| will load the routes file for each module. You may also modify
| this file as you want.
|
*/
require __DIR__ . '/Http/routes.php';