@section('title', 'Leave')
{{ __('Create New Leave') }}
{!! Form::model($leave, [ 'url' => $leave->exists ? route('backend.leave.update', $leave->id) : route('backend.leave.store'), 'method' => $leave->exists ? 'PUT' : 'POST', 'id' => $leave->exists ? 'leaveUpdate' : 'leaveCreate', 'novalidate' => true, ]) !!}
{!! Form::label('name', 'Employee Name', ['class' => 'form-label']) !!} * @if (auth()->user()->hasRole('super-admin')) {!! Form::select( 'employee_id', ['' => 'Select Type'] + $users->mapWithKeys(function ($employee) { return [$employee->id => $employee->user->name ?? '']; })->toArray(), old('employee_id', $leave->employee_id), [ 'class' => 'form-control form-select select2', 'required' => true, ], ) !!} @else {!! Form::hidden('employee_id', auth()->user()->id) !!} {!! Form::text('employee_name', auth()->user()->name, ['class' => 'form-control', 'readonly']) !!} @endif
{!! Form::label('name', 'Leave Status', ['class' => 'form-label']) !!} * {!! Form::select( 'leave_status', ['' => 'Select Status'] + [ 'full day' => 'Full Day', 'half day' => 'Half Day', 'many days' => 'Many Days', ], old('leave_status', $leave->leave_status), [ 'class' => 'form-control form-select select2', 'id' => 'leave_status', 'required' => true, ], ) !!}
{!! Form::label('name', 'Leave Type', ['class' => 'form-label']) !!} * {!! Form::select( 'leave_type_id', ['' => 'Select Leave Type'] + $leave_type_id->pluck('category', 'id')->toArray(), old('leave_type_id', $leave->leave_type_id), [ 'class' => 'form-control form-select select2', 'required' => true, ], ) !!}
{!! Form::label('name', 'Start Date', ['class' => 'form-label']) !!} * {!! Form::date('start_date', old('start_date', $leave->start_date), [ 'class' => 'form-control', 'id' => 'start_date', ]) !!}
{!! Form::label('name', 'End Date', ['class' => 'form-label']) !!} * {!! Form::date('end_date', old('end_date', $leave->end_date), [ 'class' => 'form-control', 'id' => 'end_date', ]) !!}
{!! Form::label('name', 'Total Days', ['class' => 'form-label']) !!} * {!! Form::number('total_days', old('total_days', $leave->total_days), [ 'class' => 'form-control', 'id' => 'total_days', 'required' => true, ]) !!}
@if (auth()->user()->hasRole('super-admin'))
{!! Form::label('name', 'Status', ['class' => 'form-label']) !!} * {!! Form::select( 'status', ['' => 'Select Status'] + [ 'pending' => 'Pending', 'approved' => 'Approved', 'rejected' => 'Rejected', ], old('status', $leave->status), [ 'class' => 'form-control form-select select2', 'required' => true, ], ) !!}
@else {!! Form::hidden('status', 'pending') !!} @endif
{!! Form::label('name', 'Reason', ['class' => 'form-label']) !!} * {!! Form::textarea('reason', old('reason', $leave->reason), [ 'class' => 'form-control', 'required' => true, ]) !!}
{!! Form::submit($leave->exists ? 'Update' : 'Create', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
@push('css') @endpush @push('js') {{-- Create & Update Ajax Script --}} @endpush