-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ee8d3cf
Showing
17 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
vendor/ | ||
node_modules/ | ||
|
||
# Laravel 4 specific | ||
bootstrap/compiled.php | ||
app/storage/ | ||
|
||
# Laravel 5 & Lumen specific | ||
bootstrap/cache/ | ||
.env.*.php | ||
.env.php | ||
.env | ||
|
||
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer | ||
.rocketeer/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Laralum | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<p align="center"><a href="https://laralum.com"><img height="150" src="https://avatars1.githubusercontent.com/u/22253051"></a></p> | ||
|
||
<h1 align="center">Routes</h1> | ||
|
||
<p align="center"> | ||
<a href="https://styleci.io/repos/86605593"><img src="https://styleci.io/repos/86605593/shield?style=flat&branch=master" alt="StyleCI"></a> | ||
<a href="https://github.com/laralum"><img src="https://img.shields.io/badge/Built%20For-Laralum-orange.svg" alt="Laralum"></a> | ||
<a href="https://github.com/laralum/Routes"><img src="https://poser.pugx.org/laralum/routes/d/total.svg" alt="Downloads"></a> | ||
<a href="https://github.com/Laralum/Routes/releases"><img src="https://poser.pugx.org/laralum/routes/v/stable.svg" alt="License"></a> | ||
<a href="https://raw.githubusercontent.com/Laralum/Routes/master/LICENSE"><img src="https://poser.pugx.org/laralum/routes/license.svg" alt="License"></a> | ||
</p> | ||
|
||
## Description | ||
|
||
|
||
|
||
## Documentation | ||
|
||
<p align="center"> | ||
<a href="https://laralum.com/docs/routes"><img height="120" src="http://i.imgur.com/47WnADd.png"></a> | ||
</p> | ||
|
||
## License | ||
|
||
``` | ||
MIT License | ||
Copyright (c) 2017 Laralum | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "laralum/routes", | ||
"description": "Routes module for laralum", | ||
"require": { | ||
"laralum/laralum": "1.*" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Erik Campobadal", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Aitor Riba", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Krishan König", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Laralum\\Routes\\": "./src" | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Laralum\Routes\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Router; | ||
use Laralum\Routes\Models\Route; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Routing\Route as BaseRoute; | ||
|
||
class RoutesController extends Controller | ||
{ | ||
/** | ||
* The router instance. | ||
* | ||
* @var \Illuminate\Routing\Router | ||
*/ | ||
protected $router; | ||
|
||
/** | ||
* An array of all the registered routes. | ||
* | ||
* @var \Illuminate\Routing\RouteCollection | ||
*/ | ||
protected $routes; | ||
|
||
/** | ||
* Routes Facade constructor. | ||
*/ | ||
public function __construct(Router $router) | ||
{ | ||
$this->router = $router; | ||
$this->routes = $router->getRoutes(); | ||
} | ||
|
||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function routes() | ||
{ | ||
collect($this->routes)->map(function ($route) { | ||
dd($route->getName()); | ||
})->all(); | ||
|
||
return view('laralum_routes::routes', ['routes' => $routes]); | ||
} | ||
|
||
/** | ||
* Compile the routes into a displayable format. | ||
* | ||
* @return array | ||
*/ | ||
public function getAll() | ||
{ | ||
$routes = collect($this->routes)->map(function ($route) { | ||
return $this->getRouteInformation($route); | ||
})->all(); | ||
|
||
return array_filter($routes); | ||
} | ||
|
||
/** | ||
* Get the route information for a given route. | ||
* | ||
* @param \Illuminate\Routing\Route $route | ||
* @return array | ||
*/ | ||
public function getRouteInformation(BaseRoute $route) | ||
{ | ||
return [ | ||
'host' => $route->domain(), | ||
'method' => implode('|', $route->methods()), | ||
'uri' => $route->uri(), | ||
'name' => $route->getName(), | ||
'action' => $route->getActionName(), | ||
'middleware' => $this->getRouteMiddleware($route), | ||
]; | ||
} | ||
|
||
/** | ||
* Get before filters. | ||
* | ||
* @param \Illuminate\Routing\Route $route | ||
* @return string | ||
*/ | ||
public function getRouteMiddleware($route) | ||
{ | ||
return collect($route->gatherMiddleware())->map(function ($middleware) { | ||
return $middleware instanceof Closure ? 'Closure' : $middleware; | ||
})->implode(','); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"permission" : "laralum::routes.access", | ||
"trans": "laralum_routes::general.routes", | ||
"route": "laralum::routes.index" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Laralum\Routes\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Route extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Laralum\Routes\Policies; | ||
|
||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
use Laralum\Users\Models\User; | ||
|
||
class RoutePolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Filters the authoritzation. | ||
* | ||
* @param mixed $user | ||
* @param mixed $ability | ||
*/ | ||
public function before($user, $ability) | ||
{ | ||
if (User::findOrFail($user->id)->superAdmin()) { | ||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Determine if the current user can access statistics moule. | ||
* | ||
* @param mixed $user | ||
* | ||
* @return bool | ||
*/ | ||
public function access($user) | ||
{ | ||
return User::findOrFail($user->id)->hasPermission('laralum::routes.access'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
Route::group([ | ||
'middleware' => [ | ||
'web', 'laralum.base', 'laralum.auth', | ||
// 'can:access,Laralum\Routes\Models\Route', | ||
], | ||
'prefix' => config('laralum.settings.base_url'), | ||
'namespace' => 'Laralum\Routes\Controllers', | ||
'as' => 'laralum::routes.', | ||
], function () { | ||
Route::get('routes', 'RoutesController@routes')->name('index'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Laralum\Routes; | ||
|
||
use Laralum\CRUD\Models\Route; | ||
use Illuminate\Support\Facades\Gate; | ||
use Laralum\CRUD\Policies\RoutePolicy; | ||
use Illuminate\Support\ServiceProvider; | ||
use Laralum\Permissions\PermissionsChecker; | ||
|
||
class RoutesServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The policy mappings for the application. | ||
* | ||
* @var array | ||
*/ | ||
protected $policies = [ | ||
Route::class => RoutePolicy::class, | ||
]; | ||
|
||
/** | ||
* The mandatory permissions for the module. | ||
* | ||
* @var array | ||
*/ | ||
protected $permissions = [ | ||
[ | ||
'name' => 'Routes Access', | ||
'slug' => 'laralum::routes.access', | ||
'desc' => 'Grants access to laralum/Routes module', | ||
], | ||
]; | ||
|
||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
$this->loadViewsFrom(__DIR__.'/Views', 'laralum_routes'); | ||
$this->loadTranslationsFrom(__DIR__.'/Translations', 'laralum_routes'); | ||
|
||
if (!$this->app->routesAreCached()) { | ||
require __DIR__.'/Routes/web.php'; | ||
} | ||
|
||
// Make sure the permissions are OK | ||
PermissionsChecker::check($this->permissions); | ||
} | ||
|
||
/** | ||
* I cheated this comes from the AuthServiceProvider extended by the App\Providers\AuthServiceProvider. | ||
* | ||
* Register the application's policies. | ||
* | ||
* @return void | ||
*/ | ||
public function registerPolicies() | ||
{ | ||
foreach ($this->policies as $key => $value) { | ||
Gate::policy($key, $value); | ||
} | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Routes Language Lines | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
'home' => 'Inici', | ||
'name' => 'Nom', | ||
'routes' => 'Rutes', | ||
'routes_desc' => 'Veure rutes d\'aplicacions', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| CRUD Language Lines | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
'home' => 'Home', | ||
'name' => 'Name', | ||
'routes' => 'Routen', | ||
'routes_desc' => 'Anzeigen der App Routen', | ||
]; |
Oops, something went wrong.