moonshiner/safe-queuing 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moonshiner/safe-queuing

Composer 安装命令:

composer require moonshiner/safe-queuing

包简介

Package to manage bookings and reservations for timeslots

README 文档

README

Latest Version on Packagist Total Downloads

This package helps you to attach timeslot and reservation capabilities to your existing Eloquent Models in Laravel.

Installation

You can install the package via composer:

composer require moonshiner/safe-queuing

You can use the package for timeslot calculation only. To use the reservation capabilities of the package you need to publish the migrations. If you want to change the table name publishing the config is necessary as well. To run the publish command you need to add the Service Provider:

// config/app.php
'providers' => [
    // ...
    Moonshiner\SafeQueuing\SafeQueuingServiceProvider::class,
];

If you want to specify a custom table name, you'll need to publish and edit the configuration file:

php artisan vendor:publish --provider="Moonshiner\SafeQueuing\SafeQueuingServiceProvider" --tag="config"

Publishing and running the migrations for the usage of reservations:

php artisan vendor:publish --provider="Moonshiner\SafeQueuing\SafeQueuingServiceProvider" --tag="migrations"
php artisan migrate

Usage

You can simply add timeslots to your existing Model via the HasTimeslots Trait.

use Moonshiner\SafeQueuing\HasTimeslots;

//...

class Event extends Model
{
    use HasTimeslots;

To better configure the contraints for the timeslots you can add the following functions to your model to configure when timeslots are available:

public function timeslotStartDate(){
    return \Carbon\Carbon::now();
}
public function timeslotEndDate(){}
public function timeslotStartTime(){}
public function timeslotEndTime(){}
public function timeslotDuration(){}
public function timeslotBreak(){}
public function timeslotAvailableDays(){}
public function timeslotExcludedDates(){}
public function timeslotIncludedDates(){}
public function timeslotExcludedTimes(){}

To show all the timeslots available you can use:

$event = Event::first();

dd($event->timeslots());

To show all the reservations run:

$event = Event::first();

dd($event->reservations);

You can filter Timeslots

use Carbon\Carbon;
$event = Event::first();


// timeslots after some date
dd($event->timeslots()->findSlot(['start'=>Carbon::now(), 'end'=>Carbon::now()->addMinutes('30')]));

// only timeslots on a specific date
dd($event->timeslots()->onDay(Carbon::today()));

// timeslots after some date
dd($event->timeslots()->afterDate(Carbon::yesterday()));

// timeslots that end before given time
dd($event->timeslots()->beforeDate(Carbon::tomorrow()));

To add a reservations run:

$event = Event::first();
$timeslot = $event->timeslots()->first();

$event->reservations()->create([
    'details' => 'Person specific data',
    'timeslot' => $timeslot
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email office@moonshiner.at instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固