douqi0090 2014-10-30 16:29
浏览 16
已采纳

没有模型[]的查询结果

I have an error when I try to acces to my tipos/index page, i'm using laravel 4 framework with jeffrey way generator to speed up the creation process of routes, controllers, models, etc.

This is my 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();
        return View::make('tipos.index', compact('tipos'));
    }

Especific Route in my 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&Oacute;DIGO</th>
                <th>DESCRIPCI&Oacute;N</th>
                <th>EDITAR</th>
                <th>ELIMINAR</th>
            </thead>

        </table>
    <div class="foot">

    </div>
    </form>
</div> 
@stop

And this error appears: Illuminate \ Database \ Eloquent \ ModelNotFoundException No query results for model [Tipo].

If anyone can help I will be grateful!

  • 写回答

3条回答 默认 最新

  • dqppv86022 2014-10-30 17:35
    关注

    Solved, i have two routes of tipos:

    Route::resource('tipos', 'TiposController');
    

    AND

    Route::get('tipos/index', 
        array(
            'as' => 'index',
            'uses' => 'TiposController@index')
    );
    

    Just remove the the duplicate route tipos/index and put in mi master.blade:

    {{ link_to**_route**('tipos.index', trans({{'common/messages.tipos'))}} |
    

    The conflict was because i needed the _route in mi master.

    Thanks!.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器