schneespur/app/Http/Controllers/Portal/PortalNotificationController.php
Michael ee3dbba6cc Initial release v1.0.0
Schneespur — Open-source winter service documentation software (PWA + Admin).
GPS tracking via OwnTracks, weather data, photo evidence, and legally
compliant service records for winter maintenance operators.

License: AGPL-3.0-or-later
2026-05-17 13:33:51 +00:00

33 lines
1 KiB
PHP

<?php
namespace App\Http\Controllers\Portal;
use App\Http\Controllers\Controller;
use App\Models\Customer;
use App\Models\Job;
use App\Models\NotificationLog;
use Illuminate\View\View;
class PortalNotificationController extends Controller
{
public function index(): View
{
/** @var Customer $customer */
$customer = auth('customer')->user();
$logs = NotificationLog::query()
->where(function ($query) use ($customer) {
$query->where(function ($q) use ($customer) {
$q->where('notifiable_type', Job::class)
->whereIn('notifiable_id', $customer->serviceJobs()->select('id'));
})->orWhere(function ($q) use ($customer) {
$q->where('notifiable_type', Customer::class)
->where('notifiable_id', $customer->id);
});
})
->orderByDesc('created_at')
->paginate(20);
return view('portal.notifications.index', compact('logs'));
}
}