我尝试访问我的tipos/index页面时出现错误,我正在使用jerarey way generator的laravel 4框架来加速路由,控制器,模型的创建过程,等没有关于model []的查询结果
这是我的代码:
路线:
Route::get('tipos/index',
array(
'as' => 'index',
'uses' => '[email protected]')
);
型号:
class Tipo extends Eloquent{
protected $guarded = array();
public static $rules = array(
'clave_tipo' => 'required',
'nombre_tipo' => 'required',
'status' => 'required',
'created_by' => 'required',
);
}
控制器:
class TiposController extends BaseController {
protected $tipo;
public function index()
{
$tipos = $this->tipo->all();
return View::make('tipos.index', compact('tipos'));
}
Especific路线在我master.blade:
{{ link_to('tipos/index', trans('common/messages.tipos'))}} |
index.blade:
@extends('layouts.master')
@section('content')
<h1>
Tipos
</h1>
<form name="form" id="form" method="post">
<a class="editar button clear" href="/sistema/crearTipo">Nuevo Tipo</a>
<input type="button" onclick="javascript:exportar();" value="Exportar" class="button" style="margin: 0px;">
<input type="hidden" name="format" id="format" value="yy-mm-dd">
<input type="hidden" name="excel" id="excel" value="false">
<br><br>
<iframe name="x" height="0" width="0" style="display: none;"></iframe>
<div class="title">
<form name="form" id="form" method="post">
<iframe name="x" height="0" width="0" style="display: none;"></iframe>
<table class="datatable" id="tipos">
<thead>
<th>CÓDIGO</th>
<th>DESCRIPCIÓN</th>
<th>EDITAR</th>
<th>ELIMINAR</th>
</thead>
</table>
<div class="foot">
</div>
</form>
</div>
@stop
而且出现这个错误:照亮\数据库\雄辩\ ModelNotFoundException 无查询结果的模型[Tipo]。
如果有人能帮助我将不胜感激!
您在数据库中没有记录。在访问视图之前处理异常。 – 2014-10-30 16:34:17
我没有看到'''protected $ table ='';'''你在模型中! – ArjanSchouten 2014-10-30 16:37:36
嗨,我添加到我的模型: protected $ table ='tipos'; 但仍然得到错误:模型[Tipo]没有查询结果。 – 2014-10-30 16:57:32