rakeshthapac/laratime
Composer 安装命令:
composer require rakeshthapac/laratime
包简介
Cool laravel package to broadcast database updates using websockets for realtime system
README 文档
README
Provides a cool way to make your system realtime by sending real-time database updates using WebSockets
Installation
- Setup websocket in your application (Pusher, Laravel-Websockets)
- Require this package in your project
$ composer require rakeshthapac/laratime
- Now install small npm package laratime-js
$ npm install laratime-js
Usage
- Just plug one trait into your model and you are ready to go
use \rakeshthapac\LaraTime\Traits\LaraTimeable; // now all your database updates will be broadcasted through websockets
Usage (Frontend laratime-js)
- import laratime from laratime-js and pass it the Echo instance
// in bootstrap.js // first create a instance of a echo with correct credentials import LaraTime from "laratime-js"; window.laratime = new LaraTime(window.Echo);
- Now you are ready to listen for database changes
window.laratime .db("users") .on("added", (user) => addUser(user)) .on("updated", (user) => updateUser(user)) .on("deleted", (user) => deletesUser(user));
- Using laratime-js you can listen to updates of a table using db(tableName) and by chaining on(eventName) you can listen to three different events:
- added
- updated
- deleted
- You can hook a callaback which accepts the added (or updated or deleted) model as the first argument as javascript object.
统计信息
- 总下载量: 159
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-11