Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Dashboard Attendances Tile Laravel Package

spatie/laravel-dashboard-attendances-tile

Spatie tile for Laravel Dashboard that shows office attendance at a glance—who’s in the office and who’s not. Built to plug into Laravel Dashboard and display current team presence in a simple, readable tile.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require spatie/laravel-dashboard-attendances-tile
    

    Ensure laravel-dashboard is installed (this package is a tile for it).

  2. Publish Config (if needed):

    php artisan vendor:publish --provider="Spatie\DashboardAttendancesTile\DashboardAttendancesTileServiceProvider"
    

    (Note: The package is minimal; config is rarely needed for basic use.)

  3. Register the Tile: Add the tile to your dashboard in app/Providers/DashboardServiceProvider.php:

    public function boot()
    {
        Dashboard::create()
            ->row()
                ->tile(Spatie\DashboardAttendancesTile\DashboardAttendancesTile::class)
            ->endRow();
    }
    
  4. First Use Case: Visit your dashboard (/dashboard). The tile will display users marked as "present" (based on is_present column in your users table by default).


Implementation Patterns

Core Workflow

  1. Data Source: The tile queries the users table for records with is_present = true (configurable via present_column in config). Override the default behavior by extending the tile:

    use Spatie\DashboardAttendancesTile\DashboardAttendancesTile;
    
    class CustomAttendancesTile extends DashboardAttendancesTile
    {
        protected function getPresentUsers()
        {
            return User::where('custom_status', 'active')->get();
        }
    }
    
  2. Styling/Customization:

    • Colors: Modify present_color and absent_color in config (e.g., #4CAF50 for present, #F44336 for absent).
    • Labels: Override getPresentLabel() and getAbsentLabel() in a custom tile class.
  3. Integration with Auth: Exclude admins or specific roles from attendance checks:

    protected function getPresentUsers()
    {
        return auth()->user()->isAdmin()
            ? User::none()
            : User::where('is_present', true)->get();
    }
    
  4. Real-Time Updates: Use Laravel Echo/Pusher to update the tile dynamically when attendance changes:

    // Frontend (dashboard JS)
    Echo.channel('attendance-updates')
        .listen('AttendanceUpdated', (e) => {
            location.reload(); // Or fetch new data via AJAX
        });
    

Gotchas and Tips

Pitfalls

  1. Default Column Assumption: The tile assumes a is_present boolean column. If your schema differs (e.g., status = 'present'), extend the tile or publish/config the present_column:

    // config/dashboard-attendances-tile.php
    'present_column' => 'status',
    'present_value' => 'present',
    
  2. Performance: Avoid eager-loading heavy relationships in getPresentUsers(). Use select() to limit columns:

    return User::where('is_present', true)->select('id', 'name')->get();
    
  3. Caching: The tile doesn’t cache by default. For large teams, cache the query result:

    protected function getPresentUsers()
    {
        return Cache::remember('present_users', now()->addHours(1), function () {
            return User::where('is_present', true)->get();
        });
    }
    

Debugging Tips

  • Blank Tile?: Check if the users table has records with is_present = true. Add a dd() in getPresentUsers() to verify data.

    dd(User::where('is_present', true)->get()); // Debug query
    
  • Styling Issues: Inspect the tile’s Blade template (resources/views/vendor/dashboard-attendances-tile.blade.php) if CSS isn’t applying. Override it by publishing the view:

    php artisan vendor:publish --tag=dashboard-attendances-tile-views
    

Extension Points

  1. Custom User Model: Bind the tile to a custom model (e.g., Employee):

    class CustomAttendancesTile extends DashboardAttendancesTile
    {
        protected $model = \App\Models\Employee::class;
    }
    
  2. Multi-Location Support: Add a location column and filter by office:

    protected function getPresentUsers()
    {
        return User::where('is_present', true)
            ->where('office_id', request('office_id'))
            ->get();
    }
    
  3. Webhook Triggers: Sync attendance data via webhooks (e.g., from a badge system):

    // Route webhook to update attendance
    Route::post('/update-attendance', function (Request $request) {
        $user = User::find($request->user_id);
        $user->update(['is_present' => $request->status]);
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport