本文整理汇总了PHP中Route::group方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::group方法的具体用法?PHP Route::group怎么用?PHP Route::group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::group方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: returnRoutes
public static function returnRoutes()
{
$class = __CLASS__;
Route::group(array('before' => 'auth', 'prefix' => 'admin'), function () use($class) {
Route::resource('questions', $class, array('except' => array('show'), 'names' => array('index' => 'questions.index', 'create' => 'questions.create', 'store' => 'questions.store', 'edit' => 'questions.edit', 'update' => 'questions.update', 'destroy' => 'questions.destroy')));
});
}
示例2: expose
/**
* Enable REST routes to expose a resource.
*
* Example:
* <code>
* // Create a new '/bucket' route group.
* REST::expose('bucket',[
* 'create' => function(){ echo "New bucket"; },
* 'read' => function($id){ echo "SHOW bucket($id)"; },
* 'update' => function($id){ echo "MODIFY bucket($id)"; },
* 'delete' => function($id){ echo "DELETE bucket($id)"; },
* 'list' => function(){ echo "All buckets"; },
* 'clear' => function(){ echo "Cleared all buckets"; },
* ]);
*
*
*
* Route::group('/non_conventional_/route/base',function(){
* // Create directly the REST routes (for use inside another parent group).
* REST::expose([
* 'create' => function(){ echo "New bucket"; },
* 'read' => function($id){ echo "SHOW bucket($id)"; },
* 'update' => function($id){ echo "MODIFY bucket($id)"; },
* 'delete' => function($id){ echo "DELETE bucket($id)"; },
* 'list' => function(){ echo "All buckets"; },
* 'clear' => function(){ echo "Cleared all buckets"; },
* ]);
* });
*
* </code>
*
* @param string $element The resource name.
* @param array $maps A map of actions callbacks for different CRUD actions.
*/
public static function expose($element, array $maps = null)
{
if (null === $maps && is_array($element)) {
$maps = $element;
$collection = '';
} else {
$collection = '/' . $element;
}
return Route::group($collection, function () use($maps) {
$actions = [];
if (isset($maps['list'])) {
$actions['get'] = $maps['list'];
}
if (isset($maps['create'])) {
$actions['post'] = $maps['create'];
}
if (isset($maps['clear'])) {
$actions['delete'] = $maps['clear'];
}
Route::map('/', $actions);
$actions = [];
if (isset($maps['read'])) {
$actions['get'] = $maps['read'];
}
if (isset($maps['update'])) {
$actions['put'] = $maps['update'];
}
if (isset($maps['delete'])) {
$actions['delete'] = $maps['delete'];
}
Route::map("/:id", $actions);
});
}
示例3: returnRoutes
public static function returnRoutes($prefix = null)
{
$dics_for_cache = ['projects', 'types'];
foreach ($dics_for_cache as $dic_name) {
## Refresh dics cache
#Cache::forget('dic_' . $dic_name);
$dic_[$dic_name] = Cache::get('dic_' . $dic_name);
if (!$dic_[$dic_name]) {
Cache::forget('dic_' . $dic_name);
$dic_[$dic_name] = Dic::valuesBySlug($dic_name, function ($query) {
$query->orderBy('lft', 'ASC');
}, ['allfields', 'alltextfields'], true, true, true);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
$dic_[$dic_name] = DicLib::loadImages($dic_[$dic_name], ['avatar', 'image', 'logo', 'photo', 'header_img']);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
Cache::add('dic_' . $dic_name, $dic_[$dic_name], self::$global_cache_min);
}
View::share('dic_' . $dic_name, $dic_[$dic_name]);
#Helper::d($dic_name); Helper::ta($dic_{$dic_name});
}
#Helper::tad($dic_{'city'});
#die;
Route::group(array('prefix' => '{lang}'), function () {
Route::any('/project/{slug}', array('as' => 'app.project', 'uses' => __CLASS__ . '@appProject'));
#Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
#Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
});
Route::group(array(), function () {
#Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
#Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
});
}
示例4: returnRoutes
public static function returnRoutes()
{
$class = __CLASS__;
Route::group(array('prefix' => 'api'), function () use($class) {
Route::any('debug/{method}', array('uses' => $class . '@debug'));
});
}
示例5: returnRoutes
public static function returnRoutes()
{
$class = __CLASS__;
Route::group(array('before' => 'guest', 'prefix' => ''), function () use($class) {
Route::post('social-signin', array('as' => 'signin.ulogin', 'uses' => $class . '@postUlogin'));
});
}
示例6: routes
function routes($config)
{
// only mess with the cms
Route::group(['prefix' => $config['cms_path'], 'middleware' => ['cms.language', 'cms.view']], function () use($config) {
Route::group(['namespace' => '\\Thorazine\\Cms\\Http\\Controllers'], function () use($config) {
// pickup on first contact
Route::get('/', ['as' => 'cms.auth.first', 'uses' => 'AuthController@first']);
Route::post('/', ['as' => 'cms.auth.first.create', 'uses' => 'AuthController@create']);
// auth
Route::post('/login/submit', ['as' => 'cms.auth.check', 'before' => 'csrf', 'uses' => 'AuthController@check']);
Route::get('/login', ['as' => 'cms.auth.login', 'uses' => 'AuthController@index']);
// All routes that do require auth
Route::group(['middleware' => ['cms.auth']], function () use($config) {
// logout
Route::get('/logout', ['as' => 'cms.auth.logout', 'uses' => 'AuthController@destroy']);
// cms home
Route::get('/base', ['as' => 'cms.base', 'uses' => 'CmsController@index']);
// flexible auth routes
Route::group(['middleware' => ['cms.model']], function () use($config) {
// flexible restfull routes
Route::get('/{module}/{model}/index', ['as' => 'module.model.index', 'uses' => 'PreController@index']);
Route::get('/{module}/{model}/create', ['as' => 'module.model.create', 'uses' => 'PreController@create']);
Route::post('/{module}/{model}/store', ['as' => 'module.model.store', 'uses' => 'PreController@store']);
Route::get('/{module}/{model}/show/{id}', ['as' => 'module.model.show', 'uses' => 'PreController@show']);
Route::get('/{module}/{model}/edit/{id}', ['as' => 'module.model.edit', 'uses' => 'PreController@edit']);
Route::put('/{module}/{model}/update/{id}', ['as' => 'module.model.update', 'uses' => 'PreController@update']);
Route::delete('/{module}/{model}/destroy/{id}', ['as' => 'module.model.destroy', 'uses' => 'PreController@destroy']);
Route::post('/{module}/{model}/order', ['as' => 'module.model.order', 'uses' => 'PreController@order']);
Route::get('/{module}/{model}/{action}', ['as' => 'module.model.action', 'uses' => 'PreController@custom']);
});
});
});
});
}
示例7: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('kkstudio/blog');
\Route::get('blog', '\\Kkstudio\\Blog\\Controllers\\BlogController@index');
\Route::get('blog/category/{slug}', '\\Kkstudio\\Blog\\Controllers\\BlogController@fromCategory');
\Route::get('blog/{slug}', '\\Kkstudio\\Blog\\Controllers\\BlogController@show');
\Route::group(['prefix' => 'admin', 'before' => 'admin'], function () {
\Route::get('blog', '\\Kkstudio\\Blog\\Controllers\\BlogController@admin');
\Route::get('blog/create', '\\Kkstudio\\Blog\\Controllers\\BlogController@create');
\Route::post('blog/create', '\\Kkstudio\\Blog\\Controllers\\BlogController@postCreate');
\Route::get('blog/{slug}/edit', '\\Kkstudio\\Blog\\Controllers\\BlogController@edit');
\Route::post('blog/{slug}/edit', '\\Kkstudio\\Blog\\Controllers\\BlogController@postEdit');
\Route::get('blog/{slug}/delete', '\\Kkstudio\\Blog\\Controllers\\BlogController@delete');
\Route::post('blog/{slug}/delete', '\\Kkstudio\\Blog\\Controllers\\BlogController@postDelete');
// Categories
\Route::get('blog/categories', '\\Kkstudio\\Blog\\Controllers\\BlogController@categories');
\Route::get('blog/categories/create', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_create');
\Route::post('blog/categories/create', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_postCreate');
\Route::get('blog/categories/{slug}/edit', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_edit');
\Route::post('blog/categories/{slug}/edit', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_postEdit');
\Route::get('blog/categories/{slug}/delete', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_delete');
\Route::post('blog/categories/{slug}/delete', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_postDelete');
\Route::post('blog/categories/swap', '\\Kkstudio\\Blog\\Controllers\\BlogController@category_swap');
});
}
示例8: init
/**
* 初始化应用
*/
public static function init()
{
//加载应用组配置
if (IS_GROUP) {
is_file(COMMON_CONFIG_PATH . 'config.php') and C(require COMMON_CONFIG_PATH . 'config.php');
is_file(COMMON_CONFIG_PATH . 'event.php') and C('GROUP_EVENT', require COMMON_CONFIG_PATH . 'event.php');
is_file(COMMON_CONFIG_PATH . 'alias.php') and alias_import(COMMON_CONFIG_PATH . 'alias.php');
is_file(COMMON_LANGUAGE_PATH . C('LANGUAGE') . '.php') and L(require COMMON_LANGUAGE_PATH . C('LANGUAGE') . '.php');
}
IS_GROUP and Route::group();
defined('GROUP_NAME') or define('GROUP_NAME', isset($_GET[C('VAR_GROUP')]) && !empty($_GET[C('VAR_GROUP')]) ? $_GET[C('VAR_GROUP')] : C('DEFAULT_GROUP'));
defined('APP') or define('APP', ucfirst(IS_GROUP ? $_GET[C('VAR_APP')] : basename(substr(APP_PATH, 0, -1))));
IS_GROUP and define('APP_PATH', GROUP_PATH . GROUP_NAME . '/' . APP . '/');
//常量
defined('CONTROL_PATH') or define('CONTROL_PATH', APP_PATH . 'Control/');
defined('MODEL_PATH') or define('MODEL_PATH', APP_PATH . 'Model/');
defined('CONFIG_PATH') or define('CONFIG_PATH', APP_PATH . 'Config/');
defined('EVENT_PATH') or define('EVENT_PATH', APP_PATH . 'Event/');
defined('LANGUAGE_PATH') or define('LANGUAGE_PATH', APP_PATH . 'Language/');
defined('TAG_PATH') or define('TAG_PATH', APP_PATH . 'Tag/');
defined('LIB_PATH') or define('LIB_PATH', APP_PATH . 'Lib/');
defined('COMPILE_PATH') or define('COMPILE_PATH', TEMP_PATH . (IS_GROUP ? GROUP_NAME . '/' . APP . '/Compile/' : 'Compile/'));
defined('CACHE_PATH') or define('CACHE_PATH', TEMP_PATH . (IS_GROUP ? GROUP_NAME . '/' . APP . '/Cache/' : 'Cache/'));
defined('TABLE_PATH') or define('TABLE_PATH', TEMP_PATH . (IS_GROUP ? GROUP_NAME . '/' . APP . '/Table/' : 'Table/'));
defined('LOG_PATH') or define('LOG_PATH', TEMP_PATH . 'Log/');
//应用配置
is_file(CONFIG_PATH . 'config.php') and C(require CONFIG_PATH . 'config.php');
is_file(CONFIG_PATH . 'event.php') and C('APP_EVENT', require CONFIG_PATH . 'event.php');
is_file(CONFIG_PATH . 'alias.php') and alias_import(CONFIG_PATH . 'alias.php');
is_file(LANGUAGE_PATH . C('LANGUAGE') . '.php') and L(require LANGUAGE_PATH . C('LANGUAGE') . '.php');
//模板目录
$tpl_style = C('TPL_STYLE');
if ($tpl_style and substr($tpl_style, -1) != '/') {
$tpl_style .= '/';
}
defined('TPL_PATH') or define('TPL_PATH', (C('TPL_PATH') ? C('TPL_PATH') : APP_PATH . 'Tpl/') . $tpl_style);
defined('PUBLIC_PATH') or define('PUBLIC_PATH', TPL_PATH . 'Public/');
//应用url解析并创建常量
Route::app();
//=========================环境配置
date_default_timezone_set(C('DEFAULT_TIME_ZONE'));
@ini_set('memory_limit', '128M');
@ini_set('register_globals', 'off');
@ini_set('magic_quotes_runtime', 0);
define('NOW', $_SERVER['REQUEST_TIME']);
define('NOW_MICROTIME', microtime(true));
define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
define('IS_AJAX', ajax_request());
define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
define('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
//注册自动载入函数
spl_autoload_register(array(__CLASS__, 'autoload'));
set_error_handler(array(__CLASS__, 'error'), E_ALL);
set_exception_handler(array(__CLASS__, 'exception'));
register_shutdown_function(array(__CLASS__, 'fatalError'));
HDPHP::_appAutoLoad();
}
示例9: boot
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('kkstudio/info');
\Route::group(['before' => 'admin'], function () {
\Route::get('admin/info', '\\Kkstudio\\Info\\Controllers\\InfoController@admin');
\Route::post('admin/info', '\\Kkstudio\\Info\\Controllers\\InfoController@edit');
});
}
示例10: createRouteAdmin
protected function createRouteAdmin()
{
Route::group(['middleware' => ['web', 'auth']], function () {
Route::get('/admin/test', function () {
return 'Admin Test!';
});
});
}
示例11: returnRoutes
public static function returnRoutes($prefix = null)
{
$class = __CLASS__;
Route::group(array('before' => 'auth', 'prefix' => $prefix), function () use($class) {
$entity = $class::$entity;
Route::resource($class::$group, $class, array('except' => array('show'), 'names' => array('index' => $entity . '.index', 'create' => $entity . '.create', 'store' => $entity . '.store', 'edit' => $entity . '.edit', 'update' => $entity . '.update', 'destroy' => $entity . '.destroy')));
});
}
示例12: createRoute
protected function createRoute()
{
Route::group(['middleware' => ['web']], function () {
Route::get('/email/registration', function () {
return view('email.registration', ['username' => 'test@test.com', 'password' => '123456']);
});
});
}
示例13: defineRoutes
/**
* Load Easel specific routes.
*/
private function defineRoutes()
{
if (!$this->app->routesAreCached()) {
\Route::group(['namespace' => 'Easel\\Http\\Controllers'], function ($router) {
require EASEL_BASE_PATH . '/src/Http/routes.php';
});
}
}
示例14: createApplication
public function createApplication()
{
$app = parent::createApplication();
Route::group(['namespace' => 'AblaFahita\\Http\\Controllers'], function () {
require app_path() . '/Http/routes/api.php';
});
return $app;
}
示例15: returnRoutes
public static function returnRoutes()
{
$class = __CLASS__;
if (Auth::check() && Auth::user()->group_id == 3) {
Route::group(array('before' => '', 'prefix' => 'admin'), function () use($class) {
Route::resource('participant-groups', $class, array('except' => array('show'), 'names' => array('index' => 'participant_group.index', 'create' => 'participant_group.create', 'store' => 'participant_group.store', 'edit' => 'participant_group.edit', 'update' => 'participant_group.update', 'destroy' => 'participant_group.destroy')));
});
}
}