Compare commits
10 Commits
d4bb643143
...
580c319c55
| Author | SHA1 | Date |
|---|---|---|
|
|
580c319c55 | |
|
|
6939000238 | |
|
|
a58121455c | |
|
|
6fa0d1a1da | |
|
|
fcc1ab0c04 | |
|
|
ddaca1ab98 | |
|
|
24b3a4b194 | |
|
|
706064056a | |
|
|
8608a7f4fa | |
|
|
a5f4071072 |
|
|
@ -7,6 +7,7 @@
|
||||||
use App\Models\PaketFoto;
|
use App\Models\PaketFoto;
|
||||||
use App\Http\Requests\Admin\FotoRequest; // Gunakan Request baru
|
use App\Http\Requests\Admin\FotoRequest; // Gunakan Request baru
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class FotoController extends Controller
|
class FotoController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -20,12 +21,14 @@ public function index()
|
||||||
public function store(FotoRequest $request)
|
public function store(FotoRequest $request)
|
||||||
{
|
{
|
||||||
$data = $request->validated();
|
$data = $request->validated();
|
||||||
|
$data['id_user'] = Auth::id();
|
||||||
if ($request->hasFile('foto')) {
|
if ($request->hasFile('foto')) {
|
||||||
$file = $request->file('foto');
|
$file = $request->file('foto');
|
||||||
$filename = time() . '_' . $file->getClientOriginalName();
|
$filename = time() . '_' . $file->getClientOriginalName();
|
||||||
$path = $file->storeAs('img/foto', $filename, 'public');
|
$path = $file->storeAs('img/foto', $filename, 'public');
|
||||||
$data['foto'] = $path;
|
$data['foto'] = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaketFoto::create($data);
|
PaketFoto::create($data);
|
||||||
return redirect()->back()->with('success', 'Paket foto baru berhasil ditambahkan!');
|
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);
|
$paket = PaketFoto::findOrFail($id);
|
||||||
$data = $request->validated();
|
$data = $request->validated();
|
||||||
|
$data['id_user'] = Auth::id();
|
||||||
if ($request->hasFile('foto')) {
|
if ($request->hasFile('foto')) {
|
||||||
if ($paket->foto) {
|
if ($paket->foto) {
|
||||||
Storage::disk('public')->delete($paket->foto);
|
Storage::disk('public')->delete($paket->foto);
|
||||||
|
|
@ -49,6 +53,9 @@ public function update(FotoRequest $request, string $id)
|
||||||
public function destroy(string $id)
|
public function destroy(string $id)
|
||||||
{
|
{
|
||||||
$paket = PaketFoto::findOrFail($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) {
|
if ($paket->foto) {
|
||||||
Storage::disk('public')->delete($paket->foto);
|
Storage::disk('public')->delete($paket->foto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,15 @@ class PaketFoto extends Model
|
||||||
'harga',
|
'harga',
|
||||||
'foto',
|
'foto',
|
||||||
'durasi',
|
'durasi',
|
||||||
|
'id_user',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function booking()
|
public function booking()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingFoto::class, 'id_paket');
|
return $this->hasMany(BookingFoto::class, 'id_paket');
|
||||||
}
|
}
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'id_user');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,8 @@ class User extends Authenticatable
|
||||||
'password',
|
'password',
|
||||||
'remember_token',
|
'remember_token',
|
||||||
];
|
];
|
||||||
|
public function paketFotos()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PaketFoto::class, 'id_user');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('paket_fotos', function (Blueprint $table) {
|
||||||
|
$table->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) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||||
<button class="btn icon btn-warning btn-action disabled"
|
<button class="btn icon btn-warning btn-action disabled"
|
||||||
style="cursor: not-allowed !important; pointer-events: auto !important;"
|
style="opacity: 0.5;cursor: not-allowed !important; pointer-events: auto !important;"
|
||||||
type="button" disabled>
|
type="button" disabled>
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||||
<button class="btn icon btn-danger btn-action disabled"
|
<button class="btn icon btn-danger btn-action disabled"
|
||||||
style="cursor: not-allowed !important; pointer-events: auto !important;"
|
style="opacity: 0.5;cursor: not-allowed !important; pointer-events: auto !important;"
|
||||||
type="button" disabled>
|
type="button" disabled>
|
||||||
<i class="bi bi-trash"></i>
|
<i class="bi bi-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -175,7 +175,7 @@
|
||||||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||||
<button class="btn icon btn-warning btn-action disabled"
|
<button class="btn icon btn-warning btn-action disabled"
|
||||||
style="cursor: not-allowed !important; pointer-events: auto !important;"
|
style="opacity: 0.5;cursor: not-allowed !important; pointer-events: auto !important;"
|
||||||
type="button" disabled>
|
type="button" disabled>
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||||
<button class="btn icon btn-danger btn-action disabled"
|
<button class="btn icon btn-danger btn-action disabled"
|
||||||
style="cursor: not-allowed !important; pointer-events: auto !important;"
|
style="opacity: 0.5;cursor: not-allowed !important; pointer-events: auto !important;"
|
||||||
type="button" disabled>
|
type="button" disabled>
|
||||||
<i class="bi bi-trash"></i>
|
<i class="bi bi-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ class="custom-img-box-foto d-flex align-items-center justify-content-center text
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<p class="x-small text-muted mb-0">Terakhir diubah oleh:</strong>
|
||||||
|
{{ $f->user->nama ?? 'Admin' }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -113,21 +113,48 @@ class="badge {{ $p->status_label->class }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer border-top-0 pt-2 px-2">
|
<div class="modal-footer border-top-0 pt-2 px-2">
|
||||||
<div class="d-flex w-100 gap-2">
|
<div class="d-flex w-100 gap-2">
|
||||||
|
@php
|
||||||
|
$hasAccess = Auth::user()->role == 'admin_buket' || Auth::user()->role == 'pemilik';
|
||||||
|
@endphp
|
||||||
@if ($p->status_transaksi == 'menunggu_verifikasi')
|
@if ($p->status_transaksi == 'menunggu_verifikasi')
|
||||||
<button type="button" class="btn btn-danger flex-fill tolak"
|
@if ($hasAccess)
|
||||||
onclick="prosesBuket(this, 'tolak', '{{ $p->id_transaksi }}', 'buket')">
|
<button type="button" class="btn btn-danger flex-fill tolak"
|
||||||
Tolak Pesanan
|
onclick="prosesBuket(this, 'tolak', '{{ $p->id_transaksi }}', 'buket')">
|
||||||
</button>
|
Tolak Pesanan
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<button type="button" class="btn btn-danger flex-fill tolak disabled"
|
||||||
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
|
title="Hanya Admin Buket dan Pemilik yang dapat menolak pesanan ini">
|
||||||
|
Tolak Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
<button type="button" class="btn btn-success flex-fill terima"
|
@if ($hasAccess)
|
||||||
onclick="prosesBuket(this, 'terima', '{{ $p->id_transaksi }}', 'buket')">
|
<button type="button" class="btn btn-success flex-fill terima"
|
||||||
Terima Pesanan
|
onclick="prosesBuket(this, 'terima', '{{ $p->id_transaksi }}', 'buket')">
|
||||||
</button>
|
Terima Pesanan
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<button type="button" class="btn btn-success flex-fill terima disabled"
|
||||||
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
|
title="Hanya Admin Buket dan Pemilik yang dapat menerima pesanan ini">
|
||||||
|
Terima Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
@elseif ($p->status_transaksi == 'diterima')
|
@elseif ($p->status_transaksi == 'diterima')
|
||||||
<button type="button" class="btn btn-primary flex-fill terima"
|
@if ($hasAccess)
|
||||||
onclick="prosesBuket(this, 'selesai', '{{ $p->id_transaksi }}', 'buket')">
|
<button type="button" class="btn btn-primary flex-fill terima"
|
||||||
Selesaikan Pesanan
|
onclick="prosesBuket(this, 'selesai', '{{ $p->id_transaksi }}', 'buket')">
|
||||||
</button>
|
Selesaikan Pesanan
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<button type="button" class="btn btn-primary flex-fill terima disabled"
|
||||||
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
|
title="Hanya Admin Buket dan Pemilik yang dapat menyelesaikan pesanan ini">
|
||||||
|
Selesaikan Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -108,21 +108,48 @@ class="badge {{ $p->status_label->class }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer border-top-0 pt-2 px-2">
|
<div class="modal-footer border-top-0 pt-2 px-2">
|
||||||
<div class="d-flex w-100 gap-2">
|
<div class="d-flex w-100 gap-2">
|
||||||
|
@php
|
||||||
|
$hasAccess = Auth::user()->role == 'admin_foto' || Auth::user()->role == 'pemilik';
|
||||||
|
@endphp
|
||||||
@if ($p->status_booking == 'menunggu_verifikasi')
|
@if ($p->status_booking == 'menunggu_verifikasi')
|
||||||
<button type="button" class="btn btn-danger flex-fill tolak"
|
@if ($hasAccess)
|
||||||
onclick="prosesFoto(this, 'tolak', '{{ $p->id_booking }}', 'foto')">
|
<button type="button" class="btn btn-danger flex-fill tolak"
|
||||||
Tolak Pesanan
|
onclick="prosesFoto(this, 'tolak', '{{ $p->id_booking }}', 'foto')">
|
||||||
</button>
|
Tolak Pesanan
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<button type="button" class="btn btn-danger flex-fill tolak disabled"
|
||||||
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
|
title="Hanya Admin Foto dan Pemilik yang dapat menolak pesanan ini">
|
||||||
|
Tolak Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
<button type="button" class="btn btn-success flex-fill terima"
|
@if ($hasAccess)
|
||||||
onclick="prosesFoto(this, 'terima', '{{ $p->id_booking }}', 'foto')">
|
<button type="button" class="btn btn-success flex-fill terima"
|
||||||
Terima Pesanan
|
onclick="prosesFoto(this, 'terima', '{{ $p->id_booking }}', 'foto')">
|
||||||
</button>
|
Terima Pesanan
|
||||||
@elseif ($p->status_booking == 'diterima')
|
</button>
|
||||||
<button type="button" class="btn btn-primary flex-fill terima"
|
@else
|
||||||
onclick="prosesFoto(this, 'selesai', '{{ $p->id_booking }}', 'foto')">
|
<button type="button" class="btn btn-success flex-fill terima disabled"
|
||||||
Selesaikan Pesanan
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
</button>
|
title="Hanya Admin Foto dan Pemilik yang dapat menerima pesanan ini">
|
||||||
|
Terima Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
@elseif ($p->status_transaksi == 'diterima')
|
||||||
|
@if ($hasAccess)
|
||||||
|
<button type="button" class="btn btn-primary flex-fill terima"
|
||||||
|
onclick="prosesFoto(this, 'selesai', '{{ $p->id_booking }}', 'foto')">
|
||||||
|
Selesaikan Pesanan
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<button type="button" class="btn btn-primary flex-fill terima disabled"
|
||||||
|
style="cursor: not-allowed !important; pointer-events: auto !important; opacity: 0.5;"
|
||||||
|
title="Hanya Admin Foto dan Pemilik yang dapat menyelesaikan pesanan ini">
|
||||||
|
Selesaikan Pesanan
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{{-- RIWAYAT BUKET --}}
|
{{-- RIWAYAT BUKET --}}
|
||||||
<div class="modal fade text-left" id="riwayatBuket{{ $rb->id_transaksi }}" tabindex="-1" role="dialog"
|
<div class="modal fade text-left" id="riwayatBuket{{ $rb->id_transaksi }}" tabindex="-1" role="dialog"
|
||||||
aria-labelledby="myModalLabel1" aria-hidden="true">
|
aria-labelledby="myModalLabel1" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
<div class=" modal-xl" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,11 @@ class="sidebar-item {{ request()->is('admin/beranda', 'admin/beranda-pemilik') ?
|
||||||
style="min-width: 150px;">
|
style="min-width: 150px;">
|
||||||
<li class="dropdown-header text-center">
|
<li class="dropdown-header text-center">
|
||||||
<h6 class="mb-0 text-dark">{{ Auth::user()->username ?? 'Admin' }}</h6>
|
<h6 class="mb-0 text-dark">{{ Auth::user()->username ?? 'Admin' }}</h6>
|
||||||
<small class="text-muted">{{ ucfirst(Auth::user()->role ?? 'Administrator') }}</small>
|
<span
|
||||||
|
class="badge rounded-pill px-3 py-2 mt-2
|
||||||
|
{{ Auth::user()->role == 'admin_buket' ? 'bg-success-subtle' : 'bg-warning-subtle' }}">
|
||||||
|
{{ str_replace('_', ' ', Auth::user()->role) }}
|
||||||
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<hr class="dropdown-divider mt-0">
|
<hr class="dropdown-divider mt-0">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue