【发布时间】:2015-01-28 09:31:49
【问题描述】:
我正在开发一个简单的 CRUD 应用程序, 我想从我的 forms 表中获取我的表单详细信息。
我的控制器如下所示,
public function manage_forms()
{
$form_data=Form::all();
return View::make('manage_forms')->with('form_array',$form_data);
}
routes.php,
Route::get('manage-forms',array('as'=>'manage_forms','uses'=>'Nri@manage_forms'));
查看文件,
<title>Registered Form details</title>
<h2>Registered Form details</h2>
<ul>
@foreach($form_array as $form_view)
<li>{{$form_view->name}}</li>
@endforeach
</ul>
我的表单模型(Form.php),
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class Form extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'forms';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
}
我收到类似
的错误 BadMethodCallException
Method all does not exist.
【问题讨论】:
标签: php database laravel-4 eloquent