具有多个域的Laravel路由在link_to_action函数中失败

时间:2015-02-22 16:59:51

标签: laravel routes laravel-5

我的routes.php如下:

<?php
$approutes =function (){

    Route::group(['middleware' => 'auth'], function(){
        Route::get('/', 'AdminController@index');
        Route::get('profile/{user}','ProfileController@index');    
        Route::post('profile/{user}/update',array('as' => 'profile.update','uses' => 'ProfileController@update'));    
        Route::resource('posts','PostsController');    
        Route::resource('tags','TagsController');    
        Route::resource('health','HealthController');    
        Route::resource('health-categories','HealthCategoriesController');
    });

    Route::controllers([
        'auth' => 'Auth\AuthController',
        'password' => 'Auth\PasswordController'
    ]);
};

$siteroutes =function (){
    Route::get('/', 'SiteController@index');
};

Route::group(['domain' => 'my.xxxx.com'],$approutes);
Route::group(['domain' => 'my.xxxx.dev'],$approutes);

Route::group(['domain' => 'www.xxxx.com'],$siteroutes);
Route::group(['domain' => 'www.xxxx.dev'],$siteroutes);

在我的开发.dev域中,没关系。

但是当我试图将它放在.com域中时,来自link_to_action的所有引用(可能来自其他所有路由函数)都默认为.dev域。

我无法弄清楚发生了什么。

1 个答案:

答案 0 :(得分:0)

如果您想支持多域,请使用以下代码:

moving_fun <- function(x, w, FUN, ...) {
  # x: a double vector
  # w: the length of the window, i.e., the section of the vector selected to apply FUN
  # FUN: a function that takes a vector and return a summarize value, e.g., mean, sum, etc.
  # Given a double type vector apply a FUN over a moving window from left to the right, 
  #    when a window boundary is not a legal section, i.e. lower_bound and i (upper bound) 
  #    are not contained in the length of the vector, return a NA_real_
  if (w < 1) {
    stop("The length of the window 'w' must be greater than 0")
  }
  output <- x
  for (i in 1:length(x)) {
     # plus 1 because the index is inclusive with the upper_bound 'i'
    lower_bound <- i - w + 1
    if (lower_bound < 1) {
      output[i] <- NA_real_
    } else {
      output[i] <- FUN(x[lower_bound:i, ...])
    }
  }
  output
}

# example
v <- seq(1:10)

# compute a MA(2)
moving_fun(v, 2, mean)

# compute moving sum of two periods
moving_fun(v, 2, sum)

示例:

ln -s ~/Projects/directory  ~/.valet/Sites/domain_name

并更改路径文件:

ln -s ~/Projects/laravel  ~/.valet/Sites/taylor

在此项目中,项目名称为 laravel ,主域名为 laravel.app ,而泰勒域名为 taylor.app

注意:我不使用.dev域名。如果您使用默认代客设置,您的域名为laravel.dev和taylor.dev。