我无法摆脱错误。我已经创建了一个模型,并且在控制器和路径中都有功能,但是我得到了错误。
我的模型(newsticker.php):
<?php
class Newsticker extends Eloquent {
protected $table = 'aac_newsticker';
protected $fillable = array('label', 'content');
public $timestamps = true;
}
我的控制器(也用于其他功能,但也用于newstickers):
<?php
class NewsController extends BaseController {
/**
* News Repository
*
* @var News
*/
protected $news;
public function __construct(News $news)
{
$this->news = $news;
}
/** ------------------------------------------
* News Functions
* ------------------------------------------
*/
public function index()
{
return View::make('admin.news_managment')->with('newss', $this->news->all());
}
public function create()
{
return View::make('admin.create_news');
}
public function store()
{
$input = Input::all();
$rules = array(
'author' => 'required|min:4|max:255',
'title' => 'required|unique:aac_news,title|min:4|max:255',
'content' => 'required|unique:aac_news,content|min:10'
);
$validation = Validator::make($input, $rules);
if ($validation->fails()) {
return Redirect::back()->withErrors($validation);
} else {
News::create($input);
return Redirect::to('news/index');
}
}
public function delete($newsId)
{
$news = $this->news->findOrFail($newsId);
$news->delete();
return Redirect::back()->with('success', 'Your news post has been deleted.');
}
/** ------------------------------------------
* Newsticker Functions
* ------------------------------------------
*/
public function newsticker_index()
{
return View::make('aac.index')->with('newstickers', Newsticker::all());
}
}
这里也是我的index.blade.php:
@extends('base')
@section('title', 'Home')
@stop
@section('main')
@foreach($newstickers as $newsticker)
<div class="alert alert-info"><span class="label label-info">{{ $newsticker->created_at }}</span>
<span class="label label-success">{{ $newsticker->label }}</span>
<button type="button" class="close" data-dismiss="alert">×</button>
<td>{{ $newsticker->content }}</td>
</div>
</div>
@endforeach
@foreach($newss as $news)
<div class="doc-content-box">
<legend>{{ $news->title }} <div id="spaceholder"></div>
<p>
<h6><i class="icon-calendar"></i> {{ $news->created_at }} <a href="/profile/{{ $news->author }}">{{ $news->author }}</a>
</p>
</h6>
</legend>
<div style="margin-top:7px">
<p>{{ $news->content }}</p>
@if (Auth::check())
@if ($roles == 5)
<div class="btn-group">
<a class="btn btn-success" href="#"><i class="icon-pencil"></i> Edit</a>
<a class="btn btn-danger" href="{{ URL::action('NewsController@delete', ['id' => $news->id]) }}"><i class="icon-trash icon-large"></i> Delete</a>
</div>
@endif
@endif
</div>
</div>
@endforeach
@stop
和我的路线:
# News ticker
Route::get('admin/dash/newsticker', 'NewsController@newsticker_index');
我想在我的索引页面(/或新闻/索引)上显示它,但我已将其设置为admin / dash / newsticker。我也尝试将其更改为/或新闻/索引,但我在laravel的php服务器和空白页面中收到错误。
[Sun Aug 04 18:12:23 2013] PHP Fatal error: Uncaught exception 'ReflectionExcep
tion' with message 'Class NotAllowedHttpException does not exist' in C:\Users\E1
\Desktop\l4\bootstrap\compiled.php:7543
Stack trace:
#0 C:\Users\E1\Desktop\l4\bootstrap\compiled.php(7543): ReflectionParameter->get
Class()
#1 C:\Users\E1\Desktop\l4\bootstrap\compiled.php(7537): Illuminate\Exception\Han
dler->hints(Object(ReflectionFunction), Object(ReflectionException))
#2 C:\Users\E1\Desktop\l4\bootstrap\compiled.php(7512): Illuminate\Exception\Han
dler->handlesException(Object(Closure), Object(ReflectionException))
#3 C:\Users\E1\Desktop\l4\bootstrap\compiled.php(7481): Illuminate\Exception\Han
dler->callCustomHandlers(Object(ReflectionException))
#4 [internal function]: Illuminate\Exception\Handler->handleException(Object(Ref
lectionException))
#5 {main}
thrown in C:\Users\E1\Desktop\l4\bootstrap\compiled.php on line 7543