laravel5 CalendarController不存在

时间:2015-07-19 18:42:49

标签: php laravel-5

我使用https://github.com/maddhatter/laravel-fullcalendar的日历,

当我打电话时 - http://myla/nomer 我收到错误:

Class App \ Http \ Controllers \ CalendarController不存在 enter image description here

CalendarController.php

$events = [];

$events[] = \Calendar::event(
    'Event One', //event title
    false, //full day event?
    '2015-02-11T0800',//start time (you can also use Carbon instead of DateTime)
    '2015-02-12T0800', //end time (you can also use Carbon instead of DateTime)
    0 //optionally, you can specify an event ID
);

$events[] = \Calendar::event(
    "Valentine's Day", //event title
    true, //full day event?
    new \DateTime('2015-02-14'), //start time (you can also use Carbon instead of DateTime)
    new \DateTime('2015-02-14'), //end time (you can also use Carbon instead of DateTime)
    'stringEventId' //optionally, you can specify an event ID
);

$eloquentEvent = EventModel::first(); //EventModel implements MaddHatter\LaravelFullcalendar\Event

$calendar = \Calendar::addEvents($events) //add an array with addEvents
->addEvent($eloquentEvent, [ //set custom color fo this event
    'color' => '#800',])->setOptions([ //set fullcalendar options
    'firstDay' => 1])->setCallbacks([ //set fullcalendar callback options (will not be JSON encoded)
    'viewRender' => 'function() {alert("Callbacks!");}']);

return view('all_nom.blade.php', compact('calendar'));

我的routes.php

Route::get('/', function () {
    return view('welcome');
});
Route::get('nomer/{id}','nomerController@show' );
Route::get('nomer','CalendarController@index');

和all_nom.blade.php

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.js"></script>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.css"/>

<div class="row">
    <div class="col-md-12">
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}
    </div>
</div>

并且所有文件都有permision 777 请帮忙,哪里有错误?

1 个答案:

答案 0 :(得分:1)

在您的\App\Calender中尝试\Calender代替CalenderController,您的控制器使用Calendar,而不是CalendarController。将其名称更改为CalendarController(推荐)或仅在Calendar中使用routes.php