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\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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,8 @@ class User extends Authenticatable
|
|||
'password',
|
||||
'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"
|
||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||
<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>
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||
<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>
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
|
|
@ -175,7 +175,7 @@
|
|||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||
<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>
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
|
|
@ -183,7 +183,7 @@
|
|||
<span class="d-inline-block" data-bs-toggle="tooltip"
|
||||
title="Hanya dapat diakses oleh Admin Foto dan Pemilik">
|
||||
<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>
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ class="custom-img-box-foto d-flex align-items-center justify-content-center text
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="x-small text-muted mb-0">Terakhir diubah oleh:</strong>
|
||||
{{ $f->user->nama ?? 'Admin' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -113,21 +113,48 @@ class="badge {{ $p->status_label->class }}">
|
|||
</div>
|
||||
<div class="modal-footer border-top-0 pt-2 px-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 ($hasAccess)
|
||||
<button type="button" class="btn btn-danger flex-fill tolak"
|
||||
onclick="prosesBuket(this, 'tolak', '{{ $p->id_transaksi }}', 'buket')">
|
||||
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
|
||||
|
||||
@if ($hasAccess)
|
||||
<button type="button" class="btn btn-success flex-fill terima"
|
||||
onclick="prosesBuket(this, 'terima', '{{ $p->id_transaksi }}', 'buket')">
|
||||
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')
|
||||
@if ($hasAccess)
|
||||
<button type="button" class="btn btn-primary flex-fill terima"
|
||||
onclick="prosesBuket(this, 'selesai', '{{ $p->id_transaksi }}', 'buket')">
|
||||
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
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -108,21 +108,48 @@ class="badge {{ $p->status_label->class }}">
|
|||
</div>
|
||||
<div class="modal-footer border-top-0 pt-2 px-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 ($hasAccess)
|
||||
<button type="button" class="btn btn-danger flex-fill tolak"
|
||||
onclick="prosesFoto(this, 'tolak', '{{ $p->id_booking }}', 'foto')">
|
||||
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
|
||||
|
||||
@if ($hasAccess)
|
||||
<button type="button" class="btn btn-success flex-fill terima"
|
||||
onclick="prosesFoto(this, 'terima', '{{ $p->id_booking }}', 'foto')">
|
||||
Terima Pesanan
|
||||
</button>
|
||||
@elseif ($p->status_booking == 'diterima')
|
||||
@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 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
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{{-- RIWAYAT BUKET --}}
|
||||
<div class="modal fade text-left" id="riwayatBuket{{ $rb->id_transaksi }}" tabindex="-1" role="dialog"
|
||||
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-header">
|
||||
|
|
|
|||
|
|
@ -97,7 +97,11 @@ class="sidebar-item {{ request()->is('admin/beranda', 'admin/beranda-pemilik') ?
|
|||
style="min-width: 150px;">
|
||||
<li class="dropdown-header text-center">
|
||||
<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>
|
||||
<hr class="dropdown-divider mt-0">
|
||||
|
|
|
|||
Loading…
Reference in New Issue