Add employee presence with kiosk sign-in, QR badges, and mobile step-out.
Deploy Ladill Frontdesk / deploy (push) Failing after 26s
Deploy Ladill Frontdesk / deploy (push) Failing after 26s
Enables staff roster, PIN/code kiosk flow, attendance reports, evacuation staff roll call, webhooks, branch mismatch warnings, and a linked-user My presence portal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Frontdesk;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount;
|
||||
use App\Models\Employee;
|
||||
use App\Models\EmployeePresence;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Frontdesk\OrganizationResolver;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -26,15 +28,27 @@ class DashboardController extends Controller
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
|
||||
$cacheKey = "fd:dashboard:{$owner}:{$organization->id}:".($branchScope ?? 'all');
|
||||
|
||||
$stats = Cache::remember($cacheKey, 60, function () use ($visitQuery) {
|
||||
$stats = Cache::remember($cacheKey, 60, function () use ($visitQuery, $owner, $organization, $branchScope) {
|
||||
$today = (clone $visitQuery)->where(function ($q) {
|
||||
$q->whereDate('checked_in_at', today())
|
||||
->orWhereDate('scheduled_at', today());
|
||||
});
|
||||
|
||||
$employeeIds = Employee::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('active', true);
|
||||
if ($branchScope !== null) {
|
||||
$employeeIds->where('branch_id', $branchScope);
|
||||
}
|
||||
$employeeIds = $employeeIds->pluck('id');
|
||||
|
||||
$presenceQuery = EmployeePresence::query()->whereIn('employee_id', $employeeIds);
|
||||
|
||||
return [
|
||||
'visitors_today' => (clone $today)->count(),
|
||||
'currently_inside' => (clone $visitQuery)->currentlyInside()->count(),
|
||||
'staff_on_site' => (clone $presenceQuery)->where('status', EmployeePresence::STATUS_ON_SITE)->count(),
|
||||
'staff_stepped_out' => (clone $presenceQuery)->where('status', EmployeePresence::STATUS_STEPPED_OUT)->count(),
|
||||
'expected_arrivals' => (clone $visitQuery)->whereIn('status', [
|
||||
Visit::STATUS_EXPECTED,
|
||||
Visit::STATUS_SCHEDULED,
|
||||
@@ -83,6 +97,19 @@ class DashboardController extends Controller
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
return view('frontdesk.dashboard', compact('stats', 'currentVisitors', 'expectedVisitors', 'pendingApprovals', 'organization'));
|
||||
$staffSteppedOut = EmployeePresence::query()
|
||||
->where('status', EmployeePresence::STATUS_STEPPED_OUT)
|
||||
->whereHas('employee', function ($q) use ($owner, $organization, $request) {
|
||||
$q->owned($owner)->where('organization_id', $organization->id)->where('active', true);
|
||||
$this->scopeToBranch($request, $q, 'branch_id');
|
||||
})
|
||||
->with('employee')
|
||||
->orderByDesc('last_event_at')
|
||||
->limit(10)
|
||||
->get();
|
||||
|
||||
return view('frontdesk.dashboard', compact(
|
||||
'stats', 'currentVisitors', 'expectedVisitors', 'pendingApprovals', 'staffSteppedOut', 'organization',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user