2015-11-12 2 views
0

У меня есть некоторый код:Неправильные маршруты для зрения в Laravel 5

routes.php

Route::get('/countries/{country1}', [ 
    'uses' => '[email protected]', 
    'as' => 'edit1' 
    ]); 
Route::get('/countries', ['uses' => '[email protected]', 'as' => 'countries']); 

CountryController.php

public function editCountr($country1){ 
    $countries = Country::where('country','=', $country1); 
    return view('countryedit')->with('country1', $countries); 
} 

countries.blade.php

<a href="{{route('edit1')}}">{{$country->country}}</a> 

Итак, у меня есть проблема: Мои ссылки в странах.blade.php выглядит как http://localhost:8000/countries/%7Bcountry1%7D

Помогите мне, пожалуйста?

ответ

1

Сначала вы должны получить объект в вашем Conroller:

public function editCountr($country1){ 
    $countries = Country::where('country','=', $country1)->first(); 
    return view('countryedit')->with('country1', $countries); 
} 

Вы должны предоставить атрибут функции маршрута:

<a href="{{route('edit1', ['country1' => $country1->country])}}">{{$country1->country}}</a> 
+0

Спасибо большое! Оно работает! – imladris

Смежные вопросы