1. Go to this page and download the library: Download cleaniquecoders/attendance 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/ */
namespace App;
use CleaniqueCoders\Attendance\Traits\AttendanceTrait;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, AttendanceTrait;
...
// 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"
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);
}
}
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');