php - No query results for model [] -
i have error when seek acces tipos/index page, i'm using laravel 4 framework jeffrey way generator speed creation process of routes, controllers, models, etc.
this code:
route:
route::get('tipos/index', array( 'as' => 'index', 'uses' => 'tiposcontroller@index') );
model:
class tipo extends eloquent{ protected $guarded = array(); public static $rules = array( 'clave_tipo' => 'required', 'nombre_tipo' => 'required', 'status' => 'required', 'created_by' => 'required', ); }
controller:
class tiposcontroller extends basecontroller { protected $tipo; public function index() { $tipos = $this->tipo->all(); homecoming view::make('tipos.index', compact('tipos')); }
especific route in 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
and error appears: illuminate \ database \ eloquent \ modelnotfoundexception no query results model [tipo].
if can help grateful!
you need inject tipo model controller.
class tiposcontroller extends basecontroller { protected $tipo; function __construct(tipo $tipo){ $this->tipo = $tipo; } }
not sure why modelnotfoundexception because never injected model in controller. tipos
table have records in it?
php laravel blade laravel-routing
No comments:
Post a Comment