@extends('layouts.app')
@section('page_title','My Leave')
@section('page_subtitle','Submit leave requests and track approval status.')
@section('content')
<div class="card"><h3>Request Leave</h3><form method="POST" action="{{ route('user.leaves.store') }}" enctype="multipart/form-data">@csrf<div class="form-row"><div class="field"><label>Leave Type</label><select name="leave_type_id" required>@foreach($leaveTypes as $type)<option value="{{ $type->id }}">{{ $type->name }} ({{ $type->annual_days }} days)</option>@endforeach</select></div><div class="field"><label>Start Date</label><input class="input" type="date" name="start_date" required></div><div class="field"><label>End Date</label><input class="input" type="date" name="end_date" required></div><div class="field"><label>Supporting Document</label><input class="input" type="file" name="document"></div></div><div class="field"><label>Reason</label><textarea name="reason"></textarea></div><button class="btn">Submit Request</button></form></div>
<div class="card"><h3>Leave History</h3><table class="table"><tr><th>Type</th><th>Dates</th><th>Days</th><th>Status</th><th>HR Comment</th></tr>@forelse($leaves as $leave)<tr><td>{{ $leave->leaveType?->name }}</td><td>{{ $leave->start_date?->format('d M Y') }} - {{ $leave->end_date?->format('d M Y') }}</td><td>{{ $leave->total_days }}</td><td><span class="badge {{ $leave->status==='approved'?'green':($leave->status==='rejected'?'red':'yellow') }}">{{ ucfirst($leave->status) }}</span></td><td>{{ $leave->admin_comment }}</td></tr>@empty<tr><td colspan="5"><div class="empty">No leave requests yet.</div></td></tr>@endforelse</table><div class="pagination">{{ $leaves->links() }}</div></div>
@endsection
