Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Enums\Permission;
|
||||
use App\Models\Appointment;
|
||||
use App\Services\Tenant\TenantContext;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class StaffDashboardController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, TenantContext $tenant): View
|
||||
{
|
||||
$business = $tenant->require();
|
||||
$staff = $request->user()->staffProfiles()
|
||||
->where('businessId', $business->id)
|
||||
->with('role.permissions')
|
||||
->first();
|
||||
|
||||
abort_unless($staff, 403);
|
||||
|
||||
$isOwner = $staff->hasPermission(Permission::ViewAllStaffAppointments);
|
||||
$today = Carbon::now($business->timezone);
|
||||
$appointments = Appointment::query()
|
||||
->where('businessId', $business->id)
|
||||
->when(! $isOwner, fn ($query) => $query->where('staffId', $staff->id))
|
||||
->whereBetween('startAt', [$today->copy()->startOfDay()->utc(), $today->copy()->endOfDay()->utc()])
|
||||
->with(['customer', 'staff.user', 'services.service'])
|
||||
->orderBy('startAt')
|
||||
->get();
|
||||
|
||||
return view('staff.dashboard', compact('business', 'staff', 'appointments', 'isOwner'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user