我定义了以下路线:
Route::get('/tours/{country_identifier}', ['as' => 'country', 'uses' => 'CountryController@index']);
现在我想使用
之类的东西链接到这个命名路线route('country')
填写{country_identifier}参数的,例如'/旅游/加拿大'。
我怎样才能实现这一目标?
答案 0 :(得分:3)
您可以将参数作为第二个参数传递:
import numpy as np
old_array = [ (3.0535400914168154, 0.371345899229, 0.312953794281, -0.0125231427371, 0.0),
(3.056684825749555, 0.373971853521, 0.313682391117, -0.0264543909236, 0.0),
(3.0598295600822953, 0.376861295611, 0.314535588286, -0.041169303628, 0.0)]
maxline = 20
# If you want fullfil extra dimension with NaN
arr = [(np.NAN,)*len(old_array[0])]*(maxline - len(old_array))
# If you want fullfil extra dimension with anything else
# arr = np.array([(ANYTHING_YOU_WANT,)*len(old_array[0])]*(maxline - old_array.size))
new_ = old_array + arr
print numpy.array(new_)
>>
[(3.0535400914168154, 0.371345899229, 0.312953794281, -0.0125231427371, 0.0), (3
.056684825749555, 0.373971853521, 0.313682391117, -0.0264543909236, 0.0), (3.059
8295600822953, 0.376861295611, 0.314535588286, -0.041169303628, 0.0), (nan, nan,
nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan
, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, na
n, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, n
an, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan,
nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan, nan, nan, nan, nan), (nan,
nan, nan, nan, nan), (nan, nan, nan, nan, nan)]
你可以看看documentation,那里有很多有用的例子:)
答案 1 :(得分:2)
从视图使用链接(假设您使用刀片)
<a href="{{ URL::route('country', array('country_identifier' => $var)) }}">$var</a>
答案 2 :(得分:1)
试试这个
route('country', array('country_identifier' => 'Canada'))
将加拿大&#39;作为参数进行路由。
答案 3 :(得分:1)
简单:
单个链接
<a href="{{ route('country', ['country_identifier' => $country_id]) }}">$country_name</a>
如果您要生成一些链接,例如
@foreach($countries as $country)
<a href="{{ route('country', ['country_identifier' => $country->id]) }}">$country->name</a>
@endforeach
注意:$countries
是传递给视图示例$countries = Country::all()