alimehraei / laravel-fullcalendar-scheduler
Laravel 全日历调度模块组件
dev-master / 1.0.x-dev
2022-07-25 23:11 UTC
Requires
- php: 8.*
- laravel/framework: 9.*
Requires (Dev)
- orchestra/testbench: ^7.6
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-26 03:59:06 UTC
README
注意:本包尚未准备就绪!!
安装
通过 composer 安装此扩展是首选方式。
要安装,请运行
$ php composer.phar require alimehraei/laravel-fullcalendar-scheduler "v1.2.3"
或
"alimehraei/laravel-fullcalendar-scheduler": "v1.2.3"
将以下内容添加到您的 composer.json
文件的 require
部分。
注意
本包基于以下 git 仓库编写: https://github.com/Edofre/laravel-fullcalendar-scheduler
此包需要 foxy/foxy 插件才能正确安装。此插件允许您通过 composer 下载 bower 包。
您可以使用以下命令安装它
composer global require "foxy/foxy:^1.0.0"
配置
将 ServiceProvider 添加到您的 config/app.php
'providers' => [ ... AliMehraei\FullcalendarScheduler\FullcalendarSchedulerServiceProvider::class, ],
并添加 facade
'aliases' => [ ... 'Fullcalendar' => AliMehraei\FullcalendarScheduler\Facades\FullcalendarScheduler::class, ],
发布资产和配置文件
php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=fullcalendar-scheduler
手动加载脚本文件
通过将 config/.env 文件中的 include_scripts 选项设置为 false,脚本将不会在生成日历时包含。如果您想手动包含脚本,可以在您的 header/footer 等位置调用以下静态函数。
\AliMehraei\FullcalendarScheduler\FullcalendarScheduler::renderScriptFiles();
示例
使用以下作为您的控制器操作
/** * @return \Illuminate\Http\Response */ public function index() { // Generate a new fullcalendar instance $calendar = new \AliMehraei\FullcalendarScheduler\FullcalendarScheduler(); // Set events and resources, commented lines shows how to add them via ajax // $calendar->setEvents(route('fullcalendar-scheduler-ajax-events')); $calendar->setEvents([ ['id' => '1', 'resourceId' => 'b', 'start' => '2016-05-07T02:00:00', 'end' => '2016-05-07T07:00:00', 'title' => 'event 1'], ['id' => '2', 'resourceId' => 'c', 'start' => '2016-05-07T05:00:00', 'end' => '2016-05-07T22:00:00', 'title' => 'event 2'], ['id' => '3', 'resourceId' => 'd', 'start' => '2016-05-06', 'end' => '2016-05-08', 'title' => 'event 3'], ['id' => '4', 'resourceId' => 'e', 'start' => '2016-05-07T03:00:00', 'end' => '2016-05-07T08:00:00', 'title' => 'event 4'], ['id' => '5', 'resourceId' => 'f', 'start' => '2016-05-07T00:30:00', 'end' => '2016-05-07T02:30:00', 'title' => 'event 5'], ]); // $calendar->setResources(route('fullcalendar-scheduler-ajax-resources')); $calendar->setResources([ ['id' => 'a', 'title' => 'Auditorium A'], ['id' => 'b', 'title' => 'Auditorium B', 'eventColor' => 'green'], ['id' => 'c', 'title' => 'Auditorium C', 'eventColor' => 'orange'], [ 'id' => 'd', 'title' => 'Auditorium D', 'children' => [ ['id' => 'd1', 'title' => 'Room D1'], ['id' => 'd2', 'title' => 'Room D2'], ], ], ['id' => 'e', 'title' => 'Auditorium E'], ['id' => 'f', 'title' => 'Auditorium F', 'eventColor' => 'red'], ['id' => 'g', 'title' => 'Auditorium G'], ['id' => 'h', 'title' => 'Auditorium H'], ['id' => 'i', 'title' => 'Auditorium I'], ['id' => 'j', 'title' => 'Auditorium J'], ['id' => 'k', 'title' => 'Auditorium K'], ['id' => 'l', 'title' => 'Auditorium L'], ['id' => 'm', 'title' => 'Auditorium M'], ['id' => 'n', 'title' => 'Auditorium N'], ['id' => 'o', 'title' => 'Auditorium O'], ['id' => 'p', 'title' => 'Auditorium P'], ['id' => 'q', 'title' => 'Auditorium Q'], ['id' => 'r', 'title' => 'Auditorium R'], ['id' => 's', 'title' => 'Auditorium S'], ['id' => 't', 'title' => 'Auditorium T'], ['id' => 'u', 'title' => 'Auditorium U'], ['id' => 'v', 'title' => 'Auditorium V'], ['id' => 'w', 'title' => 'Auditorium W'], ['id' => 'x', 'title' => 'Auditorium X'], ['id' => 'y', 'title' => 'Auditorium Y'], ['id' => 'z', 'title' => 'Auditorium Z'], ]); // Set options $calendar->setOptions([ 'now' => '2016-05-07', 'editable' => true, // enable draggable events 'aspectRatio' => 1.8, 'scrollTime' => '00:00', // undo default 6am scrollTime 'defaultView' => 'timelineDay', 'views' => [ 'timelineThreeDays' => [ 'type' => 'timeline', 'duration' => [ 'days' => 3, ], ], ], 'resourceLabelText' => 'Rooms', 'eventClick' => new \AliMehraei\FullcalendarScheduler\JsExpression(" function(event, jsEvent, view) { console.log(event); } "), 'viewRender' => new \AliMehraei\FullcalendarScheduler\JsExpression(" function( view, element ) { console.log(\"View \"+view.name+\" rendered\"); } "), ]); return view('fullcalendar-scheduler.index', [ 'calendar' => $calendar, ]); }
然后,将以下内容添加到您的视图中
{!! $calendar->generate() !!}
测试
通过执行以下命令运行测试
composer test