bind() public static method

Add a new route parameter binder.
public static bind ( string $key, string | callable $binder ) : void
$key string
$binder string | callable
return void
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     \Route::bind('articleslug', function ($value) {
         return \App\Article::where('slug', $value)->with('user')->with('writer')->with('screenshot.image')->firstOrFail();
     });
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     \Route::bind('user', function ($username) {
         return \App\User::where('username', $username)->firstOrFail();
     });
 }
示例#3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     \Route::bind('category', function ($value) {
         return \App\Model\Option::where('id', $value)->first();
     });
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     // Custom binding of the 'username' wildcard to the Users username
     \Route::bind('username', function ($username) {
         return \App\User::where('username', $username)->firstOrFail();
     });
 }
示例#5
0
文件: Url.php 项目: cokeboL/think
 /**
  * URL生成 支持路由反射
  * @param string $url URL表达式,
  * 格式:'[模块/控制器/操作]?参数1=值1&参数2=值2...'
  * @控制器/操作?参数1=值1&参数2=值2...
  * \\命名空间类\\方法?参数1=值1&参数2=值2...
  * @param string|array $vars 传入的参数,支持数组和字符串
  * @param string $suffix 伪静态后缀,默认为true表示获取配置值
  * @param boolean|string $domain 是否显示域名 或者直接传入域名
  * @return string
  */
 public static function build($url = '', $vars = '', $suffix = true, $domain = true)
 {
     // 解析参数
     if (is_string($vars)) {
         // aaa=1&bbb=2 转换成数组
         parse_str($vars, $vars);
     }
     if (strpos($url, '?')) {
         list($url, $params) = explode('?', $url);
         parse_str($params, $params);
         $vars = array_merge($params, $vars);
     }
     // 获取路由别名
     $alias = self::getRouteAlias();
     // 检测路由
     if (0 !== strpos($url, '/') && isset($alias[$url]) && ($match = self::getRouteUrl($alias[$url], $vars))) {
         // 处理路由规则中的特殊字符
         $url = str_replace('[--think--]', '', $match);
     } else {
         // 路由不存在 直接解析
         $url = self::parseUrl($url);
     }
     // 检测URL绑定
     $type = Route::bind('type');
     if ($type) {
         $bind = Route::bind($type);
         if (0 === strpos($url, $bind)) {
             $url = substr($url, strlen($bind) + 1);
         }
     }
     // 还原URL分隔符
     $depr = Config::get('pathinfo_depr');
     $url = str_replace('/', $depr, $url);
     // URL后缀
     $suffix = self::parseSuffix($suffix);
     // 参数组装
     if (!empty($vars)) {
         // 添加参数
         if (Config::get('url_common_param')) {
             $vars = urldecode(http_build_query($vars));
             $url .= $suffix . '?' . $vars;
         } else {
             foreach ($vars as $var => $val) {
                 if ('' !== trim($val)) {
                     $url .= $depr . $var . $depr . urlencode($val);
                 }
             }
             $url .= $suffix;
         }
     } else {
         $url .= $suffix;
     }
     // 检测域名
     $domain = self::parseDomain($url, $domain);
     // URL组装
     $url = $domain . Config::get('base_url') . '/' . $url;
     return $url;
 }
 public function testNamedRouteWithParameters()
 {
     $object = new stdClass();
     Route::bind('object', function () use($object) {
         return $object;
     });
     Route::get('/sample/{text}/{object}', ['as' => 'sampleroute', function () use($object) {
         $this->assertSame(['sampleroute', ['blah', $object]], $this->currentRoute->get());
     }]);
     $this->call('GET', '/sample/blah/object');
 }
示例#7
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->model('tag', 'App\\Tag');
     // $router->bind('user', function($id) {
     //     return App\User::where('id', $id)->firstOrFail();
     // });
     // \Route::bind('user', function(User $user) {
     //     return $user;
     // });
     \Route::bind('user', function ($id) {
         return User::where('id', $id)->firstOrFail();
     });
     \Route::bind('event', function ($id) {
         return Event::where('id', $id)->firstOrFail();
     });
 }
示例#8
0
Route::get('twitter/getfeed', 'TwitterController@getfeed');
Route::get('instagram/getfriends', 'InstagramController@getfriends');
Route::get('instagram/getfeed', 'InstagramController@getfeed');
Route::get('yelp/getfeed', 'YelpController@getfeed');
Route::get('login/{provider?}', 'Auth\\AuthController@login');
Route::group(['middleware' => 'auth'], function () {
    Route::any("admin", array('as' => 'admin', 'uses' => "AdminController@index"));
    Route::get('members/create', 'MembersController@create');
    Route::get('members/{slug}', 'MembersController@index');
    Route::resource('members', 'MembersController');
    Route::resource('links', 'LinksController');
    Route::post('links/sort', 'LinksController@sort');
    Route::bind('members', function ($value, $route) {
        $ent = new App\MemberEntity();
        return $ent->getMemberDB($value);
    });
    Route::post('categories/sort', 'CategoriesController@sort');
    Route::bind('categories', function ($slug, $route) {
        // pass category to social media controller
        // members in the category and their social media can subsequently
        // be retrieved via social media model or social media controller
        return App\Category::whereSlug($slug)->first();
    });
    Route::resource('categories', 'CategoriesController');
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::resource('twitter', 'TwitterController');
Route::resource('instagram', 'InstagramController');
Route::get('socialmedia/getmembersocialmedia', 'SocialMediaController@getmembersocialmedia');
Route::get('socialmedia/{slug}', 'SocialMediaController@index');
Route::get('socialmedia', 'SocialMediaController@categorylist');
示例#9
0
<?php

Route::model('colors', 'Color');
Route::bind('palettes', function ($value, $route) {
    $palette = Palette::find($value);
    $account = $palette->account;
    if (Auth::user()->accounts()->whereAccountId($account->id)->count()) {
        return Palette::find($value);
    }
    return App::abort(404);
});
Route::group(['before' => "auth"], function () {
    Route::resource('palettes', 'PalettesController');
    Route::resource('palettes/{palettes}/colors', 'ColorsController');
});
            Route::get('category-analytics', ['as' => 'get_category-analytics', 'before' => ['has_perm:admin,_view-analytics'], 'uses' => 'AdminAnalyticsController@showCategoryAnalytics']);
            Route::get('admin-analytics', ['as' => 'get_admin-analytics', 'before' => ['has_perm:admin,_view-analytics'], 'uses' => 'AdminAnalyticsController@showAdminAnalytics']);
            Route::get('my-category-analytics', ['as' => 'get_my-category-analytics', 'before' => ['has_perm:admin,_view-analytics,_view-own-analytics'], 'uses' => 'AdminAnalyticsController@showMyCategoryAnalytics']);
            Route::get('my-products/{page?}', ['as' => 'get_my-products', 'before' => ['has_perm:admin,_load-product-via-id,_load-product-via-idea'], 'uses' => 'AdminProductController@showAdminProducts']);
        });
    }
});
/*
|--------------------------------------------------------------------------
| Route Bindings
|--------------------------------------------------------------------------
*/
Route::bind('product_id', function ($value, $route) {
    $decoded = Hashids::decode($value);
    //if the product id wasn't decodable, abort
    if (!isset($decoded[0])) {
        \App::abort(404);
    }
    return $decoded[0];
});
Route::bind('product_id_sales_agent_user_id', function ($value, $route) {
    $decoded = Hashids::decode($value);
    //if the product id wasn't decodable, abort
    if (!isset($decoded[0])) {
        \App::abort(404);
    }
    if (!isset($decoded[1])) {
        $decoded[1] = null;
    }
    return $decoded;
});
示例#11
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
//Route Model binding
Route::bind('artist', function ($id) {
    return App\artistModel::where('id', $id)->first();
});
Route::model('id', 'App\\artistModel');
//Pages Definition without a Route Resource
Route::get('/', ['as' => 'artist_home', 'uses' => 'PagesController@index']);
//Homepage
Route::get('/about', 'PagesController@about');
//About
Route::get('artist', 'PagesController@artist');
Route::get('/artist/create', 'PagesController@create');
Route::post('/artist/create', 'PagesController@store');
Route::get('/artist/{slug}', ['as' => 'artist_path', 'uses' => 'PagesController@showArtist']);
Route::get('/test/{artist}', 'PagesController@test');
//route model binding
Route::get('/test2/{id}', 'PagesController@test');
//route model binding
示例#12
0
         * =================================================================================
         * Roles
         */
        Route::get('roles/detatch_user/{user}/role/{role}', ['as' => 'admin.roles.detatch_user', 'uses' => 'RolesController@detatchUser']);
        Route::get('roles/search', ['as' => 'admin.roles.search', 'uses' => 'RolesController@search']);
        Route::bind('roles', function ($id) {
            return App\Role::with('users')->findOrFail($id);
        });
        Route::resource('roles', 'RolesController');
        /**
         * =============================================================
         * Todos
         */
        Route::get('todos/completar/{id}', ['as' => 'admin.todos.completar', 'uses' => 'TodosController@completar']);
        Route::get('todos/incompletar/{id}', ['as' => 'admin.todos.incompletar', 'uses' => 'TodosController@incompletar']);
        Route::delete('todos/remove_done_tasks', ['as' => 'admin.todos.remove_done_tasks', 'uses' => 'TodosController@removeDoneTasks']);
        Route::bind("todos", function ($id) {
            return \App\Todo::whereUserId(Auth::user()->id)->findOrFail($id);
        });
        Route::resource('todos', 'TodosController', []);
        /**
         * ==============================================================
         * Users Management
         */
        Route::get('users/search', ['as' => 'admin.users.search', 'uses' => 'UsersController@search']);
        Route::bind('users', function ($id) {
            return App\User::with('role')->findOrFail($id);
        });
        Route::resource('users', 'UsersController');
    });
});
示例#13
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return Redirect::action('StationsController@index');
});
Route::model('phones', 'Phone');
Route::model('stations', 'Station');
Route::bind('phones', function ($value, $route) {
    return App\Phone::whereSlug($value)->first();
});
Route::bind('stations', function ($value, $route) {
    return App\Station::whereSlug($value)->first();
});
Route::resource('stations', 'StationsController');
Route::resource('stations.phones', 'PhonesController');
示例#14
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::bind('uuid', function ($uuid) {
    $userModel = new \Repositories\UserRepository(new \App\User());
    return $userModel->getUserBasedOnUuid($uuid);
});
Route::bind('offer_id', function ($id) {
    $offerModel = new \Repositories\OfferRepository(new \App\Offer());
    return $offerModel->getOfferBasedOnId($id);
});
Route::bind('store_id', function ($id) {
    $storeModel = new \Repositories\StoreRepository(new \App\Store());
    return $storeModel->getStoreBasedOnId($id);
});
//caa126a6-b0b8-440c-8512-9c506264bf61
//Route::pattern('uuid','/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/');
//--------------------   V1  ---------------------
Route::post('api/users', 'UsersController@store');
Route::get('api/users/login_session', 'UsersController@getSession');
Route::get('api/users/offers', 'UsersController@getOffers');
Route::get('api/users/{uuid}/offers', 'UsersController@getOffers');
Route::get('api/users/offers', 'UsersController@getOffersAnonymously');
Route::post('api/users/{uuid}/share/{offer_id}', 'UsersController@logShare');
Route::post('api/users/{uuid}/save/{offer_id}', 'UsersController@logSave');
Route::post('api/users/{uuid}/buy/{offer_id}', 'UsersController@logBuy');
Route::get('api/users/{uuid}/saved_offers', 'UsersController@getSavedOffers');
Route::get('api/stores/{store_id}/image', 'UsersController@getImage');
//--------------------- Default -------------------
示例#15
0
<?php

