diff --git a/README.md b/README.md index b6febe9..5af5a09 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,24 @@ -[![Build Status](https://travis-ci.org/cleanique-coders/attendance.svg?branch=master)](https://travis-ci.org/cleanique-coders/attendance) [![Latest Stable Version](https://poser.pugx.org/cleanique-coders/attendance/v/stable)](https://packagist.org/packages/cleanique-coders/attendance) [![Total Downloads](https://poser.pugx.org/cleanique-coders/attendance/downloads)](https://packagist.org/packages/cleanique-coders/attendance) [![License](https://poser.pugx.org/cleanique-coders/attendance/license)](https://packagist.org/packages/cleanique-coders/attendance) +[![Build Status](https://travis-ci.org/cleaniquecoders/attendance.svg?branch=master)](https://travis-ci.org/cleaniquecoders/attendance) [![Latest Stable Version](https://poser.pugx.org/cleaniquecoders/attendance/v/stable)](https://packagist.org/packages/cleaniquecoders/attendance) [![Total Downloads](https://poser.pugx.org/cleaniquecoders/attendance/downloads)](https://packagist.org/packages/cleaniquecoders/attendance) [![License](https://poser.pugx.org/cleaniquecoders/attendance/license)](https://packagist.org/packages/cleaniquecoders/attendance) ## About Your Package -Tell people about your package +This is an Adaptive Attendance package - enabled developers to integrate with existing attendance system and devices such as Access Card, Biometric, etc. + +This package comes with common attendance adapaters: + +1. Web Adapter - use for Web based attendance system +2. API Adapter - use for Mobile based attendance system +3. Console Adapter - use for Queue based attendance system + +See usage section below for custom adapters. ## Installation -1. In order to install `cleanique-coders/attendance` in your Laravel project, just run the *composer require* command from your terminal: +1. In order to install `cleaniquecoders/attendance` in your Laravel project, just run the *composer require* command from your terminal: ``` -$ composer require cleanique-coders/attendance +$ composer require cleaniquecoders/attendance ``` 2. Then in your `config/app.php` add the following to the providers array: @@ -25,8 +33,85 @@ CleaniqueCoders\Attendance\AttendanceServiceProvider::class, 'Attendance' => CleaniqueCoders\Attendance\AttendanceFacade::class, ``` +4. Install the package: + +``` +$ php artisan attendance:install +``` + ## Usage +### Artisan Commands + +Log Attendance from console: + +```php +// log user with 1 as time in +$ php artisan attendance:log 1 1 + +// log user with 1 as time out +$ php artisan attendance:log 1 2 + +// log user with email hi@attendance.com as time in +$ php artisan attendance:log "hi@attendance.com" 1 "email" + +// log user with email hi@attendance.com as time out +$ php artisan attendance:log "hi@attendance.com" 2 "email" +``` + +### API + +When running `attendance:install`, API routes to for attendance will be append into your `routes/api.php` file. + +### Custom adapter + +You can create custom adapter if you want to have custom integration with Slack, Telegram, etc. + +``` +$ php artisan make:attendance SlackAdapter --driver=slack +``` + +This will create a class located at `app/Adapters/SlackAdapter.php`. + +```php +capture(AttendanceType::TIME_IN); + } + + public function timeOut() + { + // your implementation to determine user is time out + $this->capture(AttendanceType::TIME_OUT); + } +} +``` + +Once created, you may want to create routes to accept Slack webhook into your app. Following is an example of route setup. + +```php +Route::get('attendance/slack/time-in', function() { + $user = \App\User::whereSlackId(request()->slack_id)->firstOrFail(); + (new \App\Adapters\SlackAdapter($user, now()))->timeIn(); +})->name('attendance.slack.time-in'); + +Route::get('attendance/slack/time-out', function() { + $user = \App\User::whereSlackId(request()->slack_id)->firstOrFail(); + (new \App\Adapters\SlackAdapter($user, now()))->timeOut(); +})->name('attendance.slack.time-out'); +``` + ## Test Run the following command: @@ -37,7 +122,7 @@ $ vendor/bin/phpunit --testdox --verbose ## Contributing -Thank you for considering contributing to the `cleanique-coders/attendance`! +Thank you for considering contributing to the `cleaniquecoders/attendance`! ### Bug Reports @@ -49,7 +134,7 @@ Remember, bug reports are created in the hope that others with the same problem ## Coding Style -`cleanique-coders/attendance` follows the PSR-2 coding standard and the PSR-4 autoloading standard. +`cleaniquecoders/attendance` follows the PSR-2 coding standard and the PSR-4 autoloading standard. You may use PHP CS Fixer in order to keep things standardised. PHP CS Fixer configuration can be found in `.php_cs`.