Download the PHP package rennokki/schedule without Composer
On this page you can find all versions of the php package rennokki/schedule. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rennokki/schedule
More information about rennokki/schedule
Files in rennokki/schedule
Package schedule
Short Description Schedule is a package that helps tracking schedules for your models. If you have workers in a company, you can set schedules for them and see their availability though the time.
License MIT
Homepage https://github.com/rennokki/schedule
Informations about the package schedule
Schedule
Schedule is a package that helps tracking schedules for your models. If you have workers in a company, you can set schedules for them and see their availability though the time.
Inspiration
This package is inspired from Spatie's Opening Hours package, which uses a schedule but only statically, rather than binding it to a model. This gave me the idea of brining it closer to Eloquent Models than to the classic Class.
Installation
Install the package via Composer CLI:
For versions of Laravel that doesn't support package discovery, you should add this to your config/app.php
file, in the providers
array:
Publish the migration file and the config file.
Migrate the database.
Add the trait to your model.
Getting Started
To get stared, let's create a schedule for our user. It will be from Monday to Friday, between 8-12 and 13-18.
Let's say the user has its birthday on 1st March each year, so let's add this to an exclusions list. Adding to this, the first and the second day of Christmas is free for anyone, and let's add 1st May 2018 in our exclusions list too.
Note: 1st May 2018 will occur only once, it's not recurrent.
Checking for availability
You can check if the user has working hours on a certain day, date. Passing date also works with Carbon instance.
If there is an exclusion that day, it will return the correct value based on the schedule set that day:
Checking for availability at a certain time
You can also check availability for a certain time on a specific day.
Getting the amount of hours or minutes for a day
You can get the amount of hours or minutes scheduled for a day. Good for tracking workable hours, for example.
Deleting the schedule
If you plan to delete the user's schedule, you can do so by calling deleteSchedule()
.