@extends('layouts.app') @section('title', 'Admin Dashboard') @push('styles') @endpush @section('content')
{{-- PAGE HEADER --}}

Admin Dashboard

Welcome back, {{ auth()->user()->name }} — Ministry of Fisheries

Generate Invoice
@csrf
{{-- ALERTS --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- STAT CHIPS --}} @php $totalUsers = $users->count(); $totalLic = ($licenses ?? collect())->count(); $activeLic = ($licenses ?? collect())->where('is_revoked', false)->count(); $revokedLic = ($licenses ?? collect())->where('is_revoked', true)->count(); $totalApps = $applications->count(); $pendingApps = $applications->where('status','pending')->count(); @endphp
@foreach([ ['Users', $totalUsers, '#163a6e'], ['Licenses', $totalLic, '#166534'], ['Active', $activeLic, '#065f46'], ['Revoked', $revokedLic, '#991b1b'], ['Pending Apps', $pendingApps, '#78350f'], ] as [$lbl, $val, $clr])

{{ $lbl }}

{{ $val }}

@endforeach
{{-- ══ 1. USER MANAGEMENT ══ --}}

User Management

{{ $totalUsers }}
@foreach($users as $user)
{{ $user->name }}
{{ $user->email }}
@if($user->role==='user') Reviewer @elseif($user->role==='applicant') Applicant @else {{ ucfirst($user->role) }} @endif @if($user->hasVerifiedEmail()) ✓ Verified @else ✗ Unverified @endif @if($user->id !== auth()->id() && in_array($user->role, ['admin','user'])) Edit
@csrf @method('DELETE')
@elseif($user->id === auth()->id()) (You) @else Via Profile @endif
@endforeach
{{-- ══ 2. LICENSE MANAGEMENT ══ --}}

License Management

{{ $totalLic }}
{{ $activeLic }} active  /  {{ $revokedLic }} revoked
@foreach(['all'=>'All','active'=>'Active','revoked'=>'Revoked'] as $v => $l) {{ $l }} @endforeach
@forelse($licenses ?? [] as $license)
{{ $license->application?->business_name ?? '—' }} {{ $license->is_revoked ? 'Revoked' : 'Active' }}
No.: {{ $license->license_number }} Type: {{ $license->application?->license_type ?? '—' }} Applicant: {{ $license->application?->user?->name ?? '—' }} Issued: {{ $license->issue_date?->format('d M Y') ?? $license->created_at->format('d M Y') }} Expires: {{ $license->expiry_date?->format('d M Y') ?? '—' }} Validity: {{ $license->validity_days }} days Approved by: @php $approvedBy = \App\Models\AuditLog::where('action', 'Application Approved') ->where('details', 'like', '%' . $license->application?->business_name . '%') ->latest()->first(); @endphp {{ $approvedBy ? ($approvedBy->user?->name ?? '—') . ' on ' . $approvedBy->created_at->format('d M Y H:i') : '—' }}
@if($license->is_revoked && $license->revoked_reason)
Reason: {{ $license->revoked_reason }} — {{ $license->revoked_at?->format('d M Y H:i') }}
@endif
@if($license->license_file) View Signed License @endif
@csrf
@if($license->is_revoked)
@csrf @method('PATCH')
@else @endif
@empty

No licenses found

@endforelse
{{-- ══ 3. APPLICATION MANAGEMENT ══ --}}

Application Management

