DONE TAMBAH DATA
This commit is contained in:
parent
9805b5de90
commit
277ee2f467
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception as BaseException; // Alias the base Exception class
|
||||
|
||||
class CustomException extends BaseException
|
||||
{
|
||||
/**
|
||||
* Report the exception.
|
||||
*/
|
||||
public function report(): void
|
||||
{
|
||||
// Custom reporting logic here
|
||||
}
|
||||
}
|
|
@ -3,7 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\DataKursus; // Pastikan model diimport
|
||||
use Illuminate\Auth\Events\Validated;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
|
||||
class AdminDataKursusController extends Controller
|
||||
{
|
||||
|
@ -22,11 +25,84 @@ public function create()
|
|||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(
|
||||
[]
|
||||
);
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama_kursus' => 'required',
|
||||
'img' => 'required|file|mimes:jpeg,png,jpg|max:2048',
|
||||
'deskripsi' => 'required',
|
||||
'paket' => 'required',
|
||||
'metode' => 'required',
|
||||
'fasilitas' => 'required',
|
||||
'lokasi' => 'required',
|
||||
'latitude' => 'required|numeric|between:-90,90',
|
||||
'longitude' => 'required|numeric|between:-180,180',
|
||||
'img_konten.*' => 'file|mimes:jpeg,png,jpg|max:2048',
|
||||
]);
|
||||
|
||||
// if ($validator->fails()) {
|
||||
// return redirect()->back()->withInput()->withErrors($validator);
|
||||
// }
|
||||
$imgPath = $request->file('img')->store('images', 'public');
|
||||
$imgKontenPaths = [];
|
||||
if ($request->hasFile('img_konten')) {
|
||||
foreach ($request->file('img_konten') as $file) {
|
||||
$imgKontenPaths[] = $file->store('images', 'public');
|
||||
}
|
||||
}
|
||||
|
||||
// Simpan data ke dalam database
|
||||
$result = DataKursus::create([
|
||||
'nama_kursus' => $request->nama_kursus,
|
||||
'img' => $imgPath,
|
||||
'deskripsi' => $request->deskripsi,
|
||||
'paket' => $request->paket,
|
||||
'metode' => $request->metode,
|
||||
'fasilitas' => $request->fasilitas,
|
||||
'lokasi' => $request->lokasi,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'img_konten' => json_encode($imgKontenPaths),
|
||||
]);
|
||||
|
||||
return redirect('/admin/data-kursus');
|
||||
} catch (\Exception $e) {
|
||||
dd($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function w(Request $request)
|
||||
{
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'nama' => 'required',
|
||||
// 'img' => 'required',
|
||||
// 'deskripsi' => 'required',
|
||||
// 'paket' => 'required',
|
||||
// 'metode' => 'required',
|
||||
// 'fasilitas' => 'required',
|
||||
// 'lokasi' => 'required',
|
||||
// 'latitude' => 'required',
|
||||
// 'longtitude' => 'required',
|
||||
// 'img_konten' => 'required',
|
||||
// ]);
|
||||
// DataKursus::create([
|
||||
// "nama_kursus" => $request->nama,
|
||||
// "img" => $request->img,
|
||||
// "deskripsi" => $request->diskripsi,
|
||||
// "paket" => $request->paket,
|
||||
// "metode" => $request->metode,
|
||||
// "fasilitas" => $request->fasilitas,
|
||||
// "lokasi" => $request->lokasi,
|
||||
// "latitude" => $request->latitude,
|
||||
// "longtitude" => $request->longtitude,
|
||||
// "img_konten" => $request->img_konten,
|
||||
|
||||
// ]);
|
||||
// if ($validator->fails()) return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function destroy(string $id)
|
||||
{
|
||||
$data = DataKursus::find($id);
|
||||
|
@ -35,5 +111,4 @@ public function destroy(string $id)
|
|||
}
|
||||
return redirect()->route('admin.dataKursus')->with('success', 'Data berhasil dihapus.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,20 @@ class DataKursus extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
// Tabel yang digunakan oleh model ini
|
||||
protected $table = 'data_kursus';
|
||||
|
||||
// Jika Anda menggunakan timestamp di tabel
|
||||
protected $fillable = [
|
||||
'nama_kursus',
|
||||
'img',
|
||||
'deskripsi',
|
||||
'paket',
|
||||
'metode',
|
||||
'fasilitas',
|
||||
'lokasi',
|
||||
'latitude',
|
||||
'longitude', // Pastikan nama kolom sesuai dengan migrasi
|
||||
'img_konten'
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ public function up()
|
|||
$table->string('metode');
|
||||
$table->text('fasilitas');
|
||||
$table->string('lokasi');
|
||||
$table->decimal('latitude', 10, 7);
|
||||
$table->decimal('longtitude', 10, 7);
|
||||
$table->decimal('latitude', 10, 8)->index(); // Increased precision
|
||||
$table->decimal('longitude', 11, 8)->index(); // Increased precision
|
||||
$table->json('img_konten')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "salma",
|
||||
"name": "SIG-Salma",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<div class="relative overflow-x-auto shadow-md sm:rounded-lg">
|
||||
<div class="flex justify-end items-center pb-4">
|
||||
<a class="bg-[#4F7F81] py-2 px-4 rounded-xl" href="{{ route ('kursus.create') }}">Tambah Data</a>
|
||||
<a class="bg-[#4F7F81] py-2 px-4 rounded-xl text-white font-bold" href="{{ route ('admin.create') }}">Tambah Data</a>
|
||||
</div>
|
||||
<table class="w-full text-sm text-left rtl:text-right text-gray-500">
|
||||
<thead class="text-xs text-gray-700 uppercase bg-gray-50">
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jodit@3.8.13/build/jodit.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/jodit@3.8.13/build/jodit.min.js"></script>
|
||||
|
||||
<x-adminlayout>
|
||||
|
||||
<div class="container">
|
||||
|
@ -8,116 +5,113 @@
|
|||
|
||||
<div class="pb-4 flex">
|
||||
|
||||
<a class="px-4 flex text-white text-lg justify-center items-center py-2 rounded-xl bg-[#4F7F81]" href=""><svg
|
||||
class="w-5 h-5 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none" viewBox="0 0 14 10">
|
||||
<a class="px-4 flex text-white text-lg justify-center items-center py-2 rounded-xl bg-[#4F7F81]"
|
||||
href="{{ route('admin.dataKursus') }}"><svg class="w-5 h-5 text-white " aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13 5H1m0 0 4 4M1 5l4-4" />
|
||||
</svg></a>
|
||||
|
||||
</div>
|
||||
|
||||
<form action="#" method="POST" enctype="multipart/form-data">
|
||||
<form action="{{ route('kursus.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="grid gap-6 mb-6 md:grid-cols-2">
|
||||
<!-- Nama Kursus -->
|
||||
<div>
|
||||
<label for="nama_kursus" class="block mb-2 text-sm font-medium text-gray-900 ">Nama
|
||||
Kursus</label>
|
||||
<label for="nama_kursus" class="block mb-2 text-sm font-medium text-gray-900">Nama Kursus</label>
|
||||
<input type="text" id="nama_kursus" name="nama_kursus"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 "
|
||||
placeholder="Nama Kursus" required />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 " for="file_input">Upload
|
||||
file</label>
|
||||
<input
|
||||
class=" block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 "
|
||||
id="file_input" type="file" >
|
||||
</div>
|
||||
<div>
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 " for="multiple_files">
|
||||
Deskripsi</label>
|
||||
<input type="text" id="first_name"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
|
||||
placeholder="Deskripsi" required />
|
||||
placeholder="Kampung Inggris LC - Language Center" required />
|
||||
</div>
|
||||
|
||||
<!-- File Upload -->
|
||||
<div>
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 " for="multiple_files">Upload
|
||||
multiple files</label>
|
||||
<label for="file_input" class="block mb-2 text-sm font-medium text-gray-900">Upload File</label>
|
||||
<input
|
||||
class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 "
|
||||
id="multiple_files" type="file" multiple>
|
||||
class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50"
|
||||
id="file_input" type="file" name="img">
|
||||
</div>
|
||||
|
||||
<!-- Deskripsi -->
|
||||
<div>
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 " for="multiple_files">
|
||||
Latitude</label>
|
||||
<input type="text" id="first_name"
|
||||
<label for="deskripsi" class="block mb-2 text-sm font-medium text-gray-900">Deskripsi</label>
|
||||
<input type="text" id="deskripsi" name="deskripsi"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
|
||||
placeholder="KAMPUNG INGGRIS LC – LANGUAGE CENTER Adalah . . . ." required />
|
||||
</div>
|
||||
|
||||
<!-- Multiple File Upload -->
|
||||
<div>
|
||||
<label for="multiple_files" class="block mb-2 text-sm font-medium text-gray-900">Upload Multiple Files</label>
|
||||
<input
|
||||
class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50"
|
||||
id="multiple_files" type="file" name="img_konten[]" multiple>
|
||||
</div>
|
||||
|
||||
<!-- Latitude -->
|
||||
<div>
|
||||
<label for="latitude" class="block mb-2 text-sm font-medium text-gray-900">Latitude</label>
|
||||
<input type="text" id="latitude" name="latitude"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
|
||||
placeholder="Latitude" required />
|
||||
</div>
|
||||
|
||||
<!-- Longitude -->
|
||||
<div>
|
||||
<label class="block mb-2 text-sm font-medium text-gray-900 " for="multiple_files">
|
||||
Latitude</label>
|
||||
<input type="text" id="first_name"
|
||||
<label for="longitude" class="block mb-2 text-sm font-medium text-gray-900">longitude</label>
|
||||
<input type="text" id="longitude" name="longitude"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
|
||||
placeholder="Latitude" required />
|
||||
placeholder="longitude"/>
|
||||
</div>
|
||||
|
||||
<!-- Paket -->
|
||||
<div>
|
||||
<label for="deskprisi" class="block mb-2 text-sm font-medium text-gray-900">Paket</label>
|
||||
<textarea id="deskprisi" rows="4"
|
||||
<label for="paket" class="block mb-2 text-sm font-medium text-gray-900">Paket</label>
|
||||
<input id="paket" name="paket" type="hidden" />
|
||||
<trix-editor input="paket"
|
||||
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
|
||||
placeholder="Write your thoughts here..."></textarea>
|
||||
|
||||
placeholder="Write your thoughts here..."></trix-editor>
|
||||
</div>
|
||||
|
||||
<!-- Metode -->
|
||||
<div>
|
||||
<label for="deskprisi" class="block mb-2 text-sm font-medium text-gray-900">Metode</label>
|
||||
<textarea id="deskprisi" rows="4"
|
||||
<label for="metode" class="block mb-2 text-sm font-medium text-gray-900">Metode</label>
|
||||
<input id="metode" name="metode" type="hidden" />
|
||||
<trix-editor input="metode"
|
||||
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
|
||||
placeholder="Write your thoughts here..."></textarea>
|
||||
|
||||
placeholder="Write your thoughts here..."></trix-editor>
|
||||
</div>
|
||||
|
||||
<!-- Fasilitas -->
|
||||
<div>
|
||||
<label for="deskprisi" class="block mb-2 text-sm font-medium text-gray-900">Fasilitas</label>
|
||||
<textarea id="deskprisi" rows="4"
|
||||
<label for="fasilitas" class="block mb-2 text-sm font-medium text-gray-900">Fasilitas</label>
|
||||
<input id="fasilitas" name="fasilitas" type="hidden" />
|
||||
<trix-editor input="fasilitas"
|
||||
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
|
||||
placeholder="Write your thoughts here..."></textarea>
|
||||
|
||||
placeholder="Write your thoughts here..."></trix-editor>
|
||||
</div>
|
||||
|
||||
<!-- Lokasi -->
|
||||
<div>
|
||||
<label for="deskprisi" class="block mb-2 text-sm font-medium text-gray-900">Lokasi</label>
|
||||
<textarea id="deskprisi" rows="4"
|
||||
<label for="lokasi" class="block mb-2 text-sm font-medium text-gray-900">Lokasi</label>
|
||||
<input id="lokasi" name="lokasi" type="hidden" />
|
||||
<trix-editor input="lokasi"
|
||||
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
|
||||
placeholder="Write your thoughts here..."></textarea>
|
||||
|
||||
placeholder="Write your thoughts here..."></trix-editor>
|
||||
</div>
|
||||
<div>
|
||||
<label for="deskripsi"
|
||||
class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Deskripsi</label>
|
||||
<textarea id="deskripsi" name="deskripsi" class="bg-gray-50 border border-gray-300 rounded-lg"></textarea>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: '#deskripsi',
|
||||
plugins: 'advlist autolink lists link image charmap preview anchor searchreplace visualblocks code fullscreen insertdatetime media table paste code help wordcount',
|
||||
toolbar: 'undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
|
||||
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center ">Submit</button>
|
||||
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var editor = new Jodit('#deskripsi ', {
|
||||
height: 300,
|
||||
// Other configurations
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@push('script')
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/trix/1.3.1/trix.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/trix/1.3.1/trix.min.js"></script>
|
||||
@endpush
|
||||
|
||||
|
||||
</x-adminlayout>
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
@include('components.navbarAdmin ')
|
||||
@include('partials.head')
|
||||
@include('partials.font')
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
@include('components.navbarAdmin')
|
||||
@include('partials.head')
|
||||
@include('partials.font')
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{{ $slot }}
|
||||
</body>
|
||||
{{ $slot }}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@include('components.navbar')
|
||||
@include('partials.head')
|
||||
@include('partials.font')
|
||||
|
||||
@include('components.navbar')
|
||||
@include('partials.head')
|
||||
@include('partials.font')
|
||||
</head>
|
||||
<body>
|
||||
{{ $slot }}
|
||||
</body>
|
||||
@include('components.footer')
|
||||
|
||||
@include('components.footer')
|
||||
</html>
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
@vite('resources/css/app.css')
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
|
||||
|
||||
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
|
||||
@stack('script')
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div class="bg-[#EBFEA1] poppins-extrabold m-auto flex items-center justify-center p-2">
|
||||
<p>Halaman ini berisi tentang kursus di Pare!</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pb-10">
|
||||
<!-- Apply Tailwind CSS classes for responsive width and height -->
|
||||
<div id="map"
|
||||
|
|
|
@ -6,15 +6,20 @@
|
|||
use App\Http\Controllers\LoginController;
|
||||
use App\Http\Controllers\PengunjungController;
|
||||
|
||||
|
||||
// ADMIN
|
||||
Route::get('/admin/dashboard', [AdminDashboardController::class, 'index'])->name('admin.home');
|
||||
Route::get('/admin/data-kursus', [AdminDataKursusController::class, 'dataKursus'])->name('admin.dataKursus');
|
||||
Route::get('/admin/tambahdata', [AdminDataKursusController::class, 'create'])->name('kursus.create');
|
||||
Route::post('/admin/store', [AdminDataKursusController::class, 'store'])->name('kursus.store');
|
||||
Route::get('/admin/createData', [AdminDataKursusController::class, 'create'])->name('admin.create');
|
||||
Route::delete('/admin/delete/{id}', [AdminDataKursusController::class, 'destroy'])->name('delete');
|
||||
|
||||
Route::get('/admin/courses', [AdminDataKursusController::class, 'index']);
|
||||
|
||||
// LOGIN
|
||||
Route::get('/login', [LoginController::class, 'index'])->name('login');
|
||||
|
||||
|
||||
// PELANGGAN
|
||||
Route::get('/', [PengunjungController::class, 'home'])->name('home');
|
||||
Route::get('/kursus', [PengunjungController::class, 'kursus'])->name('user.kursus');
|
||||
|
||||
|
|
Loading…
Reference in New Issue