@extends('layouts.app', ['class' => 'g-sidenav-show bg-gray-100']) @section('content') @include('layouts.navbars.auth.topnav', ['title' => 'Edit Kedatangan Tamu']) @php // Check user roles $isResepsionis = session('user')->idroles === 'rspion'; $isSecurity = session('user')->idroles === 'scrity'; $isFullInput = $list->input_type === 'full'; // Define field access by role $resepsionisAllowedFields = [ 'NamaTamu', 'KTP_SIM_IDCARD', 'Instansi', 'JumlahPersonel', 'department_id', 'subdepartment_id', 'PICYangDituju', 'qty_earplug', 'qty_shoescover', 'qty_hairnet' ]; $securityAllowedFields = [ 'Nomor_Polisi', 'jeniskendaraan_id', 'typekendaraan_id', 'TanggalMasuk', 'JamMasuk', 'TanggalKeluar', 'JamKeluar', 'KTP_SIM_IDCARD' ]; function isFieldAllowed($fieldName, $isResepsionis, $isSecurity, $isFullInput, $resepsionisAllowedFields, $securityAllowedFields) { if ($isFullInput) { // If full input was selected, only security can edit if ($isSecurity) { return true; } return false; } else { // Partial input logic if ($isResepsionis) { return in_array($fieldName, $resepsionisAllowedFields); } elseif ($isSecurity) { return in_array($fieldName, $securityAllowedFields); } } return true; } @endphp
Mode Input:
{{ $isFullInput ? 'Input Lengkap' : 'Input Parsial' }}
@if ($isFullInput && !$isSecurity)
Data ini hanya dapat diubah oleh Security karena menggunakan mode Input Lengkap
@endif
@csrf @method('PUT')
@php $sections = [ 'Kedatangan Tamu' => [ ['name' => 'Nomor_Polisi', 'label' => 'Nopol (A 1234 AB)', 'type' => 'text', 'placeholder' => 'ex.: A 1234 AB', 'col' => 6], ['name' => 'TanggalMasuk', 'label' => 'Tanggal Masuk', 'type' => 'date', 'col' => 3], ['name' => 'JamMasuk', 'label' => 'Jam Masuk (hh:mm)', 'type' => 'time', 'col' => 2], ['name' => 'jeniskendaraan_id', 'label' => 'Jenis Kendaraan', 'type' => 'enum', 'query' => 'SELECT id, jenis_kendaraan FROM mst_jeniskendaraan', 'col' => 3], ['name' => 'typekendaraan_id', 'label' => 'Type Kendaraan', 'type' => 'enum', 'query' => 'SELECT id, Nama_typekendaraan FROM mst_typekendaraan', 'col' => 3], ['name' => 'TanggalKeluar', 'label' => 'Tanggal Keluar', 'type' => 'date', 'col' => 3], ['name' => 'JamKeluar', 'label' => 'Jam Keluar (hh:mm)', 'type' => 'time', 'col' => 2], ], 'Identitas Tamu' => [ ['name' => 'NamaTamu', 'label' => 'Nama Tamu', 'type' => 'text', 'placeholder' => 'Ex.: Nama Tamu', 'col' => 3], ['name' => 'KTP_SIM_IDCARD', 'label' => 'KTP/SIM/ID Card', 'type' => 'text', 'placeholder' => 'Ex.: xxxx', 'col' => 3], ['name' => 'Instansi', 'label' => 'Instansi', 'type' => 'text', 'placeholder' => 'Ex.: Instansi', 'col' => 3], ['name' => 'JumlahPersonel', 'label' => 'Jumlah Personel', 'type' => 'number', 'placeholder' => 'Ex.: xxxx', 'col' => 3], ], 'PIC di MSJ' => [ ['name' => 'PICYangDituju', 'label' => 'PIC yang dituju', 'type' => 'text', 'placeholder' => 'Ex.: xxxx', 'col' => 3], ['name' => 'department_id', 'label' => 'Department', 'type' => 'enum', 'query' => 'SELECT id, nama_department FROM mst_department', 'col' => 3], ['name' => 'subdepartment_id', 'label' => 'Subdepartment', 'type' => 'enum', 'query' => 'SELECT id, nama_subdepartment FROM mst_subdepartment', 'col' => 3], ], 'Perlengkapan K3' => [ ['name' => 'qty_hairnet', 'label' => 'Hairnet', 'type' => 'number', 'placeholder' => '0', 'col' => 1, 'note' => 'Jumlah Hairnet yang dipinjam'], ['name' => 'qty_shoescover', 'label' => 'Shoes Cover', 'type' => 'number', 'placeholder' => '0', 'col' => 1, 'note' => 'Jumlah Shoes Cover yang dipinjam'], ['name' => 'qty_earplug', 'label' => 'Ear Plug', 'type' => 'number', 'placeholder' => '0', 'col' => 1, 'note' => 'Jumlah Ear Plug yang dipinjam'], ], ]; @endphp @foreach ($sections as $title => $fields)

{{ $title }}


@foreach ($fields as $field)
@if ($field['type'] === 'enum') @else @endif @error($field['name'])
{{ $message }}
@enderror
@if($field['name'] === 'JamMasuk' && !$isResepsionis)
@endif @if($field['name'] === 'JamKeluar' && !$isResepsionis)
@endif @endforeach
@endforeach
@endsection @push('js') @endpush