Skip to content

Instantly share code, notes, and snippets.

@ferdiunal
Created April 1, 2016 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ferdiunal/1cc23d9e63ef0ad99532ee2dcecf75a4 to your computer and use it in GitHub Desktop.
Save ferdiunal/1cc23d9e63ef0ad99532ee2dcecf75a4 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: ferdiunal
* Date: 01.04.2016
* Time: 16:05
*/
namespace Libraries;
class Route2JSON
{
public function getRoutes()
{
$routes = \Route::getRoutes();
$router = [];
$group_title = null;
$title = null;
$ignore = ['verify'];
$tmp = [];
$current = \Route::currentRouteName();
$tmp_router = [];
$child = [];
foreach ($routes as $route) {
$name = $route->getName();
$action = $route->getAction();
if($name){
$app = explode('@',$name);
if(!in_array($app[0],$ignore) && !in_array($app[0],$tmp)){
if(!isset($action['group_title']) && isset($action['title'])){
$tmp_router[$app[0]][] = [
'title' => $action['title'],
'url' => url($name),
'isActive' => $name === $current
];
$router[$app[0]]['single'] = $tmp_router[$app[0]];
}
if(isset($action['group_title']) && isset($action['title'])){
$child[] = [
'title' => $action['title'],
'url' => url($name),
'isActive' => $name === $current
];
$router[$app[0]]['group'] = [
[
'title' => $action['group_title'],
'current' => $name === $current,
'child' => $child
]
];
}
}
}
}
return $router;
}
}
Route::group([ 'middleware' => 'guest','group_title' => 'Oturum' ],function(){
Route::group([ 'prefix' => 'giris-yap'],function(){
Route::get('/',['as' => 'auth@login','uses' => 'Login@index','title' => 'Giriş Yap']);
Route::post('/','Login@store');
Route::post('/pass_code','Login@pass_code');
});
Route::get('/sifre-sifirla',['as' => 'auth@reminder','uses' => 'Reminder@index','title' => 'Şifreni mi unuttun ?']);
Route::post('/sifre-sifirla','Reminder@store');
Route::get('uye-ol', [ 'as' => 'auth@register', 'uses' => 'Register@index','title' => 'Üye ol']);
Route::post('uye-ol','Register@store');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment