当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::bind方法代码示例

本文整理汇总了PHP中Route::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::bind方法的具体用法?PHP Route::bind怎么用?PHP Route::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Route的用法示例。


在下文中一共展示了Route::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * 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();
     });
 }
开发者ID:becast,项目名称:GameReviewSite,代码行数:13,代码来源:RouteServiceProvider.php

示例2: boot

 /**
  * 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();
     });
 }
开发者ID:TraianAlex,项目名称:laravel52,代码行数:13,代码来源:RouteServiceProvider.php

示例3: boot

 /**
  * 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();
     });
 }
开发者ID:kpaxer,项目名称:shcms,代码行数:13,代码来源:RouteServiceProvider.php

示例4: build

 /**
  * 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;
 }
开发者ID:cokeboL,项目名称:think,代码行数:69,代码来源:Url.php

示例5: testNamedRouteWithParameters

 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');
 }
开发者ID:cnlisai,项目名称:laravel-breadcrumbs,代码行数:11,代码来源:CurrentRouteTest.php

示例6: boot

 /**
  * 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();
     });
 }
开发者ID:getacked,项目名称:project,代码行数:23,代码来源:RouteServiceProvider.php

示例7: function

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');
开发者ID:nowarena,项目名称:homestead,代码行数:31,代码来源:routes.php

示例8: function

<?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');
});
开发者ID:aaronbullard,项目名称:litmus,代码行数:15,代码来源:palettes.php

示例9: function

            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;
});
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:31,代码来源:routes.php

示例10: function

|
| 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
开发者ID:saileshgc,项目名称:lyricsSite,代码行数:31,代码来源:routes.php

示例11: function

         * =================================================================================
         * 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');
    });
});
开发者ID:Yismen,项目名称:solpieles,代码行数:31,代码来源:routes.php

示例12: function

<?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');
开发者ID:jacek-9999,项目名称:callcenter,代码行数:25,代码来源:routes.php

示例13: function

|
| 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 -------------------
开发者ID:TeamAppEngine,项目名称:adraaf.server,代码行数:32,代码来源:routes.php

示例14: function

<?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');
});
开发者ID:mrkodssldrf,项目名称:TypiCMS,代码行数:25,代码来源:routes.php

示例15: function

    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')]);
});
开发者ID:sonico999,项目名称:Multitenant-Apps-in-Laravel,代码行数:31,代码来源:routes.php


注:本文中的Route::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。