applicazza / appointed
Check whether required appointment slot is open or offer closest available one
Installs: 10 770
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: >=5.6.0
- nesbot/carbon: ^1.22.1
Requires (Dev)
- phpunit/phpunit: ^6.2.0
README
Installation
composer require applicazza/appointed
Usage
- Set up default timezone, i.e.
date_default_timezone_set('Asia/Jerusalem');
- Instantiate business day
use Applicazza\Appointed\BusinessDay; // ... $business_day = new BusinessDay;
- Create some operating periods and add them to business day. If some operating periods cannot be added then false will be returned and no changes will be applied whatsoever
use Applicazza\Appointed\Period; // ... $period_0900_1400 = Period::make(today( 9, 00), today(14, 00)); $period_1600_1900 = Period::make(today(16, 00), today(19, 00)); $business_day->addOperatingPeriods( $period_1600_1900, $period_0900_1400 );
- Create some appointments and add them to business day. If some appointments cannot be added then false will be returned and no changes will be applied whatsoever
use Applicazza\Appointed\Appointment; // ... $appointment_1100_1130 = Appointment::make(today( 11, 00), today(11, 30)); $appointment_1200_1330 = Appointment::make(today( 12, 00), today(13, 30)); $business_day->addAppointments( $appointment_1100_1130, $appointment_1200_1330 );
- To fit previously failed appointment use
BusinessDay::fit(Appointment $appointment, $direction = 'forward')
that will return either null or recommended Appointment
$business_day->fit($appointment_1300_1330, 'backward'); $business_day->fit($appointment_1300_1330);
- To delete appointment(s) use
BusinessDay::deleteAppointments(Appointment ...$appointment)
that will return boolean
$business_day->deleteAppointments($appointment_1300_1330);
- To delete operating period use
BusinessDay::deleteOperatingPeriod(Period $period)
that will return boolean
$business_day->deleteOperatingPeriod($period_0900_1400)
- To edit operating period use
BusinessDay::editOperatingPeriod(Period $old_period, Period $new_period)
that will return boolean
$business_day->editOperatingPeriod($period_1330_1400, $period_1330_1430)
- To get whole day agenda use
BusinessDay::getAgenda()
that will return array of Period and/or Appointment ordered ascending. Since underlying classes implement JsonSerializable interface this data may be easily encoded to json.
$agenda = $business_day->getAgenda(); // To pretty print results echo json_encode($business_day->getAgenda(), JSON_PRETTY_PRINT), PHP_EOL;
Helpers
use function Applicazza\Appointed\interval; use function Applicazza\Appointed\today; // ... interval($hours = 0, $minutes = 0, $seconds = 0); today($hours = 0, $minutes = 0, $seconds = 0);