rakeshthapac / laratime
Cool laravel package to broadcast database updates using websockets for realtime system
Installs: 159
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rakeshthapac/laratime
Requires (Dev)
- orchestra/testbench: ^5.3
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2025-12-13 09:49:48 UTC
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.