Route::bind('news', function ($value, $route) {
    return TypiCMS\Modules\News\Models\News::where('id', $value)->with('translations')->firstOrFail();
});
if (!App::runningInConsole()) {
    Route::group(array('before' => 'visitor.publicAccess', 'namespace' => 'TypiCMS\\Modules\\News\\Controllers'), function () {
        $routes = app('TypiCMS.routes');
        foreach (Config::get('app.locales') as $lang) {
            if (isset($routes['news'][$lang])) {
                $uri = $routes['news'][$lang];
            } else {
                $uri = 'news';
                if (Config::get('app.locale_in_url')) {
                    $uri = $lang . '/' . $uri;
                }
            }
            Route::get($uri, array('as' => $lang . '.news', 'uses' => 'PublicController@index'));
            Route::get($uri . '/{slug}', array('as' => $lang . '.news.slug', 'uses' => 'PublicController@show'));
        }
    });
}
Route::group(array('namespace' => 'TypiCMS\\Modules\\News\\Controllers', 'prefix' => 'admin'), function () {
    Route::resource('news', 'AdminController');
});
    Route::get('sign-in', ['as' => 'sign-in', 'uses' => 'SessionsController@create']);
    Route::post('sign-in', ['as' => 'sign-in', 'uses' => 'SessionsController@store']);
    Route::get('sign-up', ['as' => 'sign-up', 'uses' => 'SignupsController@create']);
    Route::post('sign-up', ['as' => 'sign-up', 'uses' => 'SignupsController@store']);
});
Route::group(['domain' => 'toodoo.dev', 'before' => 'auth'], function () {
    Route::get('/', ['uses' => 'HomeController@show', 'as' => 'home']);
    Route::get('dashboard', ['uses' => 'HomeController@dashboard', 'as' => 'dashboard']);
    Route::delete('sign-out', ['as' => 'sign-out', 'uses' => 'SessionsController@destroy']);
});
Route::group(['domain' => '{organizations}.toodoo.dev', 'before' => 'auth|tenant'], function () {
    Route::get('/', ['uses' => 'OrganizationsController@show', 'as' => 'organizations.show']);
    Route::get('settings', ['uses' => 'OrganizationsController@edit', 'as' => 'settings']);
    Route::put('settings', ['uses' => 'OrganizationsController@update', 'as' => 'settings']);
    Route::bind('organizations', function ($value, $route) {
        return Organization::where('slug', $value)->firstOrFail();
    });
    Route::resource('todos', 'TodosController');
    // Will remove for manual routes maybe?
    Route::model('todos', 'Todo');
    Route::resource('users', 'UsersController');
    Route::model('users', 'User');
    Route::get('styles/organization-custom.css', function (Organization $org) {
        $response = Response::make(View::make('organizations.css', ['css' => $org->css]));
        $response->header('Content-Type', 'text/css');
        return $response;
    });
});
View::composer('shared._notifications', function ($view) {
    $view->with('flash', ['success' => Session::get('success'), 'error' => Session::get('error')]);
});
示例#17
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
Route::get('home', 'HomeController@index');
Route::resource('/contact', 'HomeController@contact');
route::resource('user', 'UsersController');
Route::get('profile', 'UsersController@showProfile');
Route::bind('users', function ($value, $route) {
    return App\User::whereId($value)->first();
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
示例#18
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('home', 'HomeController@index');
//atar todas las rutas a un controlador
// User dependency injection
Route::bind('user', function ($user) {
    return Hdeportes\User::find($user);
});
Route::bind('product', function ($slug) {
    return Hdeportes\Product::where('slug', $slug)->first();
});
/*Mails routes*/
Route::post('/mail', ['as' => 'sendMail', 'uses' => 'MailController@SendMail']);
/*FrontEnd app*/
Route::get('/404', 'FrontController@error');
Route::get('/500', function () {
    return view('errors.503');
});
Route::get('/', 'FrontController@index');
Route::get('/track', ['middleware' => ['auth', 'suscriptor', 'active'], 'uses' => 'FrontController@chanel']);
Route::get('/plan', ['uses' => 'FrontController@plan', 'as' => 'site.plan']);
Route::get('sing-in', ['uses' => 'FrontController@singIn', 'as' => 'site.singIn']);
Route::get('sing-up/{code_referrer?}', ['uses' => 'FrontController@singUp', 'as' => 'site.singUp']);
Route::get('shedule', ['uses' => 'FrontController@shedule', 'as' => 'site.shedule']);
/*Register and login(logout)*/
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::bind('ngo', function ($value) {
    return Ngo::where('user_id', $value)->first();
});
Route::bind('cause', function ($value) {
    return Cause::where('cause_id', $value)->first();
});
Route::bind('item', function ($value) {
    return Item::where('item_id', $value)->first();
});
Route::get('/', 'NgoController@index');
Route::get('/{ngo}', 'NgoController@ngoView');
Route::get('/cause/{cause}', 'NgoController@causeView');
Route::get('/causes/all', 'NgoController@viewAll');
Route::get('/{ngo}/contact-us', 'NgoController@contactView');
Route::post('/{ngo}/contact-us/message', 'NgoController@storeMessage');
Route::get('/auth/login', 'MyAuthController@getLogin');
// Route::get('/auth/login', 'MyAuthController@getLogin');
// Route::post('/auth/login', 'MyAuthController@postLogin');
Route::get('/auth/logout', 'MyAuthController@getLogout');
Route::post('/auth/login', 'MyAuthController@postLogin');
Route::get('/auth/register', 'MyAuthController@getRegister');
// Route::get('/auth/register', 'MyAuthController@getRegister');
Route::post('/auth/register', 'MyAuthController@postRegister');
示例#20
0
<?php

/**
 * ===========================================================
 * Contacts
 */
Route::get('contacts/search', ['as' => 'admin.contacts.search', 'uses' => 'ContactsController@search']);
Route::post('contacts/image/{id}', ['as' => 'admin.contacts.image', 'uses' => 'ContactsController@postImage']);
Route::bind('contacts', function ($id) {
    return App\Contact::findOrFail($id);
});
Route::resource('contacts', 'ContactsController', []);
示例#21
0
Route::controller('home', 'HomeController');
Route::controller('foto', 'FotoController');
Route::controller('ajax', 'AjaxController');
Route::controller('perfilcontroller', 'PerfilController');
Route::controller('comentario', 'ComentariosController');
Route::controller('quiz', 'QuizController');
Route::post('quimera', 'QuimeraController@quimera');
Route::post('clickbus/place', 'ClickBusController@autocompletePlace');
Route::post('clickbus/trip', 'ClickBusController@getTrip');
Route::post('clickbus/trips', 'ClickBusController@getTrips');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
/**
 * Aqui faço o tratamento para a prettyUrl, retornando um objeto da classe PrettyUrl
 */
Route::bind('prettyURL', function ($value, $route) {
    $prettyUrl = App\PrettyUrl::all()->where('url', $value)->first();
    return $prettyUrl;
});
/**
 * Aqui ficam as rotas que vao passar por autenticação. (filtro auth)
 */
Route::group(['before' => 'auth'], function () {
    Route::get('perfil', 'PerfilController@index');
    Route::get('editarPerfil', 'PerfilController@edit');
    Route::post('editarPerfil/{id}', 'PerfilController@update');
    Route::post('editarPerfilFoto/{id}', 'PerfilController@updatePhoto');
    Route::post('cropPhotoPerfil/{id}', 'PerfilController@cropPhoto');
    Route::post('cropPhotoOng/{id}', 'OngController@cropPhoto');
    Route::post('cropPhotoEmpresa/{id}', 'EmpresaController@cropPhoto');
    Route::post('cropPhotoPost/{id}', 'PostController@cropPhoto');
});
/**
示例#22
0
<?php

Route::bind('menulinks', function ($value) {
    return TypiCMS\Modules\Menulinks\Models\Menulink::where('id', $value)->with('translations')->firstOrFail();
});
Route::group(array('namespace' => 'TypiCMS\\Modules\\Menulinks\\Controllers', 'prefix' => 'admin'), function () {
    Route::resource('menus.menulinks', 'AdminController');
    Route::post('menulinks/sort', array('as' => 'admin.menulinks.sort', 'uses' => 'AdminController@sort'));
});
Route::group(array('prefix' => 'api'), function () {
    Route::resource('menulinks', 'TypiCMS\\Modules\\Menulinks\\Controllers\\ApiController');
});
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController'
]);
interface BarInterface{}
class Baz{}
class Bar implements BarInterface{}

    App::bind('BarInterface' , 'bar');
Route::get('bar', function(BarInterface $bar){
    dd($bar);
});

Route::get('foo', 'FooController@foo');

Route::get('apitest/twitter/{message}' , 'ApiTestController@twitter');

Route::resource('users','UserController');
Route::get('user/profile','MemberController@profile');
Route::put('user/profile','MemberController@saveprofile');
*/
Route::model('tasks', 'Task');
Route::model('projects', 'Project');
// Use slugs rather than IDs in URLs
Route::bind('tasks', function ($value, $route) {
    return App\Task::whereSlug($value)->first();
});
Route::bind('projects', function ($value, $route) {
    return App\Project::whereSlug($value)->first();
});
Route::resource('projects', 'ProjectsController');
Route::resource('projects.tasks', 'TasksController');
示例#24
0
文件: Url.php 项目: fjinb/think
 /**
  * URL组装 支持不同URL模式
  * @param string $url URL表达式,
  * 格式:'[模块/控制器/操作]?参数1=值1&参数2=值2...'
  * @控制器/操作?参数1=值1&参数2=值2...
  * \\命名空间类\\方法?参数1=值1&参数2=值2...
  * @param string|array $vars 传入的参数,支持数组和字符串
  * @param string $suffix 伪静态后缀,默认为true表示获取配置值
  * @param boolean $domain 是否显示域名
  * @return string
  */
 public static function build($url = '', $vars = '', $suffix = true, $domain = true)
 {
     // 检测是否存在路由别名
     if ($aliasUrl = Route::getRouteUrl($url, $vars)) {
         return $aliasUrl;
     }
     // 解析参数
     if (is_string($vars)) {
         // aaa=1&bbb=2 转换成数组
         parse_str($vars, $vars);
     } elseif (!is_array($vars)) {
         $vars = [];
     }
     if (strpos($url, '?')) {
         list($url, $params) = explode('?', $url);
         parse_str($params, $params);
         $vars = array_merge($params, $vars);
     }
     // 检测路由
     $match = self::checkRoute($url, $vars, $domain, $type);
     if (false === $match) {
         // 路由不存在 直接解析
         if (false !== strpos($url, '\\')) {
             // 解析到类
             $url = ltrim(str_replace('\\', '/', $url), '/');
         } elseif (0 === strpos($url, '@')) {
             // 解析到控制器
             $url = substr($url, 1);
         } else {
             // 解析到 模块/控制器/操作
             $path = explode('/', $url);
             $len = count($path);
             if (2 == $len) {
                 $url = (APP_MULTI_MODULE ? MODULE_NAME . '/' : '') . $url;
             } elseif (1 == $len) {
                 $url = (APP_MULTI_MODULE ? MODULE_NAME . '/' : '') . CONTROLLER_NAME . '/' . $url;
             }
         }
     } else {
         // 处理路由规则中的特殊内容
         $url = str_replace(['\\d', '$'], '', $match);
     }
     // 检测URL绑定
     $type = Route::bind('type');
     if ($type) {
         $bind = Route::bind($type);
         if (0 === strpos($url, $bind)) {
             $url = substr($url, strlen($bind) + 1);
         }
     }
     // 还原URL分隔符
     $depr = Config::get('pathinfo_depr');
     $url = str_replace('/', $depr, $url);
     // 替换变量
     $params = [];
     foreach ($vars as $key => $val) {
         if (false !== strpos($url, '[:' . $key . ']')) {
             $url = str_replace('[:' . $key . ']', $val, $url);
         } elseif (false !== strpos($url, ':' . $key)) {
             $url = str_replace(':' . $key, $val, $url);
         } else {
             $params[$key] = $val;
         }
     }
     // URL组装
     $url = Config::get('base_url') . '/' . $url;
     // URL后缀
     $suffix = self::parseSuffix($suffix);
     // 参数组装
     if (!empty($params)) {
         // 添加参数
         if (Config::get('url_common_param')) {
             $vars = urldecode(http_build_query($vars));
             $url .= $suffix . '?' . $vars;
         } else {
             foreach ($params as $var => $val) {
                 if ('' !== trim($val)) {
                     $url .= $depr . $var . $depr . urlencode($val);
                 }
             }
             $url .= $suffix;
         }
     } else {
         $url .= $suffix;
     }
     if ($domain) {
         if (true === $domain) {
             $domain = $_SERVER['HTTP_HOST'];
             if (Config::get('url_domain_deploy')) {
                 // 开启子域名部署
                 $domain = 'localhost' == $domain ? 'localhost' : 'www' . strstr($_SERVER['HTTP_HOST'], '.');
                 foreach (Route::domain() as $key => $rule) {
                     $rule = is_array($rule) ? $rule[0] : $rule;
                     if (false === strpos($key, '*') && 0 === strpos($url, $rule)) {
                         $domain = $key . strstr($domain, '.');
                         // 生成对应子域名
                         $url = substr_replace($url, '', 0, strlen($rule));
                         break;
                     }
                 }
             }
         }
         $url = (self::isSsl() ? 'https://' : 'http://') . $domain . $url;
     }
     return $url;
 }
示例#25
0
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
Route::get('home', ['as' => 'home', 'uses' => 'HomeController@index']);
// AUTH CONTROLLERS
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
// USER
Route::resource('user', 'UserController');
post('update/{user_id}/role', ['as' => 'update_role', 'uses' => 'UserController@updateRoles']);
// INFORMATION
Route::resource('information', 'InformationController', ['only' => ['store', 'update', 'index']]);
// FIELD
Route::bind('field', function ($id) {
    return App\Field::whereId($id)->first();
});
Route::resource('field', 'FieldController');
// SOA HISTORY
Route::group(['middleware' => 'auth'], function () {
    get('import/payment_history', ['as' => 'import_payment_history', 'uses' => 'InformationController@showImportPaymentHistory']);
    get('import/soa_history', ['as' => 'import_soa_history', 'uses' => 'InformationController@showImportSoaHistory']);
});
post('import_field/information', ['as' => 'importInformation', 'uses' => 'InformationController@importInformation']);
示例#26
0
文件: routes.php 项目: kokzilla/po
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::get('/portal', function () {
    return view('portal');
});
Route::get('/hr', function () {
    return view('hr.portal');
});
// Provide controller methods with object instead of ID
Route::model('jobapps', 'Jobapp');
Route::model('positions', 'Position');
Route::model('marriages', 'Marriage');
Route::resource('jobapps', 'JobappsController');
Route::resource('positions', 'PositionsController');
Route::resource('marriages', 'MarriageController');
Route::bind('jobapps', function ($value, $route) {
    return App\Models\Hr\Jobapp::whereJob_app_no($value)->first();
});
示例#27
0
文件: routes.php 项目: AcarMeel/store
|    							PRODUCTS DEPENDENCY INJECTION
==========================================================*/
Route::bind('product', function ($slug) {
    return App\Product::where('slug', $slug)->first();
});
/*==========================================================
|    							CATEGORY DEPENDENCY INJECTION
==========================================================*/
Route::bind('category', function ($category) {
    return App\Category::find($category);
});
/*==========================================================
|    							USER DEPENDENCY INJECTION
==========================================================*/
Route::bind('user', function ($user) {
    return App\User::find($user);
});
/*==========================================================
|  													HOME
==========================================================*/
Route::get('/', ['as' => 'home', 'uses' => 'StoreController@index']);
Route::get('product/{slug}', ['as' => 'product-detail', 'uses' => 'StoreController@show']);
/*
|-------------------------------------------------------------
|Carrito de compras
|-------------------------------------------------------------
*/
Route::get('cart/show', ['as' => 'cart-show', 'uses' => 'CartController@show']);
//utilizamos el metodo Route::bind
Route::get('cart/add/{product}', ['as' => 'cart-add', 'uses' => 'CartController@add']);
Route::get('cart/delete/{product}', ['as' => 'cart-delete', 'uses' => 'CartController@delete']);
示例#28
0
    return App\Models\Teacher::whereId($value)->first();
});
Route::bind('exams', function ($value, $route) {
    return App\Models\Exam::whereId($value)->first();
});
Route::bind('results', function ($value, $route) {
    return App\Models\Result::whereId($value)->first();
});
Route::bind('posts', function ($value, $route) {
    return App\Models\Post::whereId($value)->first();
});
Route::bind('comments', function ($value, $route) {
    return App\Models\Comment::whereId($value)->first();
});
Route::bind('admissions', function ($value, $route) {
    return App\Models\Admission::whereId($value)->first();
});
// Auth
Route::get('/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::controllers(['password' => 'Auth\\PasswordController']);
Route::get('admin', ['as' => 'admin', 'uses' => 'AdminController@index', 'middleware' => 'admin']);
// Admin APIs
Route::group(['prefix' => 'api', 'middleware' => 'admin'], function () {
    //File Resource Routes
    Route::resource('files', 'FileEntryController', ['except' => ['create', 'edit']]);
    Route::post('files/upload', 'FileEntryController@upload');
    Route::post('files/changevisibility/{files}', 'FileEntryController@changeVisibility');
    //Exam Resource Routes
    Route::resource('exams', 'ExamsController', ['except' => ['create', 'edit']]);
示例#29
0
<?php

Route::bind('category', function ($id) {
    $category = App\Models\Category::find($id);
    if (!$category) {
        abort(404);
    }
    return $category;
});
get('/categories', ['as' => 'categories', 'uses' => 'CategoryController@index']);
//routes to create a category
get('/category/create', ['as' => 'categoryCreate', 'uses' => 'CategoryController@create']);
post('/category/create', ['as' => 'categoryStore', 'uses' => 'CategoryController@store']);
//routes to update a category
get('/category/{category}/edit', ['as' => 'categoryEdit', 'uses' => 'CategoryController@edit']);
put('/category/{category}/edit', ['as' => 'categoryUpdate', 'uses' => 'CategoryController@update']);
//routes to delete a category
delete('/category/{category}/delete', ['as' => 'categoryDelete', 'uses' => 'CategoryController@destroy']);
示例#30
0
文件: routes.php 项目: EsthervdG/PACT
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
    //
});
//Route::get('start', 'Start@index');
//Route::get('/start/{name}', 'Start@show');
Route::get('blade', function () {
    return view('start');
});
Route::bind('patient', function ($patientName) {
    return App\Patient::where("name", $patientName)->first();
});
//Route::get('/questions/{patient}', array(
//    'as' => 'patientName',
//    'uses' => 'StartController@startQuestions'
//));
Route::get('/questions/{patient}/{questionNr}', array('as' => 'questionNr', 'uses' => 'QuestionController@questionHandler'));
Route::post('/questions/{patient}/{questionNr}', 'QuestionController@storeAnswer');
//Route::post('/questions/{patient}', 'QuestionController@storeAnswer');
Route::get('/start', 'StartController@newPatient');
Route::post('/start', 'StartController@storeName');
Route::get('/result/{patient}/{consultationType}', array('as' => 'result', 'uses' => 'QuestionController@result'));