diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php new file mode 100644 index 0000000..3455373 --- /dev/null +++ b/app/Http/Controllers/BookingController.php @@ -0,0 +1,119 @@ +generateCode(); + } else { + return $kode_unik; + } + } + + /** + * Display a listing of the resource. + */ + public function index() + { + // + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + try { + $request->validate([ + 'nama_lengkap' => ['required', 'string'], + 'email' => ['required', 'string'], + 'no_telp' => ['required', 'string'], + 'tgl_booking' => ['required', 'string'], + 'deskripsi_tambahan' => ['required', 'string'] + ]); + + $kode_unik = $this->generateCode(); + + BookingModel::create([ + 'nama_lengkap' => $request->nama_lengkap, + 'email' => $request->email, + 'no_telp' => $request->no_telp, + 'tgl_booking' => $request->tgl_booking, + 'deskripsi_tambahan' => $request->deskripsi_tambahan, + 'kode_unik' => $kode_unik + ]); + + return response()->json([ + 'status' => true, + 'msg' => 'Booking success!' + ]); + } catch(\Exception $e) { + return response()->json([ + 'status' => false, + 'msg' => $e->getMessage() + ]); + } + + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/BookingModel.php b/app/Models/BookingModel.php new file mode 100644 index 0000000..283ae5b --- /dev/null +++ b/app/Models/BookingModel.php @@ -0,0 +1,40 @@ + 'string', + ]; + + protected static function boot() + { + parent::boot(); + static::creating(function ($model) { + if (empty($model->id_booking)) { + $model->id_booking = Str::uuid(); + } + }); + } +} diff --git a/database/migrations/2026_03_26_204017_create_booking_table.php b/database/migrations/2026_03_26_204017_create_booking_table.php new file mode 100644 index 0000000..74e303c --- /dev/null +++ b/database/migrations/2026_03_26_204017_create_booking_table.php @@ -0,0 +1,31 @@ +uuid('id_booking')->primary(); + $table->string('nama_lengkap'); + $table->string('email'); + $table->string('no_telp'); + $table->string('kode_unik', 6); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('booking'); + } +}; diff --git a/database/migrations/2026_03_26_204517_add_column_in_booking_table.php b/database/migrations/2026_03_26_204517_add_column_in_booking_table.php new file mode 100644 index 0000000..0095216 --- /dev/null +++ b/database/migrations/2026_03_26_204517_add_column_in_booking_table.php @@ -0,0 +1,28 @@ +date('tgl_booking')->after('no_telp'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('booking', function (Blueprint $table) { + $table->dropColumn('tgl_booking'); + }); + } +}; diff --git a/database/migrations/2026_03_26_225718_add_column_in_booking_table.php b/database/migrations/2026_03_26_225718_add_column_in_booking_table.php new file mode 100644 index 0000000..1e6c63d --- /dev/null +++ b/database/migrations/2026_03_26_225718_add_column_in_booking_table.php @@ -0,0 +1,28 @@ +text('deskripsi_tambahan')->after('no_telp'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('booking', function (Blueprint $table) { + $table->dropColumn('deskripsi_tambahan'); + }); + } +}; diff --git a/resources/views/user/layouts/index.blade.php b/resources/views/user/layouts/index.blade.php index 3a1e1c4..92a2f59 100644 --- a/resources/views/user/layouts/index.blade.php +++ b/resources/views/user/layouts/index.blade.php @@ -7,6 +7,7 @@