여기에 정의 된 Restful routes를 얻는 데 문제가 있습니다. 올바르게 작동하려면 (Laravel Documentation: Restful Controllers).Laravel Restful Resource Controller routing getShow()
제대로 작성하려면 양식 및 색인 (모두보기)을 얻을 수 있지만 제대로 작동하려면 단일 항목에 대한 링크를 얻을 수 없습니다.
<?php
class PeopleController extends BaseController {
public $restful = true;
public function getIndex()
{
return View::make('people.index')
->with('people', $people);
}
public function getShow($id)
{
return 'success! it finally worked!';
}
public function getCreate()
{
return View::make('people.create');
}
public function postStore()
{
return Redirect::to('people')
->with('success', 'Person added successfully');
}
}
여기에 있습니다 : 여기
// People
Route::controller('people', 'PeopleController');
내 컨트롤러 PeopleController.php입니다 : 내 routes.php에 자동 라우팅을 사용해야하므로 getShow
나는 편안한 나의 길을 정의한 show.blade.php 템플릿에 링크해야하는 내 index.blade.php 템플릿 :
<ul class="thumbnails">
@foreach ($people as $people)
<li> <a href="{{ URL::to('people/' . $people->people_id) }}" class="thumbnail"> <img src="https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/s200x200/486010_633561579994787_1827482783_n.jpg" /> </a>
<div class="caption">
<p> {{ $people->people_id }}<br />
{{ $people->firstname }}<br />
{{ $people->lastname }}<br />
{{ $people->line1 }}<br />
{{ $people->city }}<br />
<br />
{{ $people->state }} {{ $people->zip }}<br />
{{ $people->country }} </p>
<p>
<button class="btn btn-small btn-primary" type="button">Actions</button>
<button class="btn btn-small" type="button">View</button>
</p>
</div>
</li>
@endforeach
</ul>
show.blade.php라는 뷰를 만들었습니다.
@extends('master')
@section('title')
@parent
:: Home
@stop
@section('content')
<p>it finally worked!</p>
@stop
하지만 사람/1과 같은 항목에 갈 때마다 오류가 발생합니다.
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
…\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php290
Illuminate\Routing\Controllers\Controller missingMethod
<#unknown>0
call_user_func_array
…\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php138
Illuminate\Routing\Controllers\Controller callMethod
…\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php115
Illuminate\Routing\Controllers\Controller callAction
…\bootstrap\compiled.php9980
Illuminate\Routing\{closure}
<#unknown>0
call_user_func_array
…\bootstrap\compiled.php16626
Illuminate\Routing\Route callCallable
…\bootstrap\compiled.php16605
Illuminate\Routing\Route run
…\bootstrap\compiled.php10000
Illuminate\Routing\Router dispatch
…\bootstrap\compiled.php1010
Illuminate\Foundation\Application dispatch
…\bootstrap\compiled.php993
Illuminate\Foundation\Application run
…\public\index.php49
이 시점에서 나는이 코드가 작동하도록하기 위해 맨손으로 코드를 제거했습니다. 문서가 너무 부족하기 때문에 RESTful 기능이별로 도움이되지 않을 수 있습니다. 어쨌든 OLD 버전 3 문서를 구할 수 있습니까?
누군가 내가 뭘 잘못하고 있는지 알 수 있다면 정말 고마워 할 것입니다. 그것은 워드 프로세서 당 올바른 것 같지만 그것이 어떻게 작동하는지 전혀 설명하지 않습니다. :(Laravel을 처음 접했을 때 나는 무엇인가를 놓치고 있는지, 아니면 문서가 실제로해야할 일을 정교하게 잘 모르는지 잘 모르겠다.
대신 자신의 경로를 만드는 것이 낫 겠는가? 기능 내장을 사용하려고 시도하는 중? 당신의 도움을 주셔서 감사합니다.
getIndex 메소드 선언에 인수가 없기 때문에 people/show/1을 시도하십시오. –