{{ $totalApps }} @if($pendingApps > 0) {{ $pendingApps }} pending @endif
{{ $totalApps }} total
@foreach(['all'=>'All','pending'=>'Pending','reviewed'=>'Reviewed','approved'=>'Approved','rejected'=>'Rejected','revoked'=>'Revoked'] as $v => $l) @php $cnt = $v === 'all' ? $applications->count() : $applications->where('status',$v)->count(); $bg = ['pending'=>'#fef3c7;color:#78350f','reviewed'=>'#dbeafe;color:#1e40af','approved'=>'#d1fae5;color:#064e3b','rejected'=>'#fee2e2;color:#991b1b','revoked'=>'#fed7aa;color:#78350f','all'=>'var(--bg2);color:#374151']; @endphp {{ $l }}{{ $cnt }} @endforeach
@forelse($applications as $app) @php $rc = ['reviewed'=>'app-reviewed','rejected'=>'app-rejected','revoked'=>'app-revoked','approved'=>'app-approved'][$app->status] ?? ''; $bc = ['pending'=>'b-pending','reviewed'=>'b-reviewed','approved'=>'b-approved','rejected'=>'b-rejected','revoked'=>'b-revoked'][$app->status] ?? ''; $od = $app->operationDetail ?? null; $cd = $app->companyDetail ?? null; @endphp
{{ $app->business_name }} {{ ucfirst($app->status) }} APP-{{ str_pad($app->id,5,'0',STR_PAD_LEFT) }}
Type: {{ $app->license_type }} Applicant: {{ $app->user?->name ?? '—' }} Submitted: {{ $app->created_at->format('d M Y') }} @if($app->reviewed_at)Reviewed: {{ \Carbon\Carbon::parse($app->reviewed_at)->format('d M Y') }}@endif
@if($app->status === 'rejected' && $app->admin_notes)
Reason: {{ $app->admin_notes }}
@endif
@verbatim @endverbatim
{{-- ── SECTION 1: Personal Details ── --}}
Section 1 — Personal Details of Applicant
Full Name{{ $app->ap_full_name ?? '—' }}
Date of Birth{{ $app->ap_date_of_birth ? \Carbon\Carbon::parse($app->ap_date_of_birth)->format('d M Y') : '—' }}
Gender{{ ucfirst($app->ap_gender ?? '—') }}
Nationality{{ $app->ap_nationality ?? '—' }}
Home Island{{ $app->ap_home_island ?? '—' }}
Phone Number{{ $app->ap_phone_number ?? '—' }}
Email Address{{ $app->ap_email ?? '—' }}
Residential Address{{ $app->ap_residential_address ?? '—' }}
@if($app->applicantProfile)
Documents @if($app->applicantProfile->police_clearance_path) 📄 Police Clearance @endif @if($app->applicantProfile->passport_biodata_path) 📄 Passport Biodata @endif @if($app->applicantProfile->birth_certificate_path) 📄 Birth Certificate @endif @if($app->applicantProfile->national_id_path) 📄 National ID @endif
@endif
{{-- ── SECTION 2: Company Details ── --}}
Section 2 — Company / Business Details
Business Name{{ $app->cd_business_name ?? '—' }}
Registered Name{{ $app->cd_registered_name ?? '—' }}
Nature of Business{{ $app->cd_nature_of_business ?? '—' }}
Registration Number{{ $app->cd_registration_number ?? '—' }}
Company Type{{ $app->cd_company_type ?? '—' }}{{ $app->cd_company_type_other ? ' — '.$app->cd_company_type_other : '' }}
Date Established{{ $app->cd_date_established ? \Carbon\Carbon::parse($app->cd_date_established)->format('d M Y') : '—' }}
Telephone{{ $app->cd_telephone_number ?? '—' }}
Email{{ $app->cd_email_address ?? '—' }}
Main Branch Address{{ $app->cd_main_branch_address ?? '—' }}
@if($cd?->landing_site)
Landing Site{{ $cd->landing_site === 'Other' ? ($cd->landing_site_other ?? $cd->landing_site) : $cd->landing_site }}
@endif @if($cd?->processing_site)
Processing Site{{ $cd->processing_site }}
@endif
@if($cd)
Documents @if($cd->bank_statement_path) 🏦 Bank Statement @endif @if($cd->company_license_path) 📜 Company License @endif
@endif
{{-- ── SECTION 3: Operation Details ── --}}
Section 3 — Fishing Operation Details
Has Vessel{{ $app->od_has_vessel ? 'Yes' : 'No' }}
Foreign Buyer / Company{{ $app->od_supplying_companies ?? '—' }}
Buyer Email{{ $od?->foreign_buyer_email ?? '—' }}
Buyer Phone{{ $od?->foreign_buyer_phone ?? '—' }}
Harvest Islands @php $iNames = $od?->harvestIslands?->pluck('island_name')->filter()->join(', '); $iExtra = $app->od_harvest_islands; echo collect([$iNames, $iExtra])->filter()->join(' | ') ?: '—'; @endphp
Target Fish Families {{ $od?->targetFishFamilies?->map(fn($ff) => ($ff->is_other && $ff->pivot?->other_value) ? $ff->pivot->other_value : $ff->name)->filter()->join(', ') ?: '—' }}
Harvesting Methods {{ $od?->harvestingMethods?->map(fn($hm) => ($hm->is_other && $hm->pivot?->other_value) ? $hm->pivot->other_value : $hm->name)->filter()->join(', ') ?: '—' }}
License Duration{{ $od?->licenseDuration?->name ?? '—' }}
@if($od?->business_plan_path)
Documents 📊 Business Plan
@endif
{{-- ── SECTION 4: Vessel Details ── --}} @if($app->vd_vessel_name)
Section 4 — Vessel Details
Vessel Name{{ $app->vd_vessel_name }}
Vessel Type{{ $app->vd_vessel_type ?? '—' }}
IMO / Reg. Number{{ $app->vd_imo_registration_number ?? '—' }}
Current Flag{{ $app->vd_current_flag ?? '—' }}
Base Port{{ $app->vd_base_port ?? '—' }}
Year Built{{ $app->vd_year_built ?? '—' }}
Registered Length{{ $app->vd_registered_length ? $app->vd_registered_length.' m' : '—' }}
Beam Length{{ $app->vd_beam_length ? $app->vd_beam_length.' m' : '—' }}
Draught{{ $app->vd_draught_length ? $app->vd_draught_length.' m' : '—' }}
Tonnage{{ $app->vd_tonnage ? $app->vd_tonnage.' t' : '—' }}
Max Speed{{ $app->vd_maximum_speed ? $app->vd_maximum_speed.' kts' : '—' }}
Service Speed{{ $app->vd_service_speed ? $app->vd_service_speed.' kts' : '—' }}
Hull Color{{ $app->vd_hull_color ?? '—' }}
Hull Material{{ $app->vd_hull_material ?? '—' }}
No. of Crew{{ $app->vd_number_of_crew ?? '—' }}
Captain / Master{{ $app->vd_captain_master_name ?? '—' }}
Call Sign{{ $app->vd_international_call_sign ?? '—' }}
VMS Number{{ $app->vd_vms_number ?? '—' }}
@if($app->vd_previous_vessel_name)
Previous Vessel Name{{ $app->vd_previous_vessel_name }}
@endif
Fishing Gears Onboard{{ $app->vd_fishing_gears_onboard ?? '—' }}
@php $adminVesselPhotos = array_filter([ $app->operationDetail?->vesselsDetails?->first()?->photo_1, $app->operationDetail?->vesselsDetails?->first()?->photo_2, $app->operationDetail?->vesselsDetails?->first()?->photo_3, $app->operationDetail?->vesselsDetails?->first()?->photo_4, $app->operationDetail?->vesselsDetails?->first()?->photo_5, $app->operationDetail?->vesselsDetails?->first()?->photo_6, ]); @endphp @if(!empty($adminVesselPhotos))
Vessel Photos
@foreach($adminVesselPhotos as $photo) Vessel photo @endforeach
@endif
@else
No vessel declared for this application.
@endif {{-- ── License Issued ── --}} @if($app->license)
✓ License Issued
License Number {{ $app->license->license_number }}
Issue Date {{ $app->license->issue_date?->format('d M Y') ?? '—' }}
Expiry Date {{ $app->license->expiry_date?->format('d M Y') ?? '—' }}
Status {{ $app->license->is_revoked ? 'Revoked' : 'Active' }}
@endif {{-- ── Actions ── --}}
@if($app->status === 'pending')
@csrf @method('PATCH')
@csrf @method('PATCH')
@elseif($app->status === 'reviewed' && !$app->license)
@csrf @method('PATCH')
@csrf @method('PATCH')
@elseif($app->status === 'approved' && !$app->license)
@csrf @method('PATCH')
@elseif($app->status === 'approved' && $app->license) ✓ License Issued @elseif($app->status === 'rejected') ✗ Rejected @elseif($app->status === 'revoked') ⊘ Revoked @endif
{{-- /pdf-doc --}}
{{-- /app-body-inner --}}
{{-- /app-body --}}
{{-- /app-card --}} @empty

