2017-11-30 13 views
0

laravel 프로젝트에서 컨트롤러 액션에 문제가 있습니다. 모든 것이 정상적으로 보이므로 왜 그런지 알 수 없습니다. Heres는액션이 정의되지 않았습니다. laravel/php 컨트롤러

오류 부분에 관한 내 경로 : Heres는

Route::get('/reminds','[email protected]'); 
Route::get('/reminds','[email protected]'); 

만들기와 RemindController.php 파일에 정의 된 인덱스 방법 : create.blade.php에서

public function index() 
{ 
    $reminds = Remind::all(); 
    return View::make('remind.index', compact('reminds')); 
} 



public function create() 
{ 
    try { 


     $listyears = RemindController::generate_list(date('Y')-100, 101); 
     $listmonths = RemindController::generate_list(1, 12); 
     $listdays = RemindController::generate_list(1, 31); 

     return View::make('remind.create', compact('listyears', 'listmonths', 'listdays')); 
    } catch (Exception $e){ 
     App:abort(404); 
    } 
} 

(의 생각 나게하다) 내가 문제있는 색인이라고 부르는 이것을 가지고있다 :

<div class="panel-heading"> 
    <h2>create reminder</h2> 
</div> 
<div class="panel-body"> 
    {!! Form::open(['action'=> '[email protected]', 'class' => 'form']) !!} 

문제는 각각 알림 작성 양식을 호출하는 페이지에 액세스하려고 할 때 오류가 발생합니다.

ErrorException (E_ERROR) 
Action App\Http\Controllers\[email protected] not defined. (View: C:\Users\myusername\Desktop\project\prototype\resources\views\remind\create.blade.php) 

그러나 명확하게 정의했습니다. 나는 이해하지 못한다.

답변

2

경로 : 수 ('인덱스 @ RemindController', '/가 나게') ; Route :: get ('/ reminds', 'RemindController @ create');

이것은 동일한 경로이므로 기술적으로이 부분에는 이미 문제가 있습니다. HTTP 프로토콜을 변경하거나 경로 이름을 바꾸십시오.

Route::get('reminds','[email protected]'); 
Route::post('reminds','[email protected]'); 

또는

Route::get('reminds','[email protected]'); 
Route::get('reminds/create','[email protected]'); 

또한 그 일을 아무 소용이 없다, 이미 경로의 첫 번째 슬래시를 생략합니다.

--- 업데이트 *

대신 정적 호출 경로

를 사용하면 당신은 같은 HTTP 동사에 대한 동일한 경로 URL을 쓴이

$router->group(function(){ 
    $this->get('/',['as' => "homepage" , 'use' => "[email protected]"]); 

    $this->group(['prefix' => "dashboard",'as' => "dashboard"],function(){ 
     $this->get('/',['as' => "index",'use' => "[email protected]"]); 
}); 
}); 
+0

감사합니다! 잘 설명했다. laravel 5 이후 새로운 방법 이니? –

+0

실제로 없습니다. 전역 변수에 대한 정적 호출은 더 이상 권장되지 않습니다. Route : :(), Session ::, Cache :: etc 등을 호출하는 대신 route() ->, session() ->, cache() -> etc를 사용할 수 있습니다. 이게 더 명확 해. –

1

주셔서 감사합니다 당신은

Route::get('/reminds','[email protected]'); 
Route::get('/reminds','[email protected]'); 

그들 중 하나의 이름을 변경 동일한 URL과 같은 방법으로 두 개의 경로를 정의

Route::get('/reminds','[email protected]'); 
Route::get('/reminds/create','[email protected]'); 
+0

Route :: get ('/ reminds/create', 'RemindController @ create'); Route :: post ('/ reminds', 'RemindController @ create')가되어야합니다. – jcorry

+1

@jcorry 자신의 작성 메소드는 데이터를 표시하기위한 것일 뿐이므로 확인해보십시오. 게시물은 저장 방법에 대한 자세한 내용입니다 –

+0

아, 알 겠어 ... 나는 방법 이름을 읽지 않았다. – jcorry

0

같은 것을 사용할 수있다.

귀하의 요구 사항으로 바꾸십시오. 경로를 단순화하기 위해 name()을 추가하라는 제안.

관련 문제