mchampaneri/timeslicer

一个可插拔的Laravel包,用于为任何时间范围生成特定时间间隔的时间段。

安装次数: 2,014

依赖项: 0

建议者: 0

安全性: 0

星标: 9

关注者: 4

分支: 1

开放问题: 0

类型:laravel-dependant

v0.1.4 2016-06-29 15:13 UTC

This package is not auto-updated.

Last update: 2024-09-27 22:47:58 UTC


README

Laravel 5 包,用于生成特定时间段的时间段

更改

  • 'GUI支持已移除 '
  • '增强后端支持,新增功能'
  • '添加了时间钟转换器'

描述

laravel-timeslicer 是一个包,可以从开始时间到结束时间生成相同长度的时间段,用于一系列的天数、月份或甚至年份。您可以创建不同时间长度或/和不同开始或/和结束时间的时间段,只需相应地更改输入即可。

安装

首先通过Composer获取

  composer require mchampaneri/timeslice

将ServiceProvider复制到config/app.php中的providers数组

   mchampaneri\timeslicer\TimeslicerServiceProvider::class

将Facade复制到config/app.php中的aliases数组

   mchampaneri\timeslicer\TimeslicerServiceProvider::class

其次您需要发布该包

  php artisan vendor:publish
This command will publish all assets file need by the package at appropriate direcotries.

第三执行迁移

  php artisan migrate
Here migrate is neccesary because this package has its own table to manage timeslots and related data

完成这三个步骤后,timeslicer 即可使用

设置

首先您需要设置timeslicer的配置文件。定义您的资源模型名称、消费者模型名称以及模型文件命名空间。

 Resource model : Model For Which You Want To Genreate The Time Slots
        for example doctors, resturant's table, class of school
 Consumer Model : Model Which are going to relate with Resource object throgh Timeslice
        for example patient, customer , subject

这里这些名称是区分大小写的,所以请仔细添加这些名称。

第二步,您可以在任何需要的地方使用此包

功能

MakeSlices($start_date, $end_date, $start_time, $end_time, $interval, $resource_id)

函数基于日期、开始时间和结束时间生成唯一的时段,从开始日期到结束日期,这里所有变量都是表的字段。

Book($consumer_id)

这里Consumer_id是消费者对象的id。此函数将为传递为参数的消费者对象预订当前时段。

UnBook()

取消预订当前时段的预约

OfResource()

返回与当前时段相关的资源对象。

ForConsumer()

返回与当前时段相关的消费者对象。

SliceOfResource($id)

返回为特定资源创建的所有时段。

SliceOfResourceDay($id, $on)

返回特定日期上资源的所有时段。

BookedSliceOfResourceDay($id, $on)
Returns the all booked time slices of the resource **on** the particular **date**.
unBookedSliceOfResourceDay($id, $on)
Returns the all unbooked/free time slices of the resource **on** the particular **date**.

```
TimeConverter($string)
```
Returns the input of 12hr clock in 24hr clock output

```
rTimeConverter($string)
```
Returns the input of 24hr clock in 12hr clock with appropriate suffix ie am/pm