定制 ianvizarra/attendance 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ianvizarra/attendance

最新稳定版本:v0.1.1

Composer 安装命令:

composer require ianvizarra/attendance

包简介

Attendance package for Laravel application.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Add Attendance feature with ease to your laravel application.

Installation

You can install the package via composer:

composer require ianvizarra/attendance

You can publish and run the migrations with:

php artisan vendor:publish --tag="attendance-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="attendance-config"

This is the contents of the published config file:

return [
  'logs_table' => 'attendance_logs',
    'schedule' => [
        'timeIn' => 9,
        'timeOut' => 17,
        'requiredDailyHours' => 8,
        'timeInAllowance' => 30, // minutes
        
        'workDays' => [
            'Monday',
            'Tuesday',
            'Wednesday',
            'Thursday',
            'Friday'
        ],
        'offDays' => [
            'Saturday',
            'Sunday'
        ]
    ],
    'user_model' => config('auth.providers.users.model', \App\Models\User::class),
    'users_table' => 'users'
];

Add CanLogAttendance Interface and HasAttendance Trait to your User model.

class User extends Authenticatable implements CanLogAttendance
{
    use HasAttendance;
}

Usage

Using User Model

$user->attendance(); // HasMany relationship to attendance log model

$user->timeIn(); // create an time-in attendance log entry

$user->timeOut(); // create an time-out attendance log entry

$user->hasTimeIn(); // return true if user already time-in for today
$user->hasTimeOut(); // return true if user already time-out for today
$user->hasWorked(); // return true if user already time-in and time-out for today
$user->getTimeIn(); // return the time-in attendance log for today

$user->logAttendance('in', 'on-time', now()); // manually log an attendance by type, status and time

Using Facade

use Ianvizarra\Attendance\Facades\Attendance;

 // create an attendance log entry for the currently logged-in user
 // by default it will the current time
 Attendance::timeIn(); 
 Attendance::timeOut();
 
 // manually set the time logged instead of the current time
 Attendance::timeIn(now()->subMinutes(30));
 
 // manually set the schedule configuration
 // the default config values can be found in config/attendance.php `config('attendance.schedule.hours')`
 Attendance::timeIn(now(), [
    'timeIn' => 8,
    'timeOut' => 16,
    'requiredDailyHours' => 8
]);
 
 // manually set the user other than the logged-in user
 Attendance::setUser($user)->timeIn();
 
 // get the time in status
 Attendance::timeInStatus(); // on-time, late
 // manually set the time using Carbon instance
 Attendance::timeInStatus(now()->subMinutes(30)); // on-time, late
  // manually set the schedule configuration
 Attendance::timeInStatus(now(), [
    'timeIn' => 8,
    'timeOut' => 16,
    'requiredDailyHours' => 8
]); // on-time, late
 
 // get the time out status
 Attendance::timeOutStatus(); // on-time, under-time
 // manually set the time using Carbon instance
 Attendance::timeOutStatus(now()->subMinutes(30)); // on-time, under-time
 // manually set the schedule configuration
 Attendance::timeOutStatus(now(), [
    'timeIn' => 8,
    'timeOut' => 16,
    'requiredDailyHours' => 8
]); // on-time, under-time

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-05