No applications found

@endforelse
{{-- ══ 4. FISH FAMILIES ══ --}} @if(isset($fishFamilies) && $fishFamilies->isNotEmpty())

Fish Families

{{ $fishFamilies->count() }}
{{ $fishFamilies->where('is_active',true)->count() }} / {{ $fishFamilies->count() }} visible

Toggle families to control which appear on the applicant's operation details form.

@foreach($fishFamilies->sortBy('is_other') as $family)
{{ $family->name }}
{{ $family->is_active ? 'On' : 'Off' }}
@csrf @method('PATCH')
@endforeach
@endif {{-- ══ 5. LANDING SITES ══ --}} @if(isset($landingSites) && $landingSites->isNotEmpty())

Landing Sites

{{ $landingSites->count() }}
{{ $landingSites->where('is_active',true)->count() }} / {{ $landingSites->count() }} visible

Toggle landing sites to control which appear in the company details form. "Other" always appears automatically.

@foreach($landingSites->sortBy('sort_order') as $site)
{{ $site->name }}
{{ $site->is_active ? 'On' : 'Off' }}
@csrf @method('PATCH')
@endforeach

Add New Landing Site

@csrf
@endif {{-- ══ 6. AUDIT LOGS ══ --}}

Audit Logs

{{ $auditLogs->total() }}
Clear
@forelse($auditLogs as $log)
{{ $log->action }}
{{ $log->details }}
by {{ $log->user?->name ?? 'System' }}
{{ $log->created_at->format('d M Y H:i') }}
@empty

No audit logs yet

@endforelse
@if($auditLogs->hasPages())
@if($auditLogs->onFirstPage()) ← Prev @else ← Prev @endif @php $cur=$auditLogs->currentPage(); $last=$auditLogs->lastPage(); $grp=ceil($cur/5); $start=(($grp-1)*5)+1; $end=min($grp*5,$last); @endphp @for($i=$start;$i<=$end;$i++) @if($i==$cur){{ $i }} @else{{ $i }}@endif @endfor @if($auditLogs->hasMorePages()) Next → @else Next → @endif
Showing {{ $auditLogs->firstItem() }}–{{ $auditLogs->lastItem() }} of {{ $auditLogs->total() }} entries
@endif
{{-- REVOKE MODAL --}} {{-- LICENSE PREVIEW MODAL --}}
License Preview
Fishing License Certificate
Page 1 — Certificate
Page 2 — Conditions
Full Document
Preparing…
@push('scripts') @endpush @endsection