Skip to content

Commit

Permalink
Updated readme [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki authored Jul 28, 2018
1 parent 32db36a commit 2954795
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
[![PayPal](https://img.shields.io/badge/PayPal-donate-blue.svg)](https://paypal.me/rennokki)

# Schedule
Schedule is a package that helps tracking schedules for your models. You can set a certain range of hours and this package will do the thing.
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](https://github.com/spatie/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:
Expand Down Expand Up @@ -56,7 +59,7 @@ $user->setSchedule([
$user->hasSchedule(); // true
```

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.
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.
```php
Expand All @@ -69,7 +72,7 @@ $user->setExclusions([
```

# Checking for availability
You can check if the user has working hours on a certain day, date. Passing date also works with Carbon Instances.
You can check if the user has working hours on a certain day, date. Passing date also works with Carbon instance.
```php
$user->isAvailableOn('monday'); // true
$user->isAvailableOn('05-28'); // true; This is Monday, in 2018 (current year)
Expand All @@ -82,19 +85,21 @@ $user->isUnavailableOn('2018-05-28'); // false
$user->isUnavailableOn(Carbon::create(2018, 5, 28, 0, 0, 0)); // false
```

Checking against exclusions work too:
If there is an exclusion that day, it will return the correct value based on the schedule set that day:
```php
$user->isUnavailableOn('12-25'); // true
$user->isUnavailableOn('03-01'); // false
```

# Checking for availability at a certain time
You can also check availability for a certain time on a specific day.
```php
$user->isAvailableOnAt('monday', '09:00'); // true
$user->isUnavailableOnAt('monday', '09:00'); // false
```

# 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.
```php
$user->getHoursOn('03-01'); // 4
$user->getHoursOn('12-26'); // 0
Expand All @@ -105,10 +110,8 @@ $user->getMinutesOn('03-01'); // 240
```

# Deleting the schedule
If you plan to delete the user's schedule, you can do so by calling `deleteSchedule()`.
```php
$user->deleteSchedule();
$user->hasSchedule(); // false
```

# About the package
This package is inspired from [Spatie's Opening Hours](https://github.com/spatie/opening-hours) package, which uses a schedule but only statically, rather than binding it to a model.

0 comments on commit 2954795

Please sign in to comment.