Sample module
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -54,3 +54,4 @@ error_log
|
||||
|
||||
.sass-cache
|
||||
.DS_Store
|
||||
Sample/
|
||||
|
||||
2
modules/.gitignore
vendored
2
modules/.gitignore
vendored
@@ -3,4 +3,4 @@
|
||||
|
||||
# But keep the sample and this file around
|
||||
!.gitignore
|
||||
!Sample
|
||||
!Sample/**
|
||||
|
||||
5
modules/Sample/Config/config.php
Normal file
5
modules/Sample/Config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Sample'
|
||||
];
|
||||
21
modules/Sample/Database/seeders/SampleDatabaseSeeder.php
Normal file
21
modules/Sample/Database/seeders/SampleDatabaseSeeder.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sample\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SampleDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
// $this->call("OthersTableSeeder");
|
||||
}
|
||||
}
|
||||
63
modules/Sample/Http/Controllers/AdminController.php
Normal file
63
modules/Sample/Http/Controllers/AdminController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sample\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\AppBaseController;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class AdminController extends AppBaseController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('sample::admin.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('sample::admin.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return view('sample::admin.show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
return view('sample::admin.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
}
|
||||
}
|
||||
64
modules/Sample/Http/Controllers/SampleController.php
Normal file
64
modules/Sample/Http/Controllers/SampleController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sample\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\AppBaseController;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class SampleController extends AppBaseController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('sample::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('sample::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
return view('sample::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
return view('sample::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy()
|
||||
{
|
||||
}
|
||||
}
|
||||
24
modules/Sample/Http/routes.php
Normal file
24
modules/Sample/Http/routes.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
Route::group([
|
||||
'as' => 'sample.',
|
||||
'prefix' => 'sample',
|
||||
'middleware' => [
|
||||
'web',
|
||||
'role:admin|user' # leave blank for public
|
||||
],
|
||||
'namespace' => 'Modules\Sample\Http\Controllers'
|
||||
], function() {
|
||||
|
||||
# all your routes are prefixed with the above prefix
|
||||
# e.g. yoursite.com/sample
|
||||
Route::get('/', 'SampleController@index');
|
||||
|
||||
# This is the admin path. Comment this out if you don't have
|
||||
# an admin panel component.
|
||||
Route::group([
|
||||
'middleware' => ['role:admin'],
|
||||
], function () {
|
||||
Route::get('/admin', 'AdminController@index');
|
||||
});
|
||||
});
|
||||
111
modules/Sample/Providers/SampleServiceProvider.php
Normal file
111
modules/Sample/Providers/SampleServiceProvider.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sample\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class SampleServiceProvider 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->registerRoutes();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->registerFactories();
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the routes
|
||||
*/
|
||||
protected function registerRoutes()
|
||||
{
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../Config/config.php' => config_path('sample.php'),
|
||||
], 'config');
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__.'/../Config/config.php', 'sample'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/sample');
|
||||
$sourcePath = __DIR__.'/../Resources/views';
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
],'views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/sample';
|
||||
}, \Config::get('view.paths')), [$sourcePath]), 'sample');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/sample');
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, 'sample');
|
||||
} else {
|
||||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'sample');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an additional directory of factories.
|
||||
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
|
||||
*/
|
||||
public function registerFactories()
|
||||
{
|
||||
if (! app()->environment('production')) {
|
||||
app(Factory::class)->load(__DIR__ . '/../Database/factories');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
18
modules/Sample/Resources/views/admin/index.blade.php
Normal file
18
modules/Sample/Resources/views/admin/index.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
@extends('sample::layouts.admin')
|
||||
|
||||
@section('title', 'Sample')
|
||||
@section('actions')
|
||||
<li>
|
||||
<a href="{!! url('/sample/admin/create') !!}">
|
||||
<i class="ti-plus"></i>
|
||||
Add New</a>
|
||||
</li>
|
||||
@endsection
|
||||
@section('content')
|
||||
<div class="card border-blue-bottom">
|
||||
<div class="header"><h4 class="title">Admin Scaffold!</h4></div>
|
||||
<div class="content">
|
||||
<p>This view is loaded from module: {!! config('sample.name') !!}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
9
modules/Sample/Resources/views/index.blade.php
Normal file
9
modules/Sample/Resources/views/index.blade.php
Normal file
@@ -0,0 +1,9 @@
|
||||
@extends('sample::layouts.frontend')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>
|
||||
This view is loaded from module: {!! config('sample.name') !!}
|
||||
</p>
|
||||
@endsection
|
||||
5
modules/Sample/Resources/views/layouts/admin.blade.php
Normal file
5
modules/Sample/Resources/views/layouts/admin.blade.php
Normal file
@@ -0,0 +1,5 @@
|
||||
{{--
|
||||
You probably don't want to edit anything here. Just make
|
||||
sure to extend this in your views. It will pass the content section through
|
||||
--}}
|
||||
@extends('admin.app')
|
||||
@@ -0,0 +1,5 @@
|
||||
{{--
|
||||
You probably don't want to edit anything here. Just make
|
||||
sure to extend this in your views. It will pass the content section through
|
||||
--}}
|
||||
@extends('layouts.' . config('phpvms.skin') . '.app')
|
||||
25
modules/Sample/composer.json
Normal file
25
modules/Sample/composer.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "/sample",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "",
|
||||
"email": ""
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Modules\\Sample\\Providers\\SampleServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Sample\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
16
modules/Sample/module.json
Normal file
16
modules/Sample/module.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Sample",
|
||||
"alias": "sample",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"active": 1,
|
||||
"order": 0,
|
||||
"providers": [
|
||||
"Modules\\Sample\\Providers\\SampleServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [
|
||||
"start.php"
|
||||
],
|
||||
"requires": []
|
||||
}
|
||||
17
modules/Sample/start.php
Normal file
17
modules/Sample/start.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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.
|
||||
|
|
||||
*/
|
||||
|
||||
/*if (!app()->routesAreCached()) {
|
||||
require __DIR__ . '/Http/routes.php';
|
||||
}*/
|
||||
Reference in New Issue
Block a user