Skip to content

Commit 945a28f

Browse files
author
Nabeel Shahzad
committedFeb 28, 2020
Moving of plugin from main repo to here
1 parent bd67f3c commit 945a28f

22 files changed

+636
-1
lines changed
 

‎.gitignore

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
_ide_helper.php
2+
.php_cs.cache
3+
.phpstorm.meta.php
4+
.phpunit.result.cache
5+
/vendor
6+
node_modules/
7+
npm-debug.log
8+
composer.phar
9+
yarn-error.log
10+
*.bak
11+
12+
# Laravel 4 specific
13+
bootstrap/compiled.php
14+
app/storage/
15+
16+
# Laravel 5 & Lumen specific
17+
public/storage
18+
public/hot
19+
storage/*.key
20+
storage/settings.json
21+
storage/*.sqlite
22+
.env.*.php
23+
.env.php
24+
.env
25+
.env.bak
26+
env.php
27+
.env.generated
28+
.vagrant
29+
#Homestead.yaml
30+
Homestead.json
31+
LocalValetDriver.php
32+
33+
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
34+
.rocketeer/
35+
36+
tmp/
37+
38+
# intellij files
39+
.idea/composerJson.xml
40+
.idea/**/workspace.xml
41+
.idea/**/tasks.xml
42+
.idea/dictionaries
43+
.idea/**/dataSources/
44+
.idea/**/dataSources.ids
45+
.idea/**/dataSources.xml
46+
.idea/**/dataSources.local.xml
47+
.idea/**/sqlDataSources.xml
48+
.idea/**/dynamic.xml
49+
.idea/**/uiDesigner.xml
50+
.idea/**/gradle.xml
51+
.idea/**/libraries
52+
cmake-build-debug/
53+
.idea/**/mongoSettings.xml
54+
*.iws
55+
out/
56+
.idea_modules/
57+
atlassian-ide-plugin.xml
58+
.idea/replstate.xml
59+
com_crashlytics_export_strings.xml
60+
crashlytics.properties
61+
crashlytics-build.properties
62+
fabric.properties
63+
.idea
64+
phpvms.iml
65+
phpvms_next.iml
66+
67+
# Gradle:
68+
public/info.php
69+
70+
# Error Logs
71+
error_log
72+
73+
.sass-cache
74+
.DS_Store
75+
/config.php
76+
/VERSION

‎Awards/SampleAward.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Modules\Sample\Awards;
4+
5+
use App\Contracts\Award;
6+
7+
/**
8+
* Class SampleAward
9+
*/
10+
class SampleAward extends Award
11+
{
12+
public $name = 'Sample Award';
13+
14+
/**
15+
* This is the method that needs to be implemented.
16+
* You have access to $this->user, which holds the current
17+
* user the award is being checked against
18+
*
19+
* @param null $params Parameters passed in from the UI
20+
*
21+
* @return bool
22+
*/
23+
public function check($params = null): bool
24+
{
25+
return false;
26+
}
27+
}

