我知道這可能是一件非常愚蠢的事情,但我似乎無法修復它。Handler.php中的NotFoundHttpException行131:
我得到這個錯誤
NotFoundHttpException在Handler.php行131:沒有找到模型查詢結果[應用程序\模塊\菜單\型號\菜單。
而且似乎無法解決它。目前它甚至不應該要求菜單模型。
這裏是我的route.php
Route::get('/signup', [
'uses' => '[email protected]',
'as' => 'signup'
]);
這裏是我的OpenController.php
<?php
namespace App\Modules\Open\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Modules\Menus\Models\Menu;
use App\Modules\Authors\Models\Story;
class OpenController extends Controller
{
public function index(){
$menus_child = Menu::where('menu_id', 0)->with('menusP')->get();
$menu = Menu::where('id', 1)->orWhere('title', 'home')->firstOrFail();
return view('open::index', compact('menus_child', 'menu'));
}
public function content($id){
$menus_child = Menu::where('menu_id', 0)->with('menusP')->get();
$menu = Menu::where('id', $id)->firstOrFail();
$layout = $menu->type;
$stories = Story::where('type', 'public')->get();
return view('open::public/'.$layout, compact('menus_child', 'menu', 'stories'));
}
public function signup(){
echo "sign up";
die();
}
}
這裏是我的signup.blade.php
@extends('templates::layouts.public')
@section('content')
<h1>signup blade</h1>
@stop
這裏是我的公衆。 blade.php版面
<!DOCTYPE html>
<html>
<head>
<title>Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Cherry+Swash|Crafty+Girls|Homemade+Apple|Italianno|Parisienne|Ranga|Rochester" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
{!! Html::style('css/bootstrap.min.css') !!}
{!! Html::style('css/style.css') !!}
{!! Html::script('js/jquery-3.1.1.min.js') !!}
{!! Html::script('js/bootstrap.min.js') !!}
{!! Html::script('js/main.js') !!}
</head>
<body>
<div class="container">
<div id="main">
<div id="header">
<div id="logo">
<div class="row">
<div class="col-lg-6">
<h1>Website</h1>
</div>
<div class="col-lg-6">
<div class="slogan">
{!! Html::link('/signup', 'Signup') !!}/{!! Html::link('/login', 'Login') !!}
</div>
</div>
</div>
</div>
@include('menus::menu')
</div>
<div id="site_content">
<div id="content">
@yield('content')
</div>
</div>
</div>
</div>
</body>
</html>
這是我menu.blade.php
<div id="menubar">
<ul class="nav navbar-nav" id="menu">
@foreach($menus_child as $grandfather)
@if($grandfather->menu_id)
<li>
@elseif($grandfather->title == 'Home')
<li class="parent {{ menu_active([$grandfather->id]) }}">
@elseif(count($grandfather->menusP()->where('menu_id', '>', 0)->get()))
<li class="dropdown {{ menu_active([$grandfather->id]) }}">
@else
<li class="parent {{ menu_active([$grandfather->id]) }}">
@endif
@if(count($grandfather->menusP()->where('menu_id', '>', 0)->get()))
{!! HTML::decode(HTML::link($grandfather->id, $grandfather->title.'<span class="caret"></span>', array('class' => 'dropdown-toggle')))!!}
@else
{!! HTML::link($grandfather->id, $grandfather->title) !!}
@endif
@if(count($grandfather->menusP))
<ul class="dropdown_menu">
@foreach($grandfather->menusP as $father)
@if($father->menu_id)
<li class="parent_child">
@else
<li>
@endif
{!! HTML::link($father->id, $father->title) !!}
@endforeach
</ul>
@endif
@endforeach
</ul>
</div>
這解決了我的問題,但是你知道爲什麼嗎? – Gus
@Gus - 我不確定。我只是亂搞,但如果你確實知道爲什麼我會很感激,如果你讓我知道,因爲我很困惑,爲什麼它發生了 – Isis