Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ php:
env:
- APP_ENV=testing

cache:
directories:
- vendor

before_script:
- travis_retry composer self-update
- travis_retry composer update --prefer-source --no-interaction --dev
Expand Down
4 changes: 1 addition & 3 deletions app/Console/Commands/ReloadAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public function handle()
$this->call('make:jwt');

if ($this->option('dev')) {
$this->call('db:seed', [
'--class' => 'DevelopmentSeeder',
]);
$this->call('seed:dev');
}
}
}
7 changes: 6 additions & 1 deletion app/Console/Commands/ReloadDbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ReloadDbCommand extends Command
*
* @var string
*/
protected $signature = 'reload:db';
protected $signature = 'reload:db
{--d|dev : Seed development data}';

/**
* The console command description.
Expand All @@ -38,5 +39,9 @@ public function handle()
$this->call('migrate:fresh', ['--seed' => true]);
$this->info('Seeding Profile Dependencies');
$this->call('profile:seed');

if ($this->option('dev')) {
$this->call('seed:dev');
}
}
}
42 changes: 42 additions & 0 deletions app/Console/Commands/SeedDevelopmentDataCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class SeedDevelopmentDataCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'seed:dev';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed Development Data';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->call('db:seed', ['--class' => 'DevelopmentSeeder']);
}
}
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Kernel extends ConsoleKernel
Commands\ReloadAllCommand::class,
Commands\ReloadCacheCommand::class,
Commands\ReloadDbCommand::class,
Commands\SeedDevelopmentDataCommand::class,
];

/**
Expand Down
48 changes: 48 additions & 0 deletions app/Http/Controllers/Api/Manage/AclController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Http\Controllers\Api\Manage;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AclController extends Controller
{
public function __invoke(Request $request)
{
switch ($request->type) {
case 'create':
$permissions = [
$request->permission . '_create',
$request->permission . '_store',
];
break;
case 'view':
$permissions = [
$request->permission . '_index',
$request->permission . '_show',
];
break;
case 'update':
$permissions = [
$request->permission . '_edit',
$request->permission . '_update',
];
break;
case 'destroy':
$permissions = [
$request->permission . '_destroy',
];
break;
}

$role = role($request->role);

foreach ($permissions as $permission) {
if($request->revoke) {
$role->revokePermissionTo($permission);
} else {
$role->givePermissionTo($permission);
}
}
}
}
85 changes: 85 additions & 0 deletions app/Http/Controllers/Manage/AclController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Http\Controllers\Manage;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AclController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('manage.acl.index');
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
39 changes: 39 additions & 0 deletions app/Macros/Routing/Breadcrumb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Macros\Routing;

use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager;

class Breadcrumb
{
public static function registerMacros()
{
if (! BreadcrumbsManager::hasMacro('crud')) {
BreadcrumbsManager::macro('crud', function (string $module, string $parent, string $prefix) {
// Module Name
BreadcrumbsManager::register($prefix . '.index', function ($breadcrumbs) use ($module, $parent, $prefix) {
$breadcrumbs->parent($parent);
$breadcrumbs->push($module, route($prefix . '.index'));
});

// Module Name > Add
BreadcrumbsManager::register($prefix . '.create', function ($breadcrumbs) use ($prefix) {
$breadcrumbs->parent($prefix . '.index');
$breadcrumbs->push(__('Add'), route($prefix . '.create'));
});

// Module Name > Details
BreadcrumbsManager::register($prefix . '.show', function ($breadcrumbs, $id) use ($prefix) {
$breadcrumbs->parent($prefix . '.index');
$breadcrumbs->push(__('Details'), route($prefix . '.show', $id));
});

// Module Name > Edit
BreadcrumbsManager::register($prefix . '.edit', function ($breadcrumbs, $id) use ($prefix) {
$breadcrumbs->parent($prefix . '.show', $id);
$breadcrumbs->push(__('Update'), route($prefix . '.edit', $id));
});
});
}
}
}
1 change: 1 addition & 0 deletions app/Providers/MacroServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function boot()
{
\App\Macros\Http\Response::registerMacros();
\App\Macros\Models\Model::registerMacros();
\App\Macros\Routing\Breadcrumb::registerMacros();
}

/**
Expand Down
30 changes: 22 additions & 8 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function boot()
public function map()
{
$this->mapApiRoutes();
$this->mapDatatableRoutes();
$this->mapWebRoutes();
}

Expand All @@ -43,7 +42,12 @@ protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
->group(function () {
collect(glob(base_path('/routes/web/*.php')))
->each(function ($path) {
require $path;
});
});
}

/**
Expand All @@ -57,7 +61,22 @@ protected function mapApiRoutes()
->middleware('api')
->as('api.')
->namespace($this->namespace . '\Api')
->group(base_path('routes/api.php'));
->group(function () {
collect(glob(base_path('/routes/api/*.php')))
->each(function ($path) {
require $path;
});

Route::prefix('datatable')
->as('datatable.')
->namespace('\Datatable')
->group(function () {
collect(glob(base_path('/routes/datatable/*.php')))
->each(function ($path) {
require $path;
});
});
});
}

/**
Expand All @@ -67,10 +86,5 @@ protected function mapApiRoutes()
*/
protected function mapDatatableRoutes()
{
Route::prefix('api/datatable')
->middleware('api')
->as('api.datatable.')
->namespace($this->namespace . '\Api\Datatable')
->group(base_path('routes/datatable.php'));
}
}
26 changes: 26 additions & 0 deletions app/Support/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Illuminate\Support\Facades\Cache;

/*
* generate sequence
* @return sequence based on length supplied
Expand Down Expand Up @@ -184,3 +186,27 @@ function locales()
});
}
}

/*
* Get Role by Name
*/
if (! function_exists('role')) {
function role($name)
{
return Cache::remember('role_' . $name, 10, function () use ($name) {
return config('permission.models.role')::findByName($name);
});
}
}

/*
* Get Permission by Name
*/
if (! function_exists('permission')) {
function permission($name)
{
return Cache::remember('permission_' . $name, 10, function () use ($name) {
return config('permission.models.permission')::findByName($name);
});
}
}
1 change: 1 addition & 0 deletions config/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'setting' => ['developer', 'administrator'],
'passport' => ['developer'],
'user' => ['developer', 'administrator'],
'acl' => ['developer', 'administrator'],
],
'actions' => [
'index', 'show',
Expand Down
2 changes: 1 addition & 1 deletion config/breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
|
*/

'files' => base_path('routes/breadcrumbs.php'),
'files' => glob(base_path('routes/breadcrumbs/*.php')),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/forms/checkbox.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
@isset($data)
@foreach($data as $key => $value) data-{{ $key }}="{{ $value }}" @endforeach
@endisset
{{ isset($checked) ? 'checked' : '' }}>
{{ isset($checked) && ($checked) ? 'checked' : '' }}>
<span class="custom-control-label">{{ __($label) }}</span>
</label>
Loading