‎Config/config.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'name' => 'Sample',
5+
];
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Modules\Sample\Database\Seeders;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Seeder;
7+
8+
class SampleDatabaseSeeder extends Seeder
9+
{
10+
/**
11+
* Run the database seeds.
12+
*
13+
* @return void
14+
*/
15+
public function run()
16+
{
17+
Model::unguard();
18+
19+
// $this->call("OthersTableSeeder");
20+
}
21+
}
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Modules\Sample\Http\Controllers\Admin;
4+
5+
use App\Contracts\Controller;
6+
use Illuminate\Http\Request;
7+
8+
/**
9+
* Class AdminController
10+
*/
11+
class AdminController extends Controller
12+
{
13+
/**
14+
* Display a listing of the resource.
15+
*/
16+
public function index()
17+
{
18+
return view('sample::admin.index');
19+
}
20+
21+
/**
22+
* Show the form for creating a new resource.
23+
*/
24+
public function create()
25+
{
26+
return view('sample::admin.create');
27+
}
28+
29+
/**
30+
* Store a newly created resource in storage.
31+
*/
32+
public function store(Request $request)
33+
{
34+
}
35+
36+
/**
37+
* Show the specified resource.
38+
*/
39+
public function show()
40+
{
41+
return view('sample::admin.show');
42+
}
43+
44+
/**
45+
* Show the form for editing the specified resource.
46+
*/
47+
public function edit()
48+
{
49+
return view('sample::admin.edit');
50+
}
51+
52+
/**
53+
* Update the specified resource in storage.
54+
*/
55+
public function update(Request $request)
56+
{
57+
}
58+
59+
/**
60+
* Remove the specified resource from storage.
61+
*/
62+
public function destroy()
63+
{
64+
}
65+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Modules\Sample\Http\Controllers\Api;
4+
5+
use App\Contracts\Controller;
6+
use Illuminate\Http\Request;
7+
8+
/**
9+
* Class SampleController
10+
*/
11+
class SampleController extends Controller
12+
{
13+
/**
14+
* Just send out a message
15+
*
16+
* @param Request $request
17+
*
18+
* @return \Illuminate\Http\JsonResponse
19+
*/
20+
public function index(Request $request)
21+
{
22+
return $this->message('Hello, world!');
23+
}
24+
25+
/**
26+
* @param Request $request
27+
*
28+
* @return \Illuminate\Http\JsonResponse
29+
*/
30+
public function hello(Request $request)
31+
{
32+
// Another way to return JSON, this for a custom response
33+
// It's recommended to use Resources for responses from the database
34+
return response()->json([
35+
'name' => Auth::user()->name,
36+
]);
37+
}
38+
}

‎Http/Controllers/SampleController.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Modules\Sample\Http\Controllers;
4+
5+
use App\Contracts\Controller;
6+
use Illuminate\Http\Request;
7+
8+
/**
9+
* Class SampleController
10+
*/
11+
class SampleController extends Controller
12+
{
13+
/**
14+
* Display a listing of the resource.
15+
*/
16+
public function index()
17+
{
18+
return view('sample::index');
19+
}
20+
21+
/**
22+
* Show the form for creating a new resource.
23+
*/
24+
public function create()
25+
{
26+
return view('sample::create');
27+
}
28+
29+
/**
30+
* Store a newly created resource in storage.
31+
*
32+
* @param Request $request
33+
*/
34+
public function store(Request $request)
35+
{
36+
}
37+
38+
/**
39+
* Show the specified resource.
40+
*/
41+
public function show()
42+
{
43+
return view('sample::show');
44+
}
45+
46+
/**
47+
* Show the form for editing the specified resource.
48+
*/
49+
public function edit()
50+
{
51+
return view('sample::edit');
52+
}
53+
54+
/**
55+
* Update the specified resource in storage.
56+
*/
57+
public function update(Request $request)
58+
{
59+
}
60+
61+
/**
62+
* Remove the specified resource from storage.
63+
*/
64+
public function destroy()
65+
{
66+
}
67+
}

‎Http/Routes/admin.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
// This is the admin path. Comment this out if you don't have
4+
// an admin panel component.
5+
Route::group([], function () {
6+
Route::get('/', 'AdminController@index');
7+
Route::get('/create', 'AdminController@create');
8+
});

‎Http/Routes/api.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/**
4+
* This is publicly accessible
5+
*/
6+
Route::group(['middleware' => []], function () {
7+
Route::get('/', 'SampleController@index');
8+
});
9+
10+
/*
11+
* This is required to have a valid API key
12+
*/
13+
Route::group(['middleware' => [
14+
'api.auth',
15+
]], function () {
16+
Route::get('/hello', 'SampleController@hello');
17+
});

‎Http/Routes/web.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
Route::group(['middleware' => [
4+
'role:user', // leave blank to make this public
5+
]], function () {
6+
// all your routes are prefixed with the above prefix
7+
// e.g. yoursite.com/sample
8+
Route::get('/', 'SampleController@index');
9+
});

‎Listeners/TestEventListener.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Modules\Sample\Listeners;
4+
5+
use App\Events\TestEvent;
6+
use Log;
7+
8+
class TestEventListener
9+
{
10+
/**
11+
* Handle the event.
12+
*/
13+
public function handle(TestEvent $event)
14+
{
15+
Log::info('Received event', [$event]);
16+
}
17+
}

‎Models/SampleTable.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Modules\Sample\Models;
4+
5+
use App\Contracts\Model;
6+
7+
/**
8+
* Class SampleTable
9+
*/
10+
class SampleTable extends Model
11+
{
12+
public $table = '';
13+
14+
protected $fillable = [];
15+
}

‎Providers/EventServiceProvider.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Modules\Sample\Providers;
4+
5+
use App\Events\TestEvent;
6+
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
7+
use Modules\Sample\Listeners\TestEventListener;
8+
9+
class EventServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* The event listener mappings for the application.
13+
*/
14+
protected $listen = [
15+
TestEvent::class => [TestEventListener::class],
16+
];
17+
18+
/**
19+
* Register any events for your application.
20+
*/
21+
public function boot()
22+
{
23+
parent::boot();
24+
}
25+
}

