DONEEE
This commit is contained in:
parent
67c7e0aa38
commit
b43ba8a0c3
|
@ -2,14 +2,15 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DataKursus; // Pastikan model diimport
|
||||
use Nette\Utils\Strings;
|
||||
use Illuminate\Http\Request;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
use Illuminate\Auth\Events\Validated;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node\Expr\Cast\String_;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\DataKursus; // Pastikan model diimport
|
||||
|
||||
class AdminDataKursusController extends Controller
|
||||
{
|
||||
|
@ -137,18 +138,42 @@ public function update(Request $request, $id)
|
|||
$dataKursus->fasilitas = $request->input('fasilitas');
|
||||
$dataKursus->lokasi = $request->input('lokasi');
|
||||
|
||||
// Handle single image upload
|
||||
|
||||
if ($request->hasFile('img')) {
|
||||
$dataKursus->img = $request->file('img')->store('images', 'public');
|
||||
// Hapus gambar lama jika ada
|
||||
if ($dataKursus->img) {
|
||||
Storage::delete('public/' . $dataKursus->img);
|
||||
}
|
||||
|
||||
|
||||
// Simpan gambar baru
|
||||
$imgPath = $request->file('img')->store('konten', 'public');
|
||||
$dataKursus->img = $imgPath;
|
||||
}
|
||||
|
||||
// Handle multiple image uploads
|
||||
|
||||
if ($request->hasFile('img_konten')) {
|
||||
$images = [];
|
||||
foreach ($request->file('img_konten') as $file) {
|
||||
$images[] = $file->store('images', 'public');
|
||||
// Hapus gambar menu lama jika ada
|
||||
if ($dataKursus->img_konten) {
|
||||
// Decode JSON untuk mendapatkan array path dari gambar lama
|
||||
$oldImages = json_decode($dataKursus->img_konten, true);
|
||||
foreach ($oldImages as $oldImage) {
|
||||
// Hapus setiap file lama dari penyimpanan
|
||||
Storage::delete('public/' . $oldImage);
|
||||
}
|
||||
}
|
||||
$dataKursus->img_konten = json_encode($images);
|
||||
|
||||
// Proses setiap file yang di-upload untuk gambar menu baru
|
||||
$menuImages = [];
|
||||
foreach ($request->file('img_konten') as $file) {
|
||||
// Simpan file di folder 'images/kuliner/detail' dalam disk 'public'
|
||||
$imgKontenPaths = $file->store('logo', 'public');
|
||||
// Menambahkan path ke array baru
|
||||
$menuImages[] = $imgKontenPaths;
|
||||
}
|
||||
|
||||
// Simpan array path gambar menu baru ke database
|
||||
$dataKursus->img_konten = json_encode($menuImages);
|
||||
}
|
||||
|
||||
// Save updated record
|
||||
|
|
|
@ -22,6 +22,6 @@ public function run(): void
|
|||
'password' => 'admin123',
|
||||
]);
|
||||
|
||||
DataKursus::factory(10)->create();
|
||||
// DataKursus::factory(10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class="flex flex-col font-medium mt-4 rounded-lg bg-white md:space-x-8 rtl:space
|
|||
|
||||
<li class="">
|
||||
<a href="{{ route('user.home') }}"
|
||||
class="{{ request()->is('beranda') ? 'bg-[#EBFEA1] md:bg-transparent md:text-white md:underline' : 'text-gray-900' }} block py-2 px-3 md:p-0 rounded hover:bg-[#EBFEA1] md:hover:bg-transparent md:border-0 md:hover:text-white poppins-extrabold text-sm ">
|
||||
class="{{ request()->is('/') ? 'bg-[#EBFEA1] md:bg-transparent md:text-white md:underline' : 'text-gray-900' }} block py-2 px-3 md:p-0 rounded hover:bg-[#EBFEA1] md:hover:bg-transparent md:border-0 md:hover:text-white poppins-extrabold text-sm ">
|
||||
Beranda
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -6,81 +6,16 @@
|
|||
</div>
|
||||
|
||||
<div class="container flex justify-center items-center pb-16">
|
||||
|
||||
<section id="gambarutama">
|
||||
<div class="h-auto w-full ">
|
||||
<img src=" {{ asset('storage/' . $data->img) }}" alt="" class="h-auto w-full">
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
{{-- <div id="default-carousel" class="relative w-full" data-carousel="slide">
|
||||
<!-- Carousel wrapper -->
|
||||
<div class="relative h-56 md:h-96 overflow-hidden rounded-lg">
|
||||
@if (!empty($imageNames) && count($imageNames) > 0)
|
||||
@foreach ($imageNames as $index => $img_konten)
|
||||
<div class="{{ $index === 0 ? 'block' : 'hidden' }} duration-1000 ease-in-out"
|
||||
data-carousel-item>
|
||||
<img src="{{ asset('storage/' . $img_konten) }}" class="w-full h-auto object-contain"
|
||||
alt="Image {{ $index + 1 }}">
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="block duration-1000 ease-in-out" data-carousel-item>
|
||||
<img src="https://via.placeholder.com/600x400" class="w-full h-auto object-contain"
|
||||
alt="No image available">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Slider indicators -->
|
||||
<div class="absolute z-30 flex -translate-x-1/2 bottom-5 left-1/2 space-x-3 rtl:space-x-reverse">
|
||||
@if (!empty($imageNames) && count($imageNames) > 0)
|
||||
@for ($i = 0; $i < count($imageNames); $i++)
|
||||
<button type="button"
|
||||
class="w-3 h-3 rounded-full {{ $i === 0 ? 'bg-blue-500' : 'bg-gray-300' }}"
|
||||
aria-current="{{ $i === 0 ? 'true' : 'false' }}" aria-label="Slide {{ $i + 1 }}"
|
||||
data-carousel-slide-to="{{ $i }}"></button>
|
||||
@endfor
|
||||
@else
|
||||
<button type="button" class="w-3 h-3 rounded-full bg-gray-300" aria-current="true"
|
||||
aria-label="No slides available"></button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Slider controls -->
|
||||
<button type="button"
|
||||
class="absolute top-0 start-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
|
||||
data-carousel-prev>
|
||||
<span
|
||||
class="inline-flex items-center justify-center w-10 h-10 rounded-full bg-white/30 group-hover:bg-white/50 group-focus:ring-4 group-focus:ring-white group-focus:outline-none">
|
||||
<svg class="w-4 h-4 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none" viewBox="0 0 6 10">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M5 1 1 5l4 4" />
|
||||
</svg>
|
||||
<span class="sr-only">Previous</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button type="button"
|
||||
class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
|
||||
data-carousel-next>
|
||||
<span
|
||||
class="inline-flex items-center justify-center w-10 h-10 rounded-full bg-white/30 group-hover:bg-white/50 group-focus:ring-4 group-focus:ring-white group-focus:outline-none">
|
||||
<svg class="w-4 h-4 text-white rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none" viewBox="0 0 6 10">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="m1 9 4-4-4-4" />
|
||||
</svg>
|
||||
<span class="sr-only">Next</span>
|
||||
</span>
|
||||
</button>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<p class="poppins-medium text-3xl xl:text-4xl text-black pb-4">Kampung Inggris LC - Language Center </p>
|
||||
<p class="poppins-medium text-3xl xl:text-4xl text-black pb-4">{{ $data->nama_kursus }}</p>
|
||||
<a href="/kursus/{{ $data->id }}/rute" target="_blank"
|
||||
class="poppins-regular py-2 px-4 bg-[#4F7F81] text-white rounded-xl text-xl shadow-xl">Rute Terdekat</a>
|
||||
<button data-modal-target="default-modal-detail-gambar" data-modal-toggle="default-modal-detail-gambar"
|
||||
|
|
Loading…
Reference in New Issue