dainsys / timy2
Add user's time tracker functionality to Laravel 7, Livewire and Bootstrap 4
Installs: 65
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/dainsys/timy2
Requires
- php: >=7.0
- consoletvs/charts: 6.*
- dainsys/components: ^1.0
- guzzlehttp/guzzle: ^6.3|^7.0.1
- laravel/framework: ^6.0|^7.0|^8.0
- laravel/ui: ^3.0
- livewire/livewire: ^v2.0
- maatwebsite/excel: ^3.1
- pusher/pusher-php-server: ~4.0
Requires (Dev)
- orchestra/canvas: 9999999-dev
- orchestra/testbench: 6.x-dev
- dev-master
- 3.x-dev
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.0
- 2.x-dev
- 2.5.0
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.7.1
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3
- 0.2
- 0.1.1
- 0.1
This package is auto-updated.
Last update: 2025-10-10 13:52:05 UTC
README
Add user's time tracker functionality to Laravel 7, Livewire and Bootstrap 4.
Installation
- Install with composer: composer require dainsys/timy2.Optional: The Package should be auto-discovered by Laravel. However, you could all register it in your config.app file within the providers array: 'providers' => [ Dainsys\Timy\TimyServiceProvider::class, ] You may want to publish the config file: php artisan vendor:publish --tag=timy-configto change default configuration. Pay attention to the option of creating default dispositions.
- Next you may want to run migrations with command php artisan migrate.You could also publish the migrations with php artisan vendor:publish --tag=tiy-migrationsand update them before migrating.
- Add the use Dainsys\Timy\Timeabletrait to yourUsermodel.use Dainsys\Timy\Timeable; class User extends Authenticatable { use Timeable; } This package relies on laravel/uito handle authentication. Follow it's installation guide Authentication. We recommend to running the following command:php artisan ui --auth vue.
- As required per laravel/livewire, make sure you update your layout view:@livewireStyles </head> <body> ... @livewireScripts @stack('scripts') </body> </html> 
- Make sure the App\Providers\BroadcastServiceProvider::classis uncommented in theconfig.appfile.
- Next paste the following routes in your routes\channels.phpfile:Broadcast::channel('Timy.User.{id}', function ($user, $id) { return (int) $user->id == (int) $id; }); Broadcast::channel('Timy.Admin', function ($user) { return \Illuminate\Support\Facades\Gate::allows(config('timy.roles.admin')); }); 
- Include the timy menu in your main nav-bar after you check for logged in users: @include('timy::_timy-menu').Alternatively you can link to the following endpoints: Users: URL= /timy/user, NAME=user_dashboard, GATEWAY(blade @can directive)=timy-userAdmin Users: URL=/timy/admin, NAME=admin_dashboard, GATEWAY(blade @can directive)=timy-adminSuper Admin User: URL=/timy/super_admin, NAME=supepr_admin_dashboard, GATEWAY(blade @can directive)=timy-super-admin
- Next, define the Super User in you .env file by providing its email in the variable TIMY_SUPER_USER_EMAIL=. This user will have plenty control of the app.
- Next get your Pusher's credentials from Pusher and use them to define the following variables in your .env file. BE CERTAIN YOU SET YOUR BROADCAST_DRIVERVARIABLE TOpusher:BROADCAST_DRIVER=pusher PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER= MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 
- Update your package.jsonfile with the follow dependencies:"laravel-echo": "^1.8.0", "pusher-js": "^6.0.3", 
- Uncomment the Laravel Echosection in yourresources/js/bootstrap.js:import Echo from 'laravel-echo'; window.Pusher = require('pusher-js'); window.Echo = new Echo({ broadcaster: 'pusher', key: process.env.MIX_PUSHER_APP_KEY, cluster: process.env.MIX_PUSHER_APP_CLUSTER, forceTLS: true }); 
- Then install the front end dependencies and compile: npm install && npm run dev.
- OPTIONAL: This package includes an artisan command that runs every 5 minutes to check user's ip is still alive. It is inactive bt default: To activate it do the following
- MAKE SURE your server is running a cron jobas suggested in Laravel documentation Scheduling, Starting The schedule session:* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
- In the config\timy.phpfile set the with_scheduled_commands variable to true:'with_scheduled_commands' => env('TIMY_WITH_SCHEDULED_COMMANDS', true).
 
- MAKE SURE your server is running a 
Features
- Authenticated users is required for the package to work. We leverage that on laravel/uipackage.
- Users and admin shoud have valid roles assigned to them.
- When session is started, all previously opened timers are closed and a new one is opened.
- Only Super Admin can manage roles.
- Admin controller is protected and only work for users with timy-adminrole assigned to them.
- On page load:
- If the user has a timer running for a specifig disposition, upon closing that one, a new timer is started using that same disposition.
- Even if there are not timers running, previous disposition is used to start a new timer on page reload.
- If both previous logic fails, by default the dispo set in the config is used to start a new timer.
 
- If a user change the Dispositions dropdown (Vue component) a new timer is created, closing all previous.
- When an user change their dispo, the admin dashboar update dinamically.
- When admin update a scpecific user's dispo, user interface update and the user is alerted.
Api Endpoints
- The GET endpoing /timy/api/timers_filteredor routeroute('timy.timers_filtered')retunrs a Json formated resource with all timers, filtered by the query string. The following GET variables will allow you to filter the list:- disposition=valuewill only return timers where the- dispositionname contains the given value.
- user=valuewill only return timers where the- username contains the given value.
- from_date=datewill only return timers where the- start_dateis newer or equal to the given date.
- to_date=datewill only return timers where the- start_dateis older or equal to the given date.
- payable=truewill only return timers where- dispositionis labeled as- payable.
- invoiceable=truewill only return timers where- dispositionis labeled as- invoiceable.
- running=truewill only return timers where- finished_atfield is null, which represent currently running timers.
 
- Visit the GET route /timy/api/get_open_timer_hoursor routeroute('timy.getOpenTimersHours')to get the current hours of the open timer for the current user. Ideal to display live updates, calculating the hours, whithout actually closing the current timer.