Невозможно просмотреть строки таблицы авторов (Laravel)

Привет и спасибо за помощь! Я новичок в Laravel, и я пытаюсь изучить его с помощью учебника, который я нашел в YouTube! http://www.youtube.com/watch?v=lceNwQf-ufY

До сих пор все работало правильно!
Я пытаюсь составить список всех строк моей таблицы authors

Мой контроллер authors.php

<?php

class Authors extends BaseController{
public function get_index(){
return View::make('authors.index')
->with('title', 'Authors Title')
->with('authors', Author::all());
}
}

Моя модель author.php

<?php
class Author extends Eloquent{
protected $table = 'authors';

}

Мой взгляд index.blade.php

@extends('authors.layout')
@section('content')
<h2>Authors Page</h2>
<h3>Welcome to the authors page</h3>
<ul>
@foreach($authors as $author)
<li>{{ $author->name }}</li>
@endforeach
</ul>
@stop

И мой макет layout.blade.php

<!DOCTYPE html>
<html>
<head>
<title>{{ $title }}</title>
</head>
<body>
@yield('content')
</body>
</html>

routes.php

<?php
Route::get('/', function()
{
return View::make('hello');
});
Route::get('users', function()
{
return View::make('users');
});
Route::get('authors', array('uses'=>'authors@index'));

0

Решение

Вы должны изменить в своем routes.php

Route::get('authors', array('uses'=>'authors@index'));

в

Route::get('authors', array('uses'=>'Authors@get_index'));

С помощью Authors@get_index первая часть это имя контроллера (в вашем случае это Authors а вторая часть это имя метода — в вашем случае это get_index и не index,

1

Другие решения

Других решений пока нет …