Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit c4d31f3

Browse files
authored
Merge pull request #15 from cleaniquecoders/develop
Major Enhancement
2 parents b7ada0e + 4ac78ac commit c4d31f3

File tree

23 files changed

+433
-48
lines changed

23 files changed

+433
-48
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ php:
77
env:
88
- APP_ENV=testing
99

10+
cache:
11+
directories:
12+
- vendor
13+
1014
before_script:
1115
- travis_retry composer self-update
1216
- travis_retry composer update --prefer-source --no-interaction --dev

app/Console/Commands/ReloadAllCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public function handle()
4242
$this->call('make:jwt');
4343

4444
if ($this->option('dev')) {
45-
$this->call('db:seed', [
46-
'--class' => 'DevelopmentSeeder',
47-
]);
45+
$this->call('seed:dev');
4846
}
4947
}
5048
}

app/Console/Commands/ReloadDbCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class ReloadDbCommand extends Command
1111
*
1212
* @var string
1313
*/
14-
protected $signature = 'reload:db';
14+
protected $signature = 'reload:db
15+
{--d|dev : Seed development data}';
1516

1617
/**
1718
* The console command description.
@@ -38,5 +39,9 @@ public function handle()
3839
$this->call('migrate:fresh', ['--seed' => true]);
3940
$this->info('Seeding Profile Dependencies');
4041
$this->call('profile:seed');
42+
43+
if ($this->option('dev')) {
44+
$this->call('seed:dev');
45+
}
4146
}
4247
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class SeedDevelopmentDataCommand extends Command
8+
{
9+
/**
10+
* The name and signature of the console command.
11+
*
12+
* @var string
13+
*/
14+
protected $signature = 'seed:dev';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Seed Development Data';
22+
23+
/**
24+
* Create a new command instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
parent::__construct();
31+
}
32+
33+
/**
34+
* Execute the console command.
35+
*
36+
* @return mixed
37+
*/
38+
public function handle()
39+
{
40+
$this->call('db:seed', ['--class' => 'DevelopmentSeeder']);
41+
}
42+
}

app/Console/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Kernel extends ConsoleKernel
1717
Commands\ReloadAllCommand::class,
1818
Commands\ReloadCacheCommand::class,
1919
Commands\ReloadDbCommand::class,
20+
Commands\SeedDevelopmentDataCommand::class,
2021
];
2122

2223
/**
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api\Manage;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
8+
class AclController extends Controller
9+
{
10+
public function __invoke(Request $request)
11+
{
12+
switch ($request->type) {
13+
case 'create':
14+
$permissions = [
15+
$request->permission . '_create',
16+
$request->permission . '_store',
17+
];
18+
break;
19+
case 'view':
20+
$permissions = [
21+
$request->permission . '_index',
22+
$request->permission . '_show',
23+
];
24+
break;
25+
case 'update':
26+
$permissions = [
27+
$request->permission . '_edit',
28+
$request->permission . '_update',
29+
];
30+
break;
31+
case 'destroy':
32+
$permissions = [
33+
$request->permission . '_destroy',
34+
];
35+
break;
36+
}
37+
38+
$role = role($request->role);
39+
40+
foreach ($permissions as $permission) {
41+
if($request->revoke) {
42+
$role->revokePermissionTo($permission);
43+
} else {
44+
$role->givePermissionTo($permission);
45+
}
46+
}
47+
}
48+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Manage;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
8+
class AclController extends Controller
9+
{
10+
/**
11+
* Display a listing of the resource.
12+
*
13+
* @return \Illuminate\Http\Response
14+
*/
15+
public function index()
16+
{
17+
return view('manage.acl.index');
18+
}
19+
20+
/**
21+
* Show the form for creating a new resource.
22+
*
23+
* @return \Illuminate\Http\Response
24+
*/
25+
public function create()
26+
{
27+
//
28+
}
29+
30+
/**
31+
* Store a newly created resource in storage.
32+
*
33+
* @param \Illuminate\Http\Request $request
34+
* @return \Illuminate\Http\Response
35+
*/
36+
public function store(Request $request)
37+
{
38+
//
39+
}
40+
41+
/**
42+
* Display the specified resource.
43+
*
44+
* @param int $id
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function show($id)
48+
{
49+
//
50+
}
51+
52+
/**
53+
* Show the form for editing the specified resource.
54+
*
55+
* @param int $id
56+
* @return \Illuminate\Http\Response
57+
*/
58+
public function edit($id)
59+
{
60+
//
61+
}
62+
63+
/**
64+
* Update the specified resource in storage.
65+
*
66+
* @param \Illuminate\Http\Request $request
67+
* @param int $id
68+
* @return \Illuminate\Http\Response
69+
*/
70+
public function update(Request $request, $id)
71+
{
72+
//
73+
}
74+
75+
/**
76+
* Remove the specified resource from storage.
77+
*
78+
* @param int $id
79+
* @return \Illuminate\Http\Response
80+
*/
81+
public function destroy($id)
82+
{
83+
//
84+
}
85+
}

