PHP code example of lee / work-home-schedule

1. Go to this page and download the library: Download lee/work-home-schedule library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lee / work-home-schedule example snippets




use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDate = $currentDate->nextWorkingDate();

$carbonDate = $nextWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$nextWorkingDate['date']; // 2020-04-07 00:00:00
$workingStatus = $nextWorkingDate['status']; // home



use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDate = $currentDate->previousWorkingDate();

$carbonDate = $previousWorkingDate['date']; // Carbon::class instance
$carbonDateString = (string)$previousWorkingDate['date']; // 2020-04-01 00:00:00
$workingStatus = $previousWorkingDate['status']; // home



use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$nextWorkingDates = $currentDate->nextWorkingDates(); // The array length is 2

$nextWorkingDates[0]['date'] // Carbon::class instance
(string)$nextWorkingDates[0]['date'] // 2020-04-07 00:00:00
$nextWorkingDates[0]['status'] // home

$nextWorkingDates[1]['date'] // Carbon::class instance
(string)$nextWorkingDates[1]['date'] // 2020-04-08 00:00:00
$nextWorkingDates[1]['status'] // office




use Carbon\Carbon;
use Lee\WorkHomeSchedule;

$filePath = __DIR__ . '/tests/fixtures/2020_calendar.csv';

$workingHomeSchedule = new WorkHomeSchedule();
$workingHomeSchedule->startDateStatus = 'office'; // The default value is empty string
$workingHomeSchedule->csvPath = $filePath; // The default value is empty string
$workingHomeSchedule->csvHead = true; // The default value is true
$workingHomeSchedule->workingDays = 2; // The default value is 1

$workingHomeSchedule = $workingHomeSchedule->loadCalendarData($filePath);

Carbon::mixin($this->workingHomeSchedule);
$currentDate = Carbon::create('2020-04-06');

$previousWorkingDates = $currentDate->previousWorkingDates(); // array length is 2

$previousWorkingDates[0]['date'] // Carbon::class instance
(string)$previousWorkingDates[0]['date'] // 2020-04-01 00:00:00
$previousWorkingDates[0]['status'] // home

$previousWorkingDates[1]['date'] // Carbon::class instance
(string)$previousWorkingDates[1]['date'] // 2020-03-31 00:00:00
$previousWorkingDates[1]['status'] // office
BASH
curl -sS https://getcomposer.org/installer | php