Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nasrulhazim committed Oct 2, 2018
1 parent 3717357 commit 828df78
Showing 1 changed file with 91 additions and 6 deletions.
97 changes: 91 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 [email protected] as time in
$ php artisan attendance:log "[email protected]" 1 "email"

// log user with email [email protected] as time out
$ php artisan attendance:log "[email protected]" 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
<?php

namespace App\Adapters;

use CleaniqueCoders\Attendance\Models\AttendanceType;

class SlackAdapter extends BaseAdapter
{
protected $driver = 'slack';

public function timeIn()
{
// your implementation to determine user is time in
$this->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:
Expand All @@ -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

Expand All @@ -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`.

Expand Down

0 comments on commit 828df78

Please sign in to comment.