app/Macros/Routing/Breadcrumb.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Macros\Routing;
4+
5+
use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager;
6+
7+
class Breadcrumb
8+
{
9+
public static function registerMacros()
10+
{
11+
if (! BreadcrumbsManager::hasMacro('crud')) {
12+
BreadcrumbsManager::macro('crud', function (string $module, string $parent, string $prefix) {
13+
// Module Name
14+
BreadcrumbsManager::register($prefix . '.index', function ($breadcrumbs) use ($module, $parent, $prefix) {
15+
$breadcrumbs->parent($parent);
16+
$breadcrumbs->push($module, route($prefix . '.index'));
17+
});
18+
19+
// Module Name > Add
20+
BreadcrumbsManager::register($prefix . '.create', function ($breadcrumbs) use ($prefix) {
21+
$breadcrumbs->parent($prefix . '.index');
22+
$breadcrumbs->push(__('Add'), route($prefix . '.create'));
23+
});
24+
25+
// Module Name > Details
26+
BreadcrumbsManager::register($prefix . '.show', function ($breadcrumbs, $id) use ($prefix) {
27+
$breadcrumbs->parent($prefix . '.index');
28+
$breadcrumbs->push(__('Details'), route($prefix . '.show', $id));
29+
});
30+
31+
// Module Name > Edit
32+
BreadcrumbsManager::register($prefix . '.edit', function ($breadcrumbs, $id) use ($prefix) {
33+
$breadcrumbs->parent($prefix . '.show', $id);
34+
$breadcrumbs->push(__('Update'), route($prefix . '.edit', $id));
35+
});
36+
});
37+
}
38+
}
39+
}

app/Providers/MacroServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function boot()
1313
{
1414
\App\Macros\Http\Response::registerMacros();
1515
\App\Macros\Models\Model::registerMacros();
16+
\App\Macros\Routing\Breadcrumb::registerMacros();
1617
}
1718

1819
/**

app/Providers/RouteServiceProvider.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function boot()
3030
public function map()
3131
{
3232
$this->mapApiRoutes();
33-
$this->mapDatatableRoutes();
3433
$this->mapWebRoutes();
3534
}
3635

@@ -43,7 +42,12 @@ protected function mapWebRoutes()
4342
{
4443
Route::middleware('web')
4544
->namespace($this->namespace)
46-
->group(base_path('routes/web.php'));
45+
->group(function () {
46+
collect(glob(base_path('/routes/web/*.php')))
47+
->each(function ($path) {
48+
require $path;
49+
});
50+
});
4751
}
4852

4953
/**
@@ -57,7 +61,22 @@ protected function mapApiRoutes()
5761
->middleware('api')
5862
->as('api.')
5963
->namespace($this->namespace . '\Api')
60-
->group(base_path('routes/api.php'));
64+
->group(function () {
65+
collect(glob(base_path('/routes/api/*.php')))
66+
->each(function ($path) {
67+
require $path;
68+
});
69+
70+
Route::prefix('datatable')
71+
->as('datatable.')
72+
->namespace('\Datatable')
73+
->group(function () {
74+
collect(glob(base_path('/routes/datatable/*.php')))
75+
->each(function ($path) {
76+
require $path;
77+
});
78+
});
79+
});
6180
}
6281

6382
/**
@@ -67,10 +86,5 @@ protected function mapApiRoutes()
6786
*/
6887
protected function mapDatatableRoutes()
6988
{
70-
Route::prefix('api/datatable')
71-
->middleware('api')
72-
->as('api.datatable.')
73-
->namespace($this->namespace . '\Api\Datatable')
74-
->group(base_path('routes/datatable.php'));
7589
}
7690
}

0 commit comments

Comments
 (0)