From 253997dfa4491c666f55c2b2d1f9f7621c72953c Mon Sep 17 00:00:00 2001 From: Gunawan19621 Date: Fri, 24 Nov 2023 09:58:10 +0700 Subject: [PATCH] update id tambahan untuk transfer dan disposal --- app/Http/Controllers/TransferController.php | 10 +------- .../Transfer/ValidasiCreateTransfer.php | 24 +++++++++++++++---- .../Transfer/ValidasiUpdateTransfer.php | 24 +++++++++++++++---- app/Models/Transfer.php | 2 +- .../History/Pengembalian/index.blade.php | 2 +- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/TransferController.php b/app/Http/Controllers/TransferController.php index ca41b24..cf92d61 100644 --- a/app/Http/Controllers/TransferController.php +++ b/app/Http/Controllers/TransferController.php @@ -30,15 +30,6 @@ class TransferController extends Controller return view('dashboard.Transfer.index', $data); } - // public function index() - // { - // $data = [ - // 'transfer' => Transfer::orderBy('created_at', 'desc')->get(), - // 'active' => 'menu-transfer', - // ]; - // return view('dashboard.Transfer.index', $data); - // } - /** * Show the form for creating a new resource. */ @@ -59,6 +50,7 @@ class TransferController extends Controller */ public function store(ValidasiCreateTransfer $request) { + // dd($request); try { // Mendapatkan informasi pengguna yang sedang login $currentUser = Auth::user(); diff --git a/app/Http/Requests/Transfer/ValidasiCreateTransfer.php b/app/Http/Requests/Transfer/ValidasiCreateTransfer.php index 3dedfee..f0119a0 100644 --- a/app/Http/Requests/Transfer/ValidasiCreateTransfer.php +++ b/app/Http/Requests/Transfer/ValidasiCreateTransfer.php @@ -22,11 +22,25 @@ class ValidasiCreateTransfer extends FormRequest public function rules(): array { return [ - 'peti_id' => 'nullable', // Optional, peti_id harus ada di tabel petis - 'source_warehouse' => 'nullable', // Optional, source_warehouse harus ada di tabel m_warehouses - 'destination_warehouse' => 'nullable', // Optional, destination_warehouse harus ada di tabel m_warehouses - 'name_customer' => 'nullable', // Optional, name_customer harus ada di tabel customers - 'date' => 'nullable', // Optional, harus berupa tanggal + 'peti_id' => 'required', // Required, peti_id harus ada di tabel petis + 'source_warehouse' => 'required', // Optional, source_warehouse harus ada di tabel m_warehouses + 'destination_warehouse' => 'required', // Optional, destination_warehouse harus ada di tabel m_warehouses + 'name_customer' => 'required', // Optional, name_customer harus ada di tabel customers + 'date' => 'required', // Optional, harus berupa tanggal + ]; + } + + /** + * Get the error messages for the defined validation rules. + */ + public function messages(): array + { + return [ + 'peti_id.required' => 'Peti harus diisi', + 'source_warehouse.required' => 'Source Warehouse harus diisi', + 'destination_warehouse.required' => 'Destination Warehouse harus diisi', + 'name_customer.required' => 'Nama Customer harus diisi', + 'date.required' => 'Tanggal harus diisi', ]; } } diff --git a/app/Http/Requests/Transfer/ValidasiUpdateTransfer.php b/app/Http/Requests/Transfer/ValidasiUpdateTransfer.php index 9841104..a24c9e4 100644 --- a/app/Http/Requests/Transfer/ValidasiUpdateTransfer.php +++ b/app/Http/Requests/Transfer/ValidasiUpdateTransfer.php @@ -22,11 +22,25 @@ class ValidasiUpdateTransfer extends FormRequest public function rules(): array { return [ - 'peti_id' => 'nullable', // Optional, peti_id harus ada di tabel petis - 'source_warehouse' => 'nullable', // Optional, source_warehouse harus ada di tabel m_warehouses - 'destination_warehouse' => 'nullable', // Optional, destination_warehouse harus ada di tabel m_warehouses - 'name_customer' => 'nullable', // Optional, name_customer harus ada di tabel customers - 'date' => 'nullable', // Optional, harus berupa tanggal + 'peti_id' => 'required', // Required, peti_id harus ada di tabel petis + 'source_warehouse' => 'required', // Optional, source_warehouse harus ada di tabel m_warehouses + 'destination_warehouse' => 'required', // Optional, destination_warehouse harus ada di tabel m_warehouses + 'name_customer' => 'required', // Optional, name_customer harus ada di tabel customers + 'date' => 'required', // Optional, harus berupa tanggal + ]; + } + + /** + * Get the error messages for the defined validation rules. + */ + public function messages(): array + { + return [ + 'peti_id.required' => 'Peti harus diisi', + 'source_warehouse.required' => 'Source Warehouse harus diisi', + 'destination_warehouse.required' => 'Destination Warehouse harus diisi', + 'name_customer.required' => 'Nama Customer harus diisi', + 'date.required' => 'Tanggal harus diisi', ]; } } diff --git a/app/Models/Transfer.php b/app/Models/Transfer.php index 2372bd2..744dbef 100644 --- a/app/Models/Transfer.php +++ b/app/Models/Transfer.php @@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; class Transfer extends Model { - use HasFactory, SoftDeletes, UUID; + use HasFactory, SoftDeletes; protected $table = 'transfers'; protected $fillable = [ diff --git a/resources/views/dashboard/History/Pengembalian/index.blade.php b/resources/views/dashboard/History/Pengembalian/index.blade.php index 16034c5..ce4f7ec 100644 --- a/resources/views/dashboard/History/Pengembalian/index.blade.php +++ b/resources/views/dashboard/History/Pengembalian/index.blade.php @@ -74,7 +74,7 @@ @if ($data->kondisi_peti) - {{ $data->kondisi_peti }} + {{ $data->kondisi_peti->nama_kondisi }} @else

-

@endif