punksolid / laravel-wialon
php-wialon 的 Composer laravel 实现包
7.0
2020-04-23 01:04 UTC
Requires
- php: ^7.1
- ext-json: *
- laravel/framework: ~7.0
Requires (Dev)
- orchestra/testbench: ~5.0
- phpunit/phpunit: ^9.1
README
安装方式
composer require punksolid/laravel-wialon
使用所需的密钥,将其放入您的 .env 文件中。
WIALON_SECRET=5dce19710a5e26ab8b7b8986cb3c49e58C291791B7F0A7AEB8AFBFCEED7DC03BC48FF5F8
使用
列出所有设备
$units = \Punksolid\Wialon\Unit::all(); dd($units); /** Illuminate\Support\Collection {#661 #items: array:29 [ 0 => Punksolid\Wialon\Unit {#663 +id: 734477 +nm: "Audi RS8" +mu: 0 +cls: 2 +uacl: 551920075299 +"pos": {#229 +"t": 1548292667 +"f": 1073741825 +"lc": 0 +"y": 52.33044 +"x": 9.78641 +"c": 73 +"z": 0 +"s": 1 +"sc": 0 } +"lmsg": {#232 +"t": 1548292667 +"f": 1073741825 +"tp": "ud" +"pos": {#233 +"y": 52.33044 +"x": 9.78641 +"c": 73 +"z": 0 +"s": 1 +"sc": 0 } +"lc": 0 +"rt": 1548292668 +"p": {#234} } */
获取所有通知
$notifications = Notification::all(); dd($notifications); /* * Illuminate\Support\Collection {#3961 #items: array:394 [ 0 => Punksolid\Wialon\Notification {#311 +id: 1 +n: "serobaronmibici" +txt: "Test Notification Text" +ta: 1539031912 +td: 1539636712 +ma: 0 +mmtd: null +cdt: null +mast: null +mpst: null +cp: null +fl: 3 +tz: null +la: null +ac: 0 +un: array:2 [ …2] +"act": array:1 [ …1] +"trg": "geozone" +"trg_p": {#233 …3} +"crc": 285336170 +"ct": 1539031913 +"mt": 1539636712 +"nm": "serobaronmibici" +"name": "serobaronmibici" +"control_type": "geozone" +"actions": array:1 [ …1] +"text": "Test Notification Text" +"resource": {#231 …9} } */
通过 ID 查找通知 要查找通知,您需要 id 和 resource->id,此方法使用下划线作为分隔符来查找它
$found_notification = Notification::findByUniqueId("{$resource_id}_{$notification_id}");
稍后提供更好的文档,您可以查看测试类中使用的函数,接受拉取请求