‎Providers/SampleServiceProvider.php

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
namespace Modules\Sample\Providers;
4+
5+
use App\Services\ModuleService;
6+
use Illuminate\Support\ServiceProvider;
7+
use Route;
8+
9+
class SampleServiceProvider extends ServiceProvider
10+
{
11+
protected $moduleSvc;
12+
13+
/**
14+
* Boot the application events.
15+
*/
16+
public function boot()
17+
{
18+
$this->moduleSvc = app(ModuleService::class);
19+
20+
$this->registerRoutes();
21+
$this->registerTranslations();
22+
$this->registerConfig();
23+
$this->registerViews();
24+
25+
$this->registerLinks();
26+
27+
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
28+
}
29+
30+
/**
31+
* Register the service provider.
32+
*/
33+
public function register()
34+
{
35+
//
36+
}
37+
38+
/**
39+
* Add module links here
40+
*/
41+
public function registerLinks()
42+
{
43+
// Show this link if logged in
44+
// $this->moduleSvc->addFrontendLink('Sample', '/sample', '', $logged_in=true);
45+
46+
// Admin links:
47+
$this->moduleSvc->addAdminLink('Sample', '/admin/sample');
48+
}
49+
50+
/**
51+
* Register the routes
52+
*/
53+
protected function registerRoutes()
54+
{
55+
/*
56+
* Routes for the frontend
57+
*/
58+
Route::group([
59+
'as' => 'sample.',
60+
'prefix' => 'sample',
61+
// If you want a RESTful module, change this to 'api'
62+
'middleware' => ['web'],
63+
'namespace' => 'Modules\Sample\Http\Controllers',
64+
], function () {
65+
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
66+
});
67+
68+
/*
69+
* Routes for the admin
70+
*/
71+
Route::group([
72+
'as' => 'sample.',
73+
'prefix' => 'admin/sample',
74+
// If you want a RESTful module, change this to 'api'
75+
'middleware' => ['web', 'role:admin'],
76+
'namespace' => 'Modules\Sample\Http\Controllers\Admin',
77+
], function () {
78+
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/admin.php');
79+
});
80+
81+
/*
82+
* Routes for an API
83+
*/
84+
Route::group([
85+
'as' => 'sample.',
86+
'prefix' => 'api/sample',
87+
// If you want a RESTful module, change this to 'api'
88+
'middleware' => ['api'],
89+
'namespace' => 'Modules\Sample\Http\Controllers\Api',
90+
], function () {
91+
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/api.php');
92+
});
93+
}
94+
95+
/**
96+
* Register config.
97+
*/
98+
protected function registerConfig()
99+
{
100+
$this->publishes([
101+
__DIR__.'/../Config/config.php' => config_path('sample.php'),
102+
], 'config');
103+
104+
$this->mergeConfigFrom(
105+
__DIR__.'/../Config/config.php', 'sample'
106+
);
107+
}
108+
109+
/**
110+
* Register views.
111+
*/
112+
public function registerViews()
113+
{
114+
$viewPath = resource_path('views/modules/sample');
115+
$sourcePath = __DIR__.'/../Resources/views';
116+
117+
$this->publishes([
118+
$sourcePath => $viewPath,
119+
], 'views');
120+
121+
$paths = array_map(
122+
function ($path) {
123+
return $path.'/modules/sample';
124+
},
125+
\Config::get('view.paths')
126+
);
127+
128+
$paths[] = $sourcePath;
129+
$this->loadViewsFrom($paths, 'sample');
130+
}
131+
132+
/**
133+
* Register translations.
134+
*/
135+
public function registerTranslations()
136+
{
137+
$langPath = resource_path('lang/modules/sample');
138+
139+
if (is_dir($langPath)) {
140+
$this->loadTranslationsFrom($langPath, 'sample');
141+
} else {
142+
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'sample');
143+
}
144+
}
145+
146+
/**
147+
* Get the services provided by the provider.
148+
*/
149+
public function provides(): array
150+
{
151+
return [];
152+
}
153+
}

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# phpvms-plugin
2-
Template repository for a phpVMS plugin
2+
3+
Sample/template repository for a phpVMS plugin.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@extends('sample::layouts.admin')
2+
3+
@section('title', 'Sample Create')
4+
@section('actions')
5+
@endsection
6+
7+
@section('content')
8+
<div class="card border-blue-bottom">
9+
<div class="content">
10+
<div class="header"><h4 class="title">Create something!</h4></div>
11+
<p>Add a form!</p>
12+
</div>
13+
</div>
14+
@endsection

