jdecano / events-starter
轻松启动您的定期活动应用程序。
dev-master / 1.0.x-dev
2016-06-16 06:57 UTC
Requires
- php: ~5.5|~7.0
- illuminate/support: ~5.1
- rlanvin/php-rrule: 1.*
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-09-23 12:51:15 UTC
README
轻松启动您的定期活动应用程序。
安装
composer require jdecano/events-starter
# Register Provider
Jdecano\EventsStarter\EventsStarterServiceProvider::class,
# Register Facade
'RecurringEvent' => Jdecano\EventsStarter\Facades\RecurringEvent::class
# Migrate
php artisan migrate --path=vendor/jdecano/events-starter/database/migrations
基本用法
- title - 活动的标题
- description - 活动的描述
- date - 活动发生的PHP日期
- frequency - 年度、月度、周度、日度
- interval - 每个FREQUENCY迭代之间的间隔。例如,当使用YEARLY时,间隔为2表示每两年一次,但使用HOURLY时,表示每两小时一次。默认为1。
- type - by_date 或 by_count。如果您使用by_date,则发生次数的生成将基于until。如果您使用by_count,则生成次数将基于计数。
- count - 将生成多少次发生。
- until - 周期的限制。接受与DTSTART相同的格式。如果周期实例恰好发生在给定日期,这将是最后一次发生。
- weekdays - 要应用于周期的时间(星期一到星期日)。必须是以下字符串之一:MO(星期一)、TU(星期二)、WE(星期三)、TH(星期四)、FR(星期五)、SA(星期六)、SU(星期日)。它可以是一个单一值,也可以是一个以逗号分隔的列表或一个数组
$event = RecurringEvent::create([
'title' => 'My Event Title',
'description' => 'My Event Description',
'date' => date("Y-m-d"),
'frequency' => 'daily',
'interval' => 1,
'type' => 'by_date', // or by_count
'count' => 1,
'until' => date("Y-m-d"), // Requires PHP date
'weekdays' => ["SU", "MO", "TU", "WE"]
]);
$event = RecurringEvent::update($eventId, [
'title' => 'My Event Title',
'description' => 'My Event Description',
'date' => date("Y-m-d"),
'frequency' => 'daily',
'interval' => 1,
'type' => 'by_date', // or by_count
'count' => 1,
'until' => date("Y-m-d"), // Requires PHP date
'weekdays' => ["SU", "MO", "TU", "WE"]
]);
$event = RecurringEvent::pick($eventId);
$event = RecurringEvent::destroy($eventId);
# Getting RRule Object
$setting = EventSetting::where('event_id', $event_id)->first();
$rrule = $setting->getRRule();
foreach ( $rrule as $occurrence ) {
echo $occurrence->format('r'),"\n";
}
// output:
// Tue, 02 Sep 1997 09:00:00 +0000
// Thu, 04 Sep 1997 09:00:00 +0000
// Sat, 06 Sep 1997 09:00:00 +0000
// Mon, 08 Sep 1997 09:00:00 +0000
// Wed, 10 Sep 1997 09:00:00 +0000
$rrule->humanReadable();
// every other week on Monday, Wednesday and Friday, starting from 9/1/97, until 12/23/97
// Refer to https://github.com/rlanvin/php-rrule/wiki/RRule
如果您发现任何与安全相关的问题,请通过电子邮件发送至 johndavedecano@gmail.com,而不是使用问题跟踪器。
致谢
- John Dave Decano http://johndavedecano.me
- Remi Lanvin https://github.com/rlanvin
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。