From fcc1ab0c0435865a07c70364e7c32470f65207e6 Mon Sep 17 00:00:00 2001
From: LailaWulandarii
Date: Thu, 26 Feb 2026 08:50:55 +0700
Subject: [PATCH 1/3] feat: add foreign key id_user to paket_fotos table for
user association
---
...12053_add_id_user_to_paket_fotos_table.php | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 database/migrations/2026_02_25_212053_add_id_user_to_paket_fotos_table.php
diff --git a/database/migrations/2026_02_25_212053_add_id_user_to_paket_fotos_table.php b/database/migrations/2026_02_25_212053_add_id_user_to_paket_fotos_table.php
new file mode 100644
index 0000000..636a6cb
--- /dev/null
+++ b/database/migrations/2026_02_25_212053_add_id_user_to_paket_fotos_table.php
@@ -0,0 +1,28 @@
+foreignId('id_user')->after('id_paket')->nullable()->constrained('users', 'id_user')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('paket_fotos', function (Blueprint $table) {
+ //
+ });
+ }
+};
From 6fa0d1a1dab9b07275c56696fce02489dd2c800b Mon Sep 17 00:00:00 2001
From: LailaWulandarii
Date: Fri, 27 Feb 2026 08:51:26 +0700
Subject: [PATCH 2/3] feat: associate PaketFoto with User model and update
FotoController for user ID handling
---
app/Http/Controllers/Admin/FotoController.php | 7 +++++++
app/Models/PaketFoto.php | 5 +++++
app/Models/User.php | 4 ++++
3 files changed, 16 insertions(+)
diff --git a/app/Http/Controllers/Admin/FotoController.php b/app/Http/Controllers/Admin/FotoController.php
index c3c95dd..b55b87a 100644
--- a/app/Http/Controllers/Admin/FotoController.php
+++ b/app/Http/Controllers/Admin/FotoController.php
@@ -7,6 +7,7 @@
use App\Models\PaketFoto;
use App\Http\Requests\Admin\FotoRequest; // Gunakan Request baru
use Illuminate\Support\Facades\Storage;
+use Illuminate\Support\Facades\Auth;
class FotoController extends Controller
{
@@ -20,12 +21,14 @@ public function index()
public function store(FotoRequest $request)
{
$data = $request->validated();
+ $data['id_user'] = Auth::id();
if ($request->hasFile('foto')) {
$file = $request->file('foto');
$filename = time() . '_' . $file->getClientOriginalName();
$path = $file->storeAs('img/foto', $filename, 'public');
$data['foto'] = $path;
}
+
PaketFoto::create($data);
return redirect()->back()->with('success', 'Paket foto baru berhasil ditambahkan!');
}
@@ -34,6 +37,7 @@ public function update(FotoRequest $request, string $id)
{
$paket = PaketFoto::findOrFail($id);
$data = $request->validated();
+ $data['id_user'] = Auth::id();
if ($request->hasFile('foto')) {
if ($paket->foto) {
Storage::disk('public')->delete($paket->foto);
@@ -49,6 +53,9 @@ public function update(FotoRequest $request, string $id)
public function destroy(string $id)
{
$paket = PaketFoto::findOrFail($id);
+ if (Auth::user()->role !== 'admin_foto' && Auth::user()->role !== 'owner') {
+ return redirect()->back()->with('error', 'Anda tidak memiliki akses untuk menghapus paket ini!');
+ }
if ($paket->foto) {
Storage::disk('public')->delete($paket->foto);
}
diff --git a/app/Models/PaketFoto.php b/app/Models/PaketFoto.php
index 4bd7e9a..28d87f7 100644
--- a/app/Models/PaketFoto.php
+++ b/app/Models/PaketFoto.php
@@ -18,10 +18,15 @@ class PaketFoto extends Model
'harga',
'foto',
'durasi',
+ 'id_user',
];
public function booking()
{
return $this->hasMany(BookingFoto::class, 'id_paket');
}
+ public function user()
+ {
+ return $this->belongsTo(User::class, 'id_user');
+ }
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 6496b9b..aba13d3 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -27,4 +27,8 @@ class User extends Authenticatable
'password',
'remember_token',
];
+ public function paketFotos()
+ {
+ return $this->hasMany(PaketFoto::class, 'id_user');
+ }
}
From a58121455c9b2a21da8524f1f0f3c615b31c3c1b Mon Sep 17 00:00:00 2001
From: LailaWulandarii
Date: Sat, 28 Feb 2026 08:51:55 +0700
Subject: [PATCH 3/3] feat: display last modified by user in foto modal
---
.../views/admin/paket-foto/partials/modal-show-foto.blade.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/resources/views/admin/paket-foto/partials/modal-show-foto.blade.php b/resources/views/admin/paket-foto/partials/modal-show-foto.blade.php
index fbb3579..f55a472 100644
--- a/resources/views/admin/paket-foto/partials/modal-show-foto.blade.php
+++ b/resources/views/admin/paket-foto/partials/modal-show-foto.blade.php
@@ -61,6 +61,8 @@ class="custom-img-box-foto d-flex align-items-center justify-content-center text
+ Terakhir diubah oleh:
+ {{ $f->user->nama ?? 'Admin' }}