‎Resources/views/admin/index.blade.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@extends('sample::layouts.admin')
2+
3+
@section('title', 'Sample')
4+
@section('actions')
5+
<li>
6+
<a href="{{ url('/admin/sample/create') }}">
7+
<i class="ti-plus"></i>
8+
Add New</a>
9+
</li>
10+
@endsection
11+
@section('content')
12+
<div class="card border-blue-bottom">
13+
<div class="content">
14+
<div class="header"><h4 class="title">Admin Scaffold!</h4></div>
15+
<p>This view is loaded from module: {{ config('sample.name') }}</p>
16+
</div>
17+
</div>
18+
@endsection

‎Resources/views/index.blade.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@extends('sample::layouts.frontend')
2+
3+
@section('content')
4+
<h1>Hello World</h1>
5+
6+
<p>
7+
This view is loaded from module: {{ config('sample.name') }}
8+
</p>
9+
@endsection
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{--
2+
You probably don't want to edit anything here. Just make
3+
sure to extend this in your views. It will pass the content section through
4+
--}}
5+
@extends('admin.app')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{--
2+
You probably don't want to edit anything here. Just make
3+
sure to extend this in your views. It will pass the content section through
4+
--}}
5+
@extends('app')

‎composer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "phpvms/sample-module",
3+
"type": "phpvms-plugin",
4+
"description": "",
5+
"require": {
6+
"composer/installers": "~1.0",
7+
"joshbrw/laravel-module-installer": "0.1.x"
8+
},
9+
"extra": {
10+
"laravel": {
11+
"providers": [
12+
"Modules\\Sample\\Providers\\SampleServiceProvider",
13+
"Modules\\Sample\\Providers\\EventServiceProvider"
14+
],
15+
"aliases": {
16+
17+
}
18+
}
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"modules\\Sample\\": ""
23+
}
24+
}
25+
}

‎module.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Sample",
3+
"alias": "sample",
4+
"description": "",
5+
"keywords": [],
6+
"active": 1,
7+
"order": 0,
8+
"providers": [
9+
"Modules\\Sample\\Providers\\SampleServiceProvider",
10+
"Modules\\Sample\\Providers\\EventServiceProvider"
11+
],
12+
"aliases": {},
13+
"files": [],
14+
"requires": []
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.