@inviziblll

Почему Laravel выдает ошибку в роутинге?

Решил познакомиться с фреймворком Laravel. Установил его на OpenServer.
Создал тестовый контроллер HomeController. В файле routes.php создал 2 пути к тестовым экшенам контролера HomeController. И здесь возникла странная ошибка с роутингом.

Когда я в файле routes.php указываю путь message/{id}/edit и путь test/{id}/edit то фреймворк выдает ошибку такого вида скриншот , но стоит мне закоментировать любой из созданных мной путей то ошибка исчезает скриншот

Почему Laravel выдает ошибку Label 'Route' already defined когда я прописываю оба роута одновременно?

Код файла routes.php

<?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('/', 'WelcomeController@index');

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

Route:get('message/{id}/edit', ['uses'=>'HomeController@edit', 'as'=>'message.edit']);
Route:get('test/{id}/edit', ['uses'=>'HomeController@test', 'as'=>'test.edit']);


Код файла HomeController.php

<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class HomeController extends Controller {

        public function index(){            
            //return "HomeController action Index";
            return view('index');
        }        
        
        public function edit($id){            
            dd($id);
            return view('edit');
        }
        
        
         public function test($id){            
              dd($id);
            return view('edit');
        }
}
  • Вопрос задан
  • 267 просмотров
Решения вопроса 2
JhaoDa
@JhaoDa
LaravelRUS Team
Route:get
Одно двоеточие не смутило?
Ответ написан
Denormalization
@Denormalization
Route::get('message/{id}/edit', ['uses'=>'HomeController@edit', 'as'=>'message.edit']);
Route::get('test/{id}/edit', ['uses'=>'HomeController@test', 'as'=>'test.edit']);
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы