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 Authentication Log Laravel Package

rappasoft/laravel-authentication-log

View on GitHub
Deep Wiki
Context7

title: Statistics and Insights weight: 8

The package provides comprehensive statistics and insights about user authentication patterns.

Getting Statistics

Get all statistics for a user:

$user = User::find(1);
$stats = $user->getLoginStats();

// Returns:
// [
//     'total_logins' => 150,
//     'failed_attempts' => 5,
//     'unique_devices' => 3,
//     'unique_ips' => 8,
//     'last_30_days' => 45,
//     'last_7_days' => 12,
//     'suspicious_activities' => 2,
//     'trusted_devices' => 2,
// ]

Individual Statistics

Get specific statistics:

$user = User::find(1);

// Total successful logins
$totalLogins = $user->getTotalLogins();

// Total failed login attempts
$failedAttempts = $user->getFailedAttempts();

// Number of unique devices
$uniqueDevices = $user->getUniqueDevicesCount();

// Number of suspicious activities
$suspiciousCount = $user->getSuspiciousActivitiesCount();

Example: Statistics Dashboard

Here's an example of displaying statistics in a dashboard:

// In your controller
public function dashboard()
{
    $user = auth()->user();
    $stats = $user->getLoginStats();
    
    return view('dashboard', compact('stats'));
}

// In your view
<div class="stats-grid">
    <div class="stat-card">
        <h3>Total Logins</h3>
        <p class="stat-value">{{ $stats['total_logins'] }}</p>
    </div>
    
    <div class="stat-card">
        <h3>Failed Attempts</h3>
        <p class="stat-value">{{ $stats['failed_attempts'] }}</p>
    </div>
    
    <div class="stat-card">
        <h3>Unique Devices</h3>
        <p class="stat-value">{{ $stats['unique_devices'] }}</p>
    </div>
    
    <div class="stat-card">
        <h3>Last 30 Days</h3>
        <p class="stat-value">{{ $stats['last_30_days'] }}</p>
    </div>
    
    [@if](https://github.com/if)($stats['suspicious_activities'] > 0)
        <div class="stat-card alert">
            <h3>Suspicious Activities</h3>
            <p class="stat-value">{{ $stats['suspicious_activities'] }}</p>
            <a href="{{ route('security.review') }}">Review</a>
        </div>
    [@endif](https://github.com/endif)
</div>

Combining with Query Scopes

You can combine statistics with query scopes for more detailed insights:

$user = User::find(1);

// Get statistics for last 7 days only
$recentLogs = $user->authentications()->recent(7)->get();
$recentStats = [
    'total' => $recentLogs->where('login_successful', true)->count(),
    'failed' => $recentLogs->where('login_successful', false)->count(),
    'suspicious' => $recentLogs->where('is_suspicious', true)->count(),
];

// Get statistics by device
$deviceStats = $user->authentications()
    ->successful()
    ->select('device_id', 'device_name', \DB::raw('count(*) as login_count'))
    ->groupBy('device_id', 'device_name')
    ->get();
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope