raihanafroz / zkteco

ZKTeco Laravel Library
151 stars 57 forks source link

ZKTeco - Laravel Library

Issues Forks Stars Total Downloads License

The rats/zkteco package provides easy to use functions to ZKTeco Device activities.

Requires: Laravel >= 6.0

License: MIT or later

Installation:

You can install the package via composer:

composer require rats/zkteco

The package will automatically register itself.

You have to enable your php socket if it is not enable.

Usage

  1. Create a object of ZKTeco class.
    use Rats\Zkteco\Lib\ZKTeco;

//  1 s't parameter is string $ip Device IP Address
//  2 nd  parameter is integer $port Default: 4370

    $zk = new ZKTeco('192.168.1.201');

//  or you can use with port
//    $zk = new ZKTeco('192.168.1.201', 8080);
  1. Call ZKTeco methods

// return bool/mixed bool|mixed Format: "Y-m-d H:i:s"

$zk->getTime(); 

* __Set Device Time__ 
```php
//    set device time
//    parameter string $t Format: "Y-m-d H:i:s"
//    return bool/mixed

    $zk->setTime(); 

// 1 s't parameter int $uid Unique ID (max 65535) // 2 nd parameter int|string $userid ID in DB (same like $uid, max length = 9, only numbers - depends device setting) // 3 rd parameter string $name (max length = 24) // 4 th parameter int|string $password (max length = 8, only numbers - depends device setting) // 5 th parameter int $role Default Util::LEVEL_USER // 6 th parameter int $cardno Default 0 (max length = 10, only numbers

// return bool|mixed

$zk->setUser(); 

* __Clear All Admin__ 
```php
//    remove all admin
//    return bool|mixed

    $zk->clearAdmin(); 

// return array[]

// like as 0 => array:5 [▼ // "uid" => 1 / serial number of the attendance / // "id" => "1" / user id of the application / // "state" => 1 / the authentication type, 1 for Fingerprint, 4 for RF Card etc / // "timestamp" => "2020-05-27 21:21:06" / time of attendance / // "type" => 255 / attendance type, like check-in, check-out, overtime-in, overtime-out, break-in & break-out etc. if attendance type is none of them, it gives 255. / // ]

$zk->getAttendance(); 

* __Clear Attendance Log__ 
```php
//    clear attendance log

//    return bool/mixed

    $zk->clearAttendance(); 

end