Note that there are some explanatory texts on larger screens.

plurals
  1. POLaravel Restful Resource Controller routing getShow()
    text
    copied!<p>I'm having difficulty getting the Restful routes defined here (<a href="http://laravel.com/docs/controllers#restful-controllers" rel="nofollow">Laravel Documentation: Restful Controllers</a>) to work properly.</p> <p>I can get the create form and the index (view of all) to work properly but I cannot get the link to a single item to work properly. The getShow</p> <p>I have defined my route as restful so it should use the automatic routing in my routes.php:</p> <pre><code>// People Route::controller('people', 'PeopleController'); </code></pre> <p>Here is my controller PeopleController.php:</p> <pre><code>&lt;?php class PeopleController extends BaseController { public $restful = true; public function getIndex() { return View::make('people.index') -&gt;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') -&gt;with('success', 'Person added successfully'); } } </code></pre> <p>Here is my index.blade.php template which should link to the show.blade.php template:</p> <pre><code>&lt;ul class="thumbnails"&gt; @foreach ($people as $people) &lt;li&gt; &lt;a href="{{ URL::to('people/' . $people-&gt;people_id) }}" class="thumbnail"&gt; &lt;img src="https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash4/s200x200/486010_633561579994787_1827482783_n.jpg" /&gt; &lt;/a&gt; &lt;div class="caption"&gt; &lt;p&gt; {{ $people-&gt;people_id }}&lt;br /&gt; {{ $people-&gt;firstname }}&lt;br /&gt; {{ $people-&gt;lastname }}&lt;br /&gt; {{ $people-&gt;line1 }}&lt;br /&gt; {{ $people-&gt;city }}&lt;br /&gt; &lt;br /&gt; {{ $people-&gt;state }} {{ $people-&gt;zip }}&lt;br /&gt; {{ $people-&gt;country }} &lt;/p&gt; &lt;p&gt; &lt;button class="btn btn-small btn-primary" type="button"&gt;Actions&lt;/button&gt; &lt;button class="btn btn-small" type="button"&gt;View&lt;/button&gt; &lt;/p&gt; &lt;/div&gt; &lt;/li&gt; @endforeach &lt;/ul&gt; </code></pre> <p>I have a view created called show.blade.php.</p> <pre><code>@extends('master') @section('title') @parent :: Home @stop @section('content') &lt;p&gt;it finally worked!&lt;/p&gt; @stop </code></pre> <p>But whenever I go to an item such as people/1 I get a crap ton of errors:.</p> <pre><code>Symfony\Component\HttpKernel\Exception\NotFoundHttpException …\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php290 Illuminate\Routing\Controllers\Controller missingMethod &lt;#unknown&gt;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} &lt;#unknown&gt;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 </code></pre> <p>At this point I've stripped my code down to the bare bones just to get this to work. I'm finding that perhaps the RESTful features are not so helpful since the documentation is so lacking. Is there anyway to get to the OLD version 3 documentation?</p> <p>If anyone can see what I'm doing wrong I would really appreciate it. It seems to be correct as per the docs but it does not detail at all how this works. :( As a newcomer to Laravel I'm not sure if I'm just missing something, or if the docs really don't elaborate what needs to be done.</p> <p>Would it be better to just create my own routes instead of trying to use the built in functions? Thank you for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload