Build Recaje Project
This commit is contained in:
parent
d74c342663
commit
42ad713f36
|
@ -0,0 +1,18 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
|
@ -0,0 +1,65 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=sqlite
|
||||||
|
# DB_HOST=127.0.0.1
|
||||||
|
# DB_PORT=3306
|
||||||
|
# DB_DATABASE=laravel
|
||||||
|
# DB_USERNAME=root
|
||||||
|
# DB_PASSWORD=
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
|
@ -0,0 +1,23 @@
|
||||||
|
/.phpunit.cache
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/pail
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/auth.json
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.nova
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
|
@ -0,0 +1,498 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use App\Models\CafeRating;
|
||||||
|
use App\Models\CafeImage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class CafeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$cafes = Cafe::latest()->paginate(10);
|
||||||
|
return view('admin.cafes.index', compact('cafes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$categories = Category::all();
|
||||||
|
$subcategories = Subcategory::all();
|
||||||
|
return view('admin.cafes.create', compact('categories', 'subcategories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nama' => 'required',
|
||||||
|
'area' => 'nullable|array',
|
||||||
|
'area.*' => 'nullable|string',
|
||||||
|
'latitude' => 'required|numeric',
|
||||||
|
'longitude' => 'required|numeric',
|
||||||
|
'koordinat' => 'required|string',
|
||||||
|
'harga_termurah' => 'nullable|numeric|min:0',
|
||||||
|
'harga_termahal' => 'nullable|numeric|min:0|gte:harga_termurah',
|
||||||
|
'category_ratings' => 'required|array',
|
||||||
|
'category_ratings.*' => 'required|exists:subcategories,id',
|
||||||
|
'gambar.*' => 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'nama' => $request->nama,
|
||||||
|
'lokasi' => $request->koordinat,
|
||||||
|
'area' => $request->area ? implode(', ', $request->area) : null,
|
||||||
|
'latitude' => $request->latitude,
|
||||||
|
'longitude' => $request->longitude,
|
||||||
|
'harga_termurah' => $request->harga_termurah,
|
||||||
|
'harga_termahal' => $request->harga_termahal,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Handle koordinat field if it exists and latitude/longitude are not set
|
||||||
|
if ($request->filled('koordinat') && (!$request->filled('latitude') || !$request->filled('longitude'))) {
|
||||||
|
$koordinat = $request->koordinat;
|
||||||
|
$koordinatArray = explode(',', $koordinat);
|
||||||
|
|
||||||
|
if (count($koordinatArray) === 2) {
|
||||||
|
$latitude = trim($koordinatArray[0]);
|
||||||
|
$longitude = trim($koordinatArray[1]);
|
||||||
|
|
||||||
|
if (is_numeric($latitude) && is_numeric($longitude)) {
|
||||||
|
$data['latitude'] = $latitude;
|
||||||
|
$data['longitude'] = $longitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat cafe
|
||||||
|
$cafe = Cafe::create($data);
|
||||||
|
|
||||||
|
// Untuk menyimpan gambar pertama yang akan digunakan di kolom gambar
|
||||||
|
$firstImagePath = null;
|
||||||
|
|
||||||
|
// Handle multiple image upload
|
||||||
|
if ($request->hasFile('gambar')) {
|
||||||
|
foreach ($request->file('gambar') as $index => $image) {
|
||||||
|
$imageName = time() . '_' . uniqid() . '.' . $image->extension();
|
||||||
|
$imagePath = 'images/cafes/' . $imageName;
|
||||||
|
$image->move(public_path('images/cafes'), $imageName);
|
||||||
|
|
||||||
|
CafeImage::create([
|
||||||
|
'cafe_id' => $cafe->id,
|
||||||
|
'image_path' => $imagePath
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Simpan path gambar pertama
|
||||||
|
if ($index === 0) {
|
||||||
|
$firstImagePath = $imagePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update kolom gambar di tabel cafe dengan gambar pertama
|
||||||
|
if ($firstImagePath) {
|
||||||
|
$cafe->gambar = $firstImagePath;
|
||||||
|
$cafe->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simpan rating category
|
||||||
|
if ($request->has('category_ratings')) {
|
||||||
|
foreach ($request->category_ratings as $categoryId => $subcategoryId) {
|
||||||
|
$subcategory = Subcategory::findOrFail($subcategoryId);
|
||||||
|
|
||||||
|
CafeRating::create([
|
||||||
|
'cafe_id' => $cafe->id,
|
||||||
|
'category_id' => $categoryId,
|
||||||
|
'subcategory_id' => $subcategoryId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()->route('admin.cafes.index')
|
||||||
|
->with('success', 'Cafe berhasil ditambahkan!');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollback();
|
||||||
|
return redirect()->back()->with('error', 'Terjadi kesalahan: ' . $e->getMessage())->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Cafe $cafe)
|
||||||
|
{
|
||||||
|
return view('admin.cafes.show', compact('cafe'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Cafe $cafe)
|
||||||
|
{
|
||||||
|
// Tambahkan ini untuk debugging
|
||||||
|
\Log::info('Old Input Session:', session()->get('_old_input', []));
|
||||||
|
\Log::info('Direct from DB: Lat=' . $cafe->latitude . ', Lng=' . $cafe->longitude);
|
||||||
|
|
||||||
|
// Hapus semua data yang tersimpan di session untuk cafe ini
|
||||||
|
session()->forget('_old_input');
|
||||||
|
session()->forget("_cafe_{$cafe->id}_coordinates");
|
||||||
|
|
||||||
|
// Paksa untuk mengambil data cafe langsung dari database
|
||||||
|
$cafe = Cafe::where('id', $cafe->id)->first();
|
||||||
|
|
||||||
|
// Simpan timestamp untuk tracking cache
|
||||||
|
$timestamp = time();
|
||||||
|
|
||||||
|
// Tambahan debug info
|
||||||
|
\Log::info("Fetching fresh data for cafe {$cafe->id}, Timestamp: {$timestamp}");
|
||||||
|
\Log::info("Fresh coordinates: Lat={$cafe->latitude}, Lng={$cafe->longitude}");
|
||||||
|
|
||||||
|
// Buat koordinat langsung tanpa old()
|
||||||
|
return view('admin.cafes.edit', [
|
||||||
|
'cafe' => $cafe,
|
||||||
|
'timestamp' => $timestamp,
|
||||||
|
'categories' => Category::all(),
|
||||||
|
'subcategories' => Subcategory::all(),
|
||||||
|
'cafeRatings' => $cafe->ratings()->pluck('subcategory_id', 'category_id')->toArray()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Cafe $cafe)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nama' => 'required',
|
||||||
|
'area' => 'nullable|array',
|
||||||
|
'area.*' => 'nullable|string',
|
||||||
|
'latitude' => 'required|numeric',
|
||||||
|
'longitude' => 'required|numeric',
|
||||||
|
'koordinat' => 'required|string',
|
||||||
|
'harga_termurah' => 'nullable|numeric|min:0',
|
||||||
|
'harga_termahal' => 'nullable|numeric|min:0|gte:harga_termurah',
|
||||||
|
'category_ratings' => 'required|array',
|
||||||
|
'category_ratings.*' => 'required|exists:subcategories,id',
|
||||||
|
'gambar.*' => 'nullable|image|mimes:jpeg,png,jpg|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
// Debug: nilai sebelum update
|
||||||
|
\Log::info("BEFORE UPDATE - ID: {$cafe->id}, Lokasi: {$cafe->lokasi}, Latitude: {$cafe->latitude}, Longitude: {$cafe->longitude}");
|
||||||
|
\Log::info("INPUT VALUES - Koordinat: {$request->koordinat}, Latitude: {$request->latitude}, Longitude: {$request->longitude}");
|
||||||
|
|
||||||
|
// Ensure koordinat, latitude and longitude are in sync
|
||||||
|
// Parse koordinat to extract latitude and longitude
|
||||||
|
$koordinatArray = explode(',', $request->koordinat);
|
||||||
|
if (count($koordinatArray) === 2) {
|
||||||
|
$latitude = trim($koordinatArray[0]);
|
||||||
|
$longitude = trim($koordinatArray[1]);
|
||||||
|
|
||||||
|
// Verify values are numeric
|
||||||
|
if (is_numeric($latitude) && is_numeric($longitude)) {
|
||||||
|
$data = [
|
||||||
|
'nama' => $request->nama,
|
||||||
|
'lokasi' => $request->koordinat,
|
||||||
|
'area' => $request->area ? implode(', ', $request->area) : null,
|
||||||
|
'latitude' => $latitude,
|
||||||
|
'longitude' => $longitude,
|
||||||
|
'harga_termurah' => $request->harga_termurah,
|
||||||
|
'harga_termahal' => $request->harga_termahal,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Force sync latitude/longitude from koordinat
|
||||||
|
$request->merge([
|
||||||
|
'latitude' => $latitude,
|
||||||
|
'longitude' => $longitude
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Use provided latitude/longitude if parsing failed
|
||||||
|
$data = [
|
||||||
|
'nama' => $request->nama,
|
||||||
|
'lokasi' => $request->koordinat,
|
||||||
|
'area' => $request->area ? implode(', ', $request->area) : null,
|
||||||
|
'latitude' => $request->latitude,
|
||||||
|
'longitude' => $request->longitude,
|
||||||
|
'harga_termurah' => $request->harga_termurah,
|
||||||
|
'harga_termahal' => $request->harga_termahal,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Use provided latitude/longitude if parsing failed
|
||||||
|
$data = [
|
||||||
|
'nama' => $request->nama,
|
||||||
|
'lokasi' => $request->koordinat,
|
||||||
|
'area' => $request->area ? implode(', ', $request->area) : null,
|
||||||
|
'latitude' => $request->latitude,
|
||||||
|
'longitude' => $request->longitude,
|
||||||
|
'harga_termurah' => $request->harga_termurah,
|
||||||
|
'harga_termahal' => $request->harga_termahal,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update cafe
|
||||||
|
$cafe->update($data);
|
||||||
|
|
||||||
|
// Verify update success by re-fetching from DB
|
||||||
|
$updatedCafe = Cafe::find($cafe->id);
|
||||||
|
\Log::info("AFTER UPDATE - ID: {$updatedCafe->id}, Lokasi: {$updatedCafe->lokasi}, Latitude: {$updatedCafe->latitude}, Longitude: {$updatedCafe->longitude}");
|
||||||
|
|
||||||
|
// Flag untuk menandai apakah ada gambar baru yang ditambahkan
|
||||||
|
$newImagesAdded = false;
|
||||||
|
|
||||||
|
// Handle multiple image upload
|
||||||
|
if ($request->hasFile('gambar')) {
|
||||||
|
$newImagesAdded = true;
|
||||||
|
foreach ($request->file('gambar') as $image) {
|
||||||
|
$imageName = time() . '_' . uniqid() . '.' . $image->extension();
|
||||||
|
$imagePath = 'images/cafes/' . $imageName;
|
||||||
|
$image->move(public_path('images/cafes'), $imageName);
|
||||||
|
|
||||||
|
CafeImage::create([
|
||||||
|
'cafe_id' => $cafe->id,
|
||||||
|
'image_path' => $imagePath
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hapus rating lama
|
||||||
|
$cafe->ratings()->delete();
|
||||||
|
|
||||||
|
// Simpan rating category baru
|
||||||
|
if ($request->has('category_ratings')) {
|
||||||
|
foreach ($request->category_ratings as $categoryId => $subcategoryId) {
|
||||||
|
$subcategory = Subcategory::findOrFail($subcategoryId);
|
||||||
|
|
||||||
|
CafeRating::create([
|
||||||
|
'cafe_id' => $cafe->id,
|
||||||
|
'category_id' => $categoryId,
|
||||||
|
'subcategory_id' => $subcategoryId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update kolom gambar di tabel cafe jika gambar baru ditambahkan
|
||||||
|
// atau jika kolom gambar masih kosong
|
||||||
|
if ($newImagesAdded || empty($cafe->gambar)) {
|
||||||
|
$this->updateCafeMainImage($cafe->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()->route('admin.cafes.index')
|
||||||
|
->with('success', 'Cafe berhasil diperbarui!');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollback();
|
||||||
|
return redirect()->back()->with('error', 'Terjadi kesalahan: ' . $e->getMessage())->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Cafe $cafe)
|
||||||
|
{
|
||||||
|
$cafe->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.cafes.index')
|
||||||
|
->with('success', 'Cafe berhasil dihapus!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete cafe image
|
||||||
|
*/
|
||||||
|
public function deleteImage($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Cari gambar berdasarkan ID
|
||||||
|
$image = CafeImage::findOrFail($id);
|
||||||
|
$cafeId = $image->cafe_id;
|
||||||
|
|
||||||
|
// Hapus file fisik jika ada
|
||||||
|
if (file_exists(public_path($image->image_path))) {
|
||||||
|
unlink(public_path($image->image_path));
|
||||||
|
} else {
|
||||||
|
// Log jika file tidak ditemukan
|
||||||
|
\Log::warning("File tidak ditemukan: {$image->image_path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hapus record dari database
|
||||||
|
$image->delete();
|
||||||
|
|
||||||
|
// Jika gambar yang dihapus adalah gambar utama, update kolom gambar di tabel cafes
|
||||||
|
$cafe = Cafe::find($cafeId);
|
||||||
|
if ($cafe && $cafe->gambar === $image->image_path) {
|
||||||
|
$this->updateCafeMainImage($cafeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'message' => 'Gambar berhasil dihapus']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Log error untuk debugging
|
||||||
|
\Log::error("Error menghapus gambar: " . $e->getMessage());
|
||||||
|
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update main image in cafes table with the image that has the smallest ID
|
||||||
|
*/
|
||||||
|
private function updateCafeMainImage($cafeId)
|
||||||
|
{
|
||||||
|
// Ambil gambar dengan ID terkecil dari tabel cafe_images
|
||||||
|
$firstImage = CafeImage::where('cafe_id', $cafeId)
|
||||||
|
->orderBy('id', 'asc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$cafe = Cafe::find($cafeId);
|
||||||
|
if ($cafe) {
|
||||||
|
if ($firstImage) {
|
||||||
|
// Update kolom gambar dengan path gambar yang memiliki ID terkecil
|
||||||
|
$cafe->gambar = $firstImage->image_path;
|
||||||
|
} else {
|
||||||
|
// Jika tidak ada gambar, kosongkan kolom gambar
|
||||||
|
$cafe->gambar = null;
|
||||||
|
}
|
||||||
|
$cafe->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update image order
|
||||||
|
*/
|
||||||
|
public function updateImageOrder(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Ambil data dari request, baik berupa form reguler atau JSON
|
||||||
|
if ($request->isJson() || $request->expectsJson() || $request->header('Content-Type') === 'application/json') {
|
||||||
|
// Untuk request JSON (fetch API)
|
||||||
|
$data = $request->json()->all();
|
||||||
|
$cafeId = $data['cafe_id'] ?? null;
|
||||||
|
$imageIds = $data['image_ids'] ?? [];
|
||||||
|
} else {
|
||||||
|
// Untuk request form biasa (jQuery Ajax)
|
||||||
|
$cafeId = $request->input('cafe_id');
|
||||||
|
$imageIds = $request->input('image_ids', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validasi Data
|
||||||
|
if (!$cafeId || empty($imageIds)) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Data cafe_id dan image_ids diperlukan'
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log untuk debugging
|
||||||
|
\Log::info('Updating image order for cafe: ' . $cafeId);
|
||||||
|
\Log::info('Image IDs: ' . print_r($imageIds, true));
|
||||||
|
|
||||||
|
// Perbarui urutan (sort_order) gambar
|
||||||
|
foreach ($imageIds as $index => $imageId) {
|
||||||
|
CafeImage::where('id', $imageId)
|
||||||
|
->update(['sort_order' => $index + 1]); // +1 agar urutan dimulai dari 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perbarui gambar utama cafe (gunakan gambar pertama sebagai gambar utama)
|
||||||
|
if (!empty($imageIds)) {
|
||||||
|
$firstImageId = $imageIds[0];
|
||||||
|
$firstImage = CafeImage::find($firstImageId);
|
||||||
|
|
||||||
|
if ($firstImage) {
|
||||||
|
$cafe = Cafe::find($cafeId);
|
||||||
|
if ($cafe) {
|
||||||
|
$cafe->gambar = $firstImage->image_path;
|
||||||
|
$cafe->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'message' => 'Urutan gambar berhasil diperbarui']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Error mengatur urutan gambar: " . $e->getMessage());
|
||||||
|
\Log::error("Stack trace: " . $e->getTraceAsString());
|
||||||
|
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix coordinates from lokasi field
|
||||||
|
*/
|
||||||
|
public function fixCoordinates($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Cari cafe berdasarkan ID
|
||||||
|
$cafe = Cafe::findOrFail($id);
|
||||||
|
|
||||||
|
// Ambil nilai lokasi
|
||||||
|
$lokasi = $cafe->lokasi;
|
||||||
|
|
||||||
|
// Parsing lokasi untuk mendapatkan latitude dan longitude
|
||||||
|
$koordinatArray = explode(',', $lokasi);
|
||||||
|
|
||||||
|
if (count($koordinatArray) === 2) {
|
||||||
|
$latitude = trim($koordinatArray[0]);
|
||||||
|
$longitude = trim($koordinatArray[1]);
|
||||||
|
|
||||||
|
// Verify values are numeric
|
||||||
|
if (is_numeric($latitude) && is_numeric($longitude)) {
|
||||||
|
// Update nilai latitude dan longitude
|
||||||
|
$cafe->latitude = $latitude;
|
||||||
|
$cafe->longitude = $longitude;
|
||||||
|
$cafe->save();
|
||||||
|
|
||||||
|
\Log::info("Fixed coordinates - ID: {$cafe->id}, Lokasi: {$lokasi}, New Lat: {$latitude}, New Lng: {$longitude}");
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Koordinat berhasil diperbaiki',
|
||||||
|
'data' => [
|
||||||
|
'id' => $cafe->id,
|
||||||
|
'latitude' => $cafe->latitude,
|
||||||
|
'longitude' => $cafe->longitude,
|
||||||
|
'lokasi' => $cafe->lokasi
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Nilai latitude/longitude tidak valid (bukan angka)'
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Format lokasi tidak valid, seharusnya "latitude, longitude"'
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Error fixing coordinates: " . $e->getMessage());
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Terjadi kesalahan: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Category;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class CategoryController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$categories = Category::with('subcategories')->get();
|
||||||
|
return view('admin.categories.index', compact('categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.categories.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$category = Category::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.subcategories.create', ['category_id' => $category->id])
|
||||||
|
->with('success', 'Kategori berhasil ditambahkan! Silakan tambahkan sub-kategori.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Category $category)
|
||||||
|
{
|
||||||
|
return view('admin.categories.show', compact('category'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Category $category)
|
||||||
|
{
|
||||||
|
return view('admin.categories.edit', compact('category'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Category $category)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$category->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.categories.index')
|
||||||
|
->with('success', 'Kategori berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Category $category)
|
||||||
|
{
|
||||||
|
$category->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.categories.index')
|
||||||
|
->with('success', 'Kategori berhasil dihapus!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Middleware auth diterapkan di routes/web.php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the admin dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Di sini Anda bisa mengambil data yang dibutuhkan untuk dashboard admin
|
||||||
|
$totalUsers = \App\Models\User::count();
|
||||||
|
|
||||||
|
return view('admin.dashboard', [
|
||||||
|
'totalUsers' => $totalUsers
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class SubcategoryController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$subcategories = Subcategory::paginate(10);
|
||||||
|
return view('admin.subcategories.index', compact('subcategories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$categories = Category::all();
|
||||||
|
$selectedCategoryId = request('category_id');
|
||||||
|
return view('admin.subcategories.create', compact('categories', 'selectedCategoryId'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
\Illuminate\Support\Facades\Log::info('Request data:', $request->all());
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'category_id' => 'required|exists:categories,id',
|
||||||
|
'subcategories' => 'required|array|min:1',
|
||||||
|
'subcategories.*.name' => 'required|string|max:255',
|
||||||
|
'subcategories.*.value' => 'required|integer|min:1|max:5'
|
||||||
|
]);
|
||||||
|
|
||||||
|
\Illuminate\Support\Facades\Log::info('Validation passed, processing subcategories');
|
||||||
|
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
foreach ($request->subcategories as $subcategory) {
|
||||||
|
\Illuminate\Support\Facades\Log::info('Creating subcategory:', $subcategory);
|
||||||
|
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $request->category_id,
|
||||||
|
'name' => $subcategory['name'],
|
||||||
|
'value' => $subcategory['value']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
\Illuminate\Support\Facades\Log::info('All subcategories created successfully');
|
||||||
|
|
||||||
|
return redirect()->route('admin.subcategories.index')
|
||||||
|
->with('success', 'Sub-kategori berhasil ditambahkan!');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
\Illuminate\Support\Facades\Log::error('Error creating subcategories: ' . $e->getMessage());
|
||||||
|
|
||||||
|
return back()->with('error', 'Terjadi kesalahan saat menambahkan sub-kategori: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Subcategory $subcategory)
|
||||||
|
{
|
||||||
|
return view('admin.subcategories.show', compact('subcategory'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Subcategory $subcategory)
|
||||||
|
{
|
||||||
|
$categories = Category::all();
|
||||||
|
return view('admin.subcategories.edit', compact('subcategory', 'categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Subcategory $subcategory)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'category_id' => 'required|exists:categories,id',
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$subcategory->update([
|
||||||
|
'category_id' => $request->category_id,
|
||||||
|
'name' => $request->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.subcategories.index')
|
||||||
|
->with('success', 'Sub-kategori berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Subcategory $subcategory)
|
||||||
|
{
|
||||||
|
$subcategory->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.subcategories.index')
|
||||||
|
->with('success', 'Sub-kategori berhasil dihapus!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Middleware auth diterapkan di routes/web.php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menampilkan daftar pengguna.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$users = User::orderBy('id', 'asc')->paginate(10);
|
||||||
|
|
||||||
|
// Format nama setiap user
|
||||||
|
$users->getCollection()->transform(function ($user) {
|
||||||
|
$user->name = ucwords(strtolower($user->name));
|
||||||
|
return $user;
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('admin.users.index', compact('users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menampilkan detail pengguna.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function show(User $user)
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->name = ucwords(strtolower($user->name));
|
||||||
|
return view('admin.users.show', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menghapus pengguna.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(User $user)
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tidak bisa menghapus diri sendiri
|
||||||
|
if (Auth::id() === $user->id) {
|
||||||
|
return back()->with('error', 'Anda tidak dapat menghapus akun Anda sendiri.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', 'Pengguna berhasil dihapus!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.users.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menyimpan user baru.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|string|email|max:255|unique:users',
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
'role' => 'required|in:admin,user',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => ucwords(strtolower($request->name)),
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'role' => $request->role,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', 'Pengguna berhasil ditambahkan!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menampilkan form edit user.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function edit(User $user)
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->name = ucwords(strtolower($user->name));
|
||||||
|
return view('admin.users.edit', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memperbarui data user.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(Request $request, User $user)
|
||||||
|
{
|
||||||
|
// Cek apakah pengguna adalah admin
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
return redirect('/')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|string|email|max:255|unique:users,email,' . $user->id,
|
||||||
|
'password' => 'nullable|string|min:8|confirmed',
|
||||||
|
'role' => 'required|in:admin,user',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'name' => ucwords(strtolower($request->name)),
|
||||||
|
'email' => $request->email,
|
||||||
|
'role' => $request->role,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Update password hanya jika diisi
|
||||||
|
if ($request->filled('password')) {
|
||||||
|
$data['password'] = Hash::make($request->password);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('admin.users.index')
|
||||||
|
->with('success', 'Pengguna berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,170 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Weight;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
|
||||||
|
class WeightController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$categories = Category::with('subcategories')->get();
|
||||||
|
$weights = Weight::with(['category', 'subcategory'])->get();
|
||||||
|
|
||||||
|
return view('admin.weights.index', compact('categories', 'weights'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$categories = Category::with('subcategories')->get();
|
||||||
|
$categoriesJson = $categories->map(function ($category) {
|
||||||
|
return [
|
||||||
|
'id' => $category->id,
|
||||||
|
'name' => $category->name,
|
||||||
|
'subcategories' => $category->subcategories->map(function ($subcategory) {
|
||||||
|
return [
|
||||||
|
'id' => $subcategory->id,
|
||||||
|
'name' => $subcategory->name
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('admin.weights.create', [
|
||||||
|
'categories' => $categories,
|
||||||
|
'categoriesJson' => $categoriesJson
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'category_id' => 'required|exists:categories,id',
|
||||||
|
'subcategory_id' => 'nullable|exists:subcategories,id',
|
||||||
|
'weight_value' => 'required|numeric|min:0|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Hitung total bobot untuk normalisasi
|
||||||
|
$totalWeight = Weight::sum('weight_value');
|
||||||
|
|
||||||
|
// Hitung bobot yang dinormalisasi
|
||||||
|
$normalizedWeight = $request->weight_value / ($totalWeight + $request->weight_value);
|
||||||
|
|
||||||
|
Weight::create([
|
||||||
|
'category_id' => $request->category_id,
|
||||||
|
'subcategory_id' => $request->subcategory_id,
|
||||||
|
'weight_value' => $request->weight_value,
|
||||||
|
'normalized_weight' => $normalizedWeight
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Update semua bobot yang dinormalisasi
|
||||||
|
$this->updateAllNormalizedWeights();
|
||||||
|
|
||||||
|
return redirect()->route('admin.weights.index')
|
||||||
|
->with('success', 'Bobot berhasil ditambahkan!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Weight $weight)
|
||||||
|
{
|
||||||
|
$categories = Category::with('subcategories')->get();
|
||||||
|
$categoriesJson = $categories->map(function ($category) {
|
||||||
|
return [
|
||||||
|
'id' => $category->id,
|
||||||
|
'name' => $category->name,
|
||||||
|
'subcategories' => $category->subcategories->map(function ($subcategory) {
|
||||||
|
return [
|
||||||
|
'id' => $subcategory->id,
|
||||||
|
'name' => $subcategory->name
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('admin.weights.edit', [
|
||||||
|
'weight' => $weight,
|
||||||
|
'categories' => $categories,
|
||||||
|
'categoriesJson' => $categoriesJson
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Weight $weight)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'category_id' => 'required|exists:categories,id',
|
||||||
|
'subcategory_id' => 'nullable|exists:subcategories,id',
|
||||||
|
'weight_value' => 'required|numeric|min:0|max:100',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Hitung total bobot untuk normalisasi
|
||||||
|
$totalWeight = Weight::where('id', '!=', $weight->id)->sum('weight_value');
|
||||||
|
|
||||||
|
// Hitung bobot yang dinormalisasi
|
||||||
|
$normalizedWeight = $request->weight_value / ($totalWeight + $request->weight_value);
|
||||||
|
|
||||||
|
$weight->update([
|
||||||
|
'category_id' => $request->category_id,
|
||||||
|
'subcategory_id' => $request->subcategory_id,
|
||||||
|
'weight_value' => $request->weight_value,
|
||||||
|
'normalized_weight' => $normalizedWeight
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Update semua bobot yang dinormalisasi
|
||||||
|
$this->updateAllNormalizedWeights();
|
||||||
|
|
||||||
|
return redirect()->route('admin.weights.index')
|
||||||
|
->with('success', 'Bobot berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Weight $weight)
|
||||||
|
{
|
||||||
|
$weight->delete();
|
||||||
|
|
||||||
|
// Update semua bobot yang dinormalisasi
|
||||||
|
$this->updateAllNormalizedWeights();
|
||||||
|
|
||||||
|
return redirect()->route('admin.weights.index')
|
||||||
|
->with('success', 'Bobot berhasil dihapus!');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateAllNormalizedWeights()
|
||||||
|
{
|
||||||
|
$weights = Weight::all();
|
||||||
|
$totalWeight = $weights->sum('weight_value');
|
||||||
|
|
||||||
|
foreach ($weights as $weight) {
|
||||||
|
$weight->update([
|
||||||
|
'normalized_weight' => $weight->weight_value / $totalWeight
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Menampilkan formulir reset password
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function showLinkRequestForm()
|
||||||
|
{
|
||||||
|
return view('auth.passwords.email');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mengirim link reset password
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function sendResetLinkEmail(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$status = Password::sendResetLink(
|
||||||
|
$request->only('email')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $status === Password::RESET_LINK_SENT
|
||||||
|
? back()->with('status', 'Link reset password telah dikirim ke email Anda!')
|
||||||
|
: back()->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Laravel\Socialite\Facades\Socialite;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Menampilkan form login
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected function redirectTo()
|
||||||
|
{
|
||||||
|
if (Auth::check() && Auth::user()->role === 'admin') {
|
||||||
|
return route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memproses request login
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$credentials = $request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => ['required'],
|
||||||
|
], [
|
||||||
|
'email.required' => 'Email harus diisi',
|
||||||
|
'email.email' => 'Format email tidak valid',
|
||||||
|
'password.required' => 'Password harus diisi',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (Auth::attempt($credentials, $request->boolean('remember'))) {
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
if (Auth::user()->role === 'admin') {
|
||||||
|
return redirect()->route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->intended('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()
|
||||||
|
->withInput($request->only('email'))
|
||||||
|
->withErrors([
|
||||||
|
'email' => 'Email atau password yang diberikan tidak cocok dengan data kami.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()
|
||||||
|
->withInput($request->only('email'))
|
||||||
|
->withErrors([
|
||||||
|
'error' => 'Terjadi kesalahan saat mencoba login. Silakan coba lagi.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout pengguna
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect ke halaman login Google.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function redirectToGoogle()
|
||||||
|
{
|
||||||
|
return Socialite::driver('google')->redirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle callback dari Google.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function handleGoogleCallback()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$googleUser = Socialite::driver('google')->user();
|
||||||
|
|
||||||
|
// Cari user berdasarkan google id, jika tidak ada cari berdasarkan email
|
||||||
|
$user = User::where('google_id', $googleUser->id)->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
// Cek apakah email sudah terdaftar
|
||||||
|
$user = User::where('email', $googleUser->email)->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
// Jika user belum terdaftar, buat user baru
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $googleUser->name,
|
||||||
|
'email' => $googleUser->email,
|
||||||
|
'google_id' => $googleUser->id,
|
||||||
|
'password' => Hash::make(rand(1,10000)),
|
||||||
|
'email_verified_at' => now(), // Email otomatis terverifikasi
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
// Update google_id untuk user yang sudah ada
|
||||||
|
$user->update([
|
||||||
|
'google_id' => $googleUser->id,
|
||||||
|
'email_verified_at' => now(), // Email otomatis terverifikasi
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Login user
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
return redirect('/');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect('/login')->with('error', 'Terjadi kesalahan saat login dengan Google: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Menampilkan form registrasi
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function showRegistrationForm()
|
||||||
|
{
|
||||||
|
return view('auth.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memproses request registrasi
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function register(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
'terms' => ['required'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
event(new Registered($user));
|
||||||
|
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
return redirect()->route('verification.notice');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Menampilkan formulir reset password dengan token
|
||||||
|
*
|
||||||
|
* @param string $token
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function showResetForm(Request $request, $token = null)
|
||||||
|
{
|
||||||
|
return view('auth.passwords.reset')->with(
|
||||||
|
['token' => $token, 'email' => $request->email]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memproses reset password
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function reset(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token' => ['required'],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => ['required', 'confirmed', 'min:8'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$status = Password::reset(
|
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||||
|
function ($user, $password) {
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($password)
|
||||||
|
])->setRememberToken(Str::random(60));
|
||||||
|
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
event(new PasswordReset($user));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return $status === Password::PASSWORD_RESET
|
||||||
|
? redirect()->route('login')->with('status', 'Password Anda telah direset!')
|
||||||
|
: back()->withErrors(['email' => [__($status)]]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CafeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tampilkan halaman pencarian cafe dengan stepper
|
||||||
|
*/
|
||||||
|
public function search(Request $request)
|
||||||
|
{
|
||||||
|
// Tentukan langkah saat ini berdasarkan parameter URL
|
||||||
|
$currentStep = 1;
|
||||||
|
if ($request->has('weight')) {
|
||||||
|
$currentStep = 3; // Hasil
|
||||||
|
} elseif ($request->has('criteria')) {
|
||||||
|
$currentStep = 2; // Kriteria
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('cafe.search-fixed', compact('currentStep'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tampilkan halaman rekomendasi cafe
|
||||||
|
*/
|
||||||
|
public function recommend()
|
||||||
|
{
|
||||||
|
return view('cafe.recommend');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tampilkan semua cafe dengan fitur fuzzy search toleran terhadap typo
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$query = Cafe::with(['ratings.subcategory', 'ratings.category']);
|
||||||
|
|
||||||
|
// Filter berdasarkan pencarian jika ada
|
||||||
|
if ($request->has('search') && !empty($request->search)) {
|
||||||
|
$searchTerm = $request->search;
|
||||||
|
|
||||||
|
// Memecah kata kunci pencarian menjadi beberapa kata
|
||||||
|
$keywords = explode(' ', $searchTerm);
|
||||||
|
|
||||||
|
$query->where(function($q) use ($searchTerm, $keywords) {
|
||||||
|
// Exact match dengan prioritas tertinggi
|
||||||
|
$q->where('nama', 'LIKE', "%{$searchTerm}%");
|
||||||
|
|
||||||
|
// Pencarian fuzzy untuk masing-masing kata kunci
|
||||||
|
foreach ($keywords as $keyword) {
|
||||||
|
if (strlen($keyword) >= 3) {
|
||||||
|
// Membuat variasi kata kunci untuk toleransi typo
|
||||||
|
$q->orWhere('nama', 'LIKE', "%{$keyword}%");
|
||||||
|
|
||||||
|
// Tambahkan wildcard di tengah untuk toleransi kesalahan ketik 1 karakter
|
||||||
|
for ($i = 0; $i < strlen($keyword) - 1; $i++) {
|
||||||
|
$fuzzyWord = substr($keyword, 0, $i) . '_' . substr($keyword, $i + 1);
|
||||||
|
$q->orWhere('nama', 'LIKE', "%{$fuzzyWord}%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mencoba juga pencarian dengan operator SOUNDS LIKE jika tersedia
|
||||||
|
try {
|
||||||
|
$q->orWhereRaw("SOUNDEX(nama) = SOUNDEX(?)", [$searchTerm]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// SOUNDEX mungkin tidak tersedia, tidak perlu error handling
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$cafes = $query->latest()->paginate(12)->withQueryString();
|
||||||
|
|
||||||
|
return view('cafe.index', compact('cafes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tampilkan detail cafe
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$cafe = Cafe::with(['ratings.subcategory', 'ratings.category'])->findOrFail($id);
|
||||||
|
return view('cafe.show', compact('cafe'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ContactMessage;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ContactController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Store a newly created contact message in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|string|email|max:255',
|
||||||
|
'message' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
ContactMessage::create($validated);
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', 'Pesan Anda telah terkirim! Terima kasih telah menghubungi kami.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of contact messages for admin.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$messages = ContactMessage::orderBy('created_at', 'desc')->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.contact-messages.index', compact('messages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified contact message.
|
||||||
|
*
|
||||||
|
* @param \App\Models\ContactMessage $contactMessage
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show(ContactMessage $contactMessage)
|
||||||
|
{
|
||||||
|
// Mark as read
|
||||||
|
if (!$contactMessage->is_read) {
|
||||||
|
$contactMessage->is_read = true;
|
||||||
|
$contactMessage->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.contact-messages.show', compact('contactMessage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified contact message from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\ContactMessage $contactMessage
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(ContactMessage $contactMessage)
|
||||||
|
{
|
||||||
|
$contactMessage->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.contact-messages.index')
|
||||||
|
->with('success', 'Pesan kontak berhasil dihapus.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
abstract class Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class FavoriteController extends Controller
|
||||||
|
{
|
||||||
|
// Konstruktor tidak diperlukan karena middleware auth sudah diterapkan di route
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle status favorit cafe
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $cafeId
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function toggleFavorite(Request $request, $cafeId)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Validasi input
|
||||||
|
if (!$cafeId || !is_numeric($cafeId)) {
|
||||||
|
Log::error('Invalid cafe ID provided: ' . $cafeId);
|
||||||
|
return response()->json(['success' => false, 'message' => 'ID cafe tidak valid'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cek apakah cafe dengan ID tersebut ada
|
||||||
|
$cafe = Cafe::find($cafeId);
|
||||||
|
if (!$cafe) {
|
||||||
|
Log::error('Cafe not found with ID: ' . $cafeId);
|
||||||
|
return response()->json(['success' => false, 'message' => 'Cafe tidak ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user) {
|
||||||
|
Log::error('User not authenticated for favorite toggle');
|
||||||
|
return response()->json(['success' => false, 'message' => 'Pengguna tidak terautentikasi'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Toggling favorite for user ID: ' . $user->id . ' and cafe ID: ' . $cafeId);
|
||||||
|
|
||||||
|
// Pemeriksaan apakah sudah favorit secara langsung menggunakan query
|
||||||
|
$existingFavorite = DB::table('favorites')
|
||||||
|
->where('user_id', $user->id)
|
||||||
|
->where('cafe_id', $cafeId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existingFavorite) {
|
||||||
|
// Hapus favorit
|
||||||
|
DB::table('favorites')
|
||||||
|
->where('user_id', $user->id)
|
||||||
|
->where('cafe_id', $cafeId)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$isFavorited = false;
|
||||||
|
Log::info('Favorite removed for user ID: ' . $user->id . ' and cafe ID: ' . $cafeId);
|
||||||
|
} else {
|
||||||
|
// Tambahkan favorit
|
||||||
|
DB::table('favorites')->insert([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'cafe_id' => $cafeId,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$isFavorited = true;
|
||||||
|
Log::info('Favorite added for user ID: ' . $user->id . ' and cafe ID: ' . $cafeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->wantsJson() || $request->ajax()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'isFavorited' => $isFavorited
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('success', $isFavorited ? 'Cafe ditambahkan ke favorit' : 'Cafe dihapus dari favorit');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error('Error toggling favorite: ' . $e->getMessage() . "\n" . $e->getTraceAsString());
|
||||||
|
|
||||||
|
if ($request->wantsJson() || $request->ajax()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Terjadi kesalahan: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('error', 'Terjadi kesalahan saat mengubah status favorit.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menampilkan daftar cafe favorit user
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$favorites = $user->favorites()->with('cafe')->get();
|
||||||
|
|
||||||
|
return view('favorites.index', [
|
||||||
|
'favorites' => $favorites
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Menampilkan halaman profil
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
return view('profile.index', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update informasi profil pengguna
|
||||||
|
*/
|
||||||
|
public function update(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,'.$user->id],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->update($validated);
|
||||||
|
|
||||||
|
return redirect()->route('profile.index')->with('success', 'Profil berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update password pengguna
|
||||||
|
*/
|
||||||
|
public function updatePassword(Request $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'current_password' => ['required', 'current_password'],
|
||||||
|
'password' => ['required', 'confirmed', Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
$user->password = Hash::make($validated['password']);
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
return redirect()->route('profile.index')->with('success', 'Password berhasil diperbarui!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use App\Models\SearchHistory;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class SmartSearchController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the search form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$currentStep = 1;
|
||||||
|
return view('cafe.search-fixed', compact('currentStep'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the search form and display results.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function search(Request $request)
|
||||||
|
{
|
||||||
|
$currentStep = 3;
|
||||||
|
$weights = $request->input('weight', []);
|
||||||
|
$criterias = $request->input('criteria', []);
|
||||||
|
$lokasi = $request->input('lokasi');
|
||||||
|
|
||||||
|
// Get cafes with ratings
|
||||||
|
$cafes = Cafe::with(['ratings.subcategory', 'ratings.category'])->get();
|
||||||
|
|
||||||
|
// Filter berdasarkan lokasi jika ada
|
||||||
|
if ($lokasi) {
|
||||||
|
$cafes = $cafes->filter(function($cafe) use ($lokasi) {
|
||||||
|
return stripos($cafe->lokasi, $lokasi) !== false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total semua bobot untuk normalisasi
|
||||||
|
$totalWeight = array_sum($weights);
|
||||||
|
if ($totalWeight == 0) {
|
||||||
|
// Jika tidak ada bobot, buat bobot merata
|
||||||
|
$categories = Category::all();
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$weights[$category->id] = 100 / $categories->count();
|
||||||
|
}
|
||||||
|
$totalWeight = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung skor SMART untuk setiap cafe
|
||||||
|
$cafeScores = [];
|
||||||
|
|
||||||
|
foreach ($cafes as $cafe) {
|
||||||
|
$score = 0;
|
||||||
|
$debugInfo = [];
|
||||||
|
|
||||||
|
$ratings = \Illuminate\Support\Facades\DB::table('cafe_ratings')
|
||||||
|
->join('subcategories', 'cafe_ratings.subcategory_id', '=', 'subcategories.id')
|
||||||
|
->join('categories', 'cafe_ratings.category_id', '=', 'categories.id')
|
||||||
|
->where('cafe_ratings.cafe_id', $cafe->id)
|
||||||
|
->select(
|
||||||
|
'cafe_ratings.category_id',
|
||||||
|
'categories.name as category_name',
|
||||||
|
'cafe_ratings.subcategory_id',
|
||||||
|
'subcategories.name as subcategory_name',
|
||||||
|
'subcategories.value'
|
||||||
|
)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($ratings as $rating) {
|
||||||
|
// Jika ada bobot untuk kategori ini
|
||||||
|
if (isset($weights[$rating->category_id])) {
|
||||||
|
$weight = floatval($weights[$rating->category_id]);
|
||||||
|
$normalizedWeight = $totalWeight > 0 ? $weight / $totalWeight : 0;
|
||||||
|
|
||||||
|
// Pastikan nilai valid
|
||||||
|
$value = max(1, intval($rating->value));
|
||||||
|
|
||||||
|
// Bonus nilai jika kriteria dipilih
|
||||||
|
if (isset($criterias[$rating->category_id]) &&
|
||||||
|
$criterias[$rating->category_id] == $rating->subcategory_id) {
|
||||||
|
$value = 5; // Nilai maksimal
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung utilitas - menerapkan konsep yang sama dengan view
|
||||||
|
$utilityValue = ($value - 1) / 4; // Normalisasi ke rentang 0-1 (jika nilai antara 1-5)
|
||||||
|
$ratingScore = $normalizedWeight * $utilityValue;
|
||||||
|
$score += $ratingScore;
|
||||||
|
|
||||||
|
// Simpan untuk debug
|
||||||
|
$debugInfo[$rating->category_name] = [
|
||||||
|
'bobot' => $weight,
|
||||||
|
'bobot_normal' => $normalizedWeight,
|
||||||
|
'nilai' => $value,
|
||||||
|
'nilai_asli' => $rating->value,
|
||||||
|
'subcategory' => $rating->subcategory_name,
|
||||||
|
'skor_kriteria' => $ratingScore
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cafeScores[$cafe->id] = [
|
||||||
|
'score' => $score,
|
||||||
|
'debug' => $debugInfo
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Urutkan cafe berdasarkan skor tertinggi
|
||||||
|
uasort($cafeScores, function($a, $b) {
|
||||||
|
return $b['score'] <=> $a['score'];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ambil id cafe yang sudah diurutkan
|
||||||
|
$rankedCafeIds = array_keys($cafeScores);
|
||||||
|
|
||||||
|
// Urutkan koleksi cafe sesuai skor
|
||||||
|
$rankedCafes = $cafes->sortBy(function($cafe) use ($rankedCafeIds) {
|
||||||
|
return array_search($cafe->id, $rankedCafeIds);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ambil hanya 10 cafe teratas
|
||||||
|
$rankedCafes = $rankedCafes->take(10);
|
||||||
|
|
||||||
|
// Persiapkan data hasil untuk disimpan
|
||||||
|
$resultsData = [];
|
||||||
|
foreach ($rankedCafes as $cafe) {
|
||||||
|
if (isset($cafeScores[$cafe->id])) {
|
||||||
|
$resultsData[$cafe->id] = [
|
||||||
|
'name' => $cafe->nama,
|
||||||
|
'score' => $cafeScores[$cafe->id]['score'],
|
||||||
|
'details' => $cafeScores[$cafe->id]['debug']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simpan hasil pencarian ke database jika user sudah login
|
||||||
|
if (Auth::check()) {
|
||||||
|
SearchHistory::create([
|
||||||
|
'user_id' => Auth::id(),
|
||||||
|
'weights' => $weights,
|
||||||
|
'criteria' => $criterias,
|
||||||
|
'location' => $lokasi,
|
||||||
|
'results' => $resultsData
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('cafe.search-fixed', compact('currentStep', 'rankedCafes', 'cafeScores'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display search history for the authenticated user.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function history()
|
||||||
|
{
|
||||||
|
$histories = SearchHistory::where('user_id', Auth::id())
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
|
return view('cafe.search-history', compact('histories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display search history detail.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function detail($id)
|
||||||
|
{
|
||||||
|
$history = SearchHistory::where('user_id', Auth::id())
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
// Retrieve cafes from the stored results
|
||||||
|
$cafeIds = array_keys($history->results ?? []);
|
||||||
|
$cafes = Cafe::whereIn('id', $cafeIds)->get();
|
||||||
|
|
||||||
|
// Map cafes to include their scores from history
|
||||||
|
$rankedCafes = $cafes->map(function($cafe) use ($history) {
|
||||||
|
$cafe->smart_score = $history->results[$cafe->id]['score'] ?? 0;
|
||||||
|
$cafe->smart_details = $history->results[$cafe->id]['details'] ?? [];
|
||||||
|
return $cafe;
|
||||||
|
})->sortByDesc('smart_score');
|
||||||
|
|
||||||
|
$weights = $history->weights;
|
||||||
|
|
||||||
|
return view('cafe.search-detail', compact('history', 'rankedCafes', 'weights'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, class-string|string>>
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
// Web middleware group
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
// API middleware group
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware aliases.
|
||||||
|
*
|
||||||
|
* Aliases may be used instead of class names to assign middleware to routes and groups.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middlewareAliases = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||||
|
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'admin' => \App\Http\Middleware\AdminMiddleware::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class AdminMiddleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if (Auth::check() && Auth::user()->role === 'admin') {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('home')->with('error', 'Anda tidak memiliki akses untuk halaman ini.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class Authenticate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class CheckRole
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, string $role): Response
|
||||||
|
{
|
||||||
|
if (!$request->user() || $request->user()->role !== $role) {
|
||||||
|
if ($request->user() && $request->user()->role === 'admin') {
|
||||||
|
return redirect()->route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('home')->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class EncryptCookies
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class PreventRequestsDuringMaintenance
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null ...$guards
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ...$guards)
|
||||||
|
{
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
$user = Auth::guard($guard)->user();
|
||||||
|
|
||||||
|
if ($user && $user->role === 'admin') {
|
||||||
|
return redirect()->route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class TrimStrings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class TrustProxies
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class ValidateSignature
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class VerifyCsrfToken
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class VerificationEmail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Verification Email',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'view.name',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class Cafe extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'nama',
|
||||||
|
'lokasi',
|
||||||
|
'area',
|
||||||
|
'gambar',
|
||||||
|
'latitude',
|
||||||
|
'longitude',
|
||||||
|
'harga_termurah',
|
||||||
|
'harga_termahal'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relasi ke cafe_ratings
|
||||||
|
*/
|
||||||
|
public function ratings()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CafeRating::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pengguna yang memfavoritkan cafe ini
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function favorites()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Favorite::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function favoritedBy()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(User::class, 'favorites');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cek apakah cafe ini difavoritkan oleh user tertentu
|
||||||
|
*
|
||||||
|
* @param int $userId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isFavoritedBy($userId)
|
||||||
|
{
|
||||||
|
return $this->favoritedBy()->where('user_id', $userId)->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan rating untuk kategori tertentu
|
||||||
|
*/
|
||||||
|
public function getCategoryRating($categoryId)
|
||||||
|
{
|
||||||
|
$rating = $this->ratings()->whereHas('subcategory', function($query) use ($categoryId) {
|
||||||
|
$query->where('category_id', $categoryId);
|
||||||
|
})->with('subcategory')->first();
|
||||||
|
|
||||||
|
return $rating ? $rating->subcategory : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nilai numerik untuk kategori tertentu
|
||||||
|
*/
|
||||||
|
public function getCategoryValue($categoryId)
|
||||||
|
{
|
||||||
|
$subcategory = $this->getCategoryRating($categoryId);
|
||||||
|
return $subcategory ? $subcategory->value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nama subcategory untuk kategori tertentu
|
||||||
|
*/
|
||||||
|
public function getCategoryName($categoryId)
|
||||||
|
{
|
||||||
|
$subcategory = $this->getCategoryRating($categoryId);
|
||||||
|
return $subcategory ? $subcategory->name : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nilai WiFi
|
||||||
|
*/
|
||||||
|
public function getWifiAttribute()
|
||||||
|
{
|
||||||
|
$wifiCategory = Category::where('name', 'Kecepatan WiFi')->first();
|
||||||
|
if (!$wifiCategory) return null;
|
||||||
|
|
||||||
|
return $this->getCategoryRating($wifiCategory->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nilai Jarak dengan Pusat Kota
|
||||||
|
*/
|
||||||
|
public function getJarakKampusAttribute()
|
||||||
|
{
|
||||||
|
$jarakCategory = Category::where('name', 'Jarak dengan Pusat Kota')->first();
|
||||||
|
if (!$jarakCategory) return null;
|
||||||
|
|
||||||
|
return $this->getCategoryRating($jarakCategory->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nilai Fasilitas
|
||||||
|
*/
|
||||||
|
public function getFasilitasAttribute()
|
||||||
|
{
|
||||||
|
$fasilitasCategory = Category::where('name', 'Fasilitas')->first();
|
||||||
|
if (!$fasilitasCategory) return null;
|
||||||
|
|
||||||
|
return $this->getCategoryRating($fasilitasCategory->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mendapatkan nilai Harga
|
||||||
|
*/
|
||||||
|
public function getHargaAttribute()
|
||||||
|
{
|
||||||
|
$hargaCategory = Category::where('name', 'Harga')->first();
|
||||||
|
if (!$hargaCategory) return null;
|
||||||
|
|
||||||
|
return $this->getCategoryRating($hargaCategory->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relasi ke cafe_images
|
||||||
|
*/
|
||||||
|
public function images()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CafeImage::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class CafeImage extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'cafe_id',
|
||||||
|
'image_path'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function cafe()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Cafe::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CafeRating extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'cafe_id',
|
||||||
|
'category_id',
|
||||||
|
'subcategory_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function cafe()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Cafe::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Category::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subcategory()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Subcategory::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Category extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
'description'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the model.
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(function ($category) {
|
||||||
|
$category->slug = Str::slug($category->name);
|
||||||
|
});
|
||||||
|
|
||||||
|
static::updating(function ($category) {
|
||||||
|
$category->slug = Str::slug($category->name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the subcategories for the category.
|
||||||
|
*/
|
||||||
|
public function subcategories()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Subcategory::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cafes for the category.
|
||||||
|
*/
|
||||||
|
public function cafes()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Cafe::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ContactMessage extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'message',
|
||||||
|
'is_read',
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Favorite extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'cafe_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cafe()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Cafe::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SearchHistory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'weights',
|
||||||
|
'criteria',
|
||||||
|
'location',
|
||||||
|
'results'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'weights' => 'array',
|
||||||
|
'criteria' => 'array',
|
||||||
|
'results' => 'array',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user that owns the search history.
|
||||||
|
*/
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Subcategory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'category_id',
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
'value',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the model.
|
||||||
|
*/
|
||||||
|
protected static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(function ($subcategory) {
|
||||||
|
$subcategory->slug = Str::slug($subcategory->name);
|
||||||
|
});
|
||||||
|
|
||||||
|
static::updating(function ($subcategory) {
|
||||||
|
$subcategory->slug = Str::slug($subcategory->name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the category that owns the subcategory.
|
||||||
|
*/
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Category::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use App\Notifications\CustomVerifyEmail;
|
||||||
|
|
||||||
|
class User extends Authenticatable implements MustVerifyEmail
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
'google_id',
|
||||||
|
'role',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the email verification notification.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function sendEmailVerificationNotification()
|
||||||
|
{
|
||||||
|
$this->notify(new CustomVerifyEmail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
'password' => 'hashed',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cafe yang difavoritkan oleh user
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function favoriteCafes()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Cafe::class, 'favorites', 'user_id', 'cafe_id')
|
||||||
|
->withTimestamps();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cek apakah user sudah memfavoritkan cafe tertentu
|
||||||
|
*
|
||||||
|
* @param int $cafeId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasFavorited($cafeId)
|
||||||
|
{
|
||||||
|
return $this->favorites()->where('cafe_id', $cafeId)->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function favorites()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Favorite::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class Weight extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'category_id',
|
||||||
|
'subcategory_id',
|
||||||
|
'weight_value',
|
||||||
|
'normalized_weight'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Category::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subcategory()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Subcategory::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
|
class CustomVerifyEmail extends Notification
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The callback that should be used to create the verify email URL.
|
||||||
|
*
|
||||||
|
* @var \Closure|null
|
||||||
|
*/
|
||||||
|
public static $createUrlCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback that should be used to build the mail message.
|
||||||
|
*
|
||||||
|
* @var \Closure|null
|
||||||
|
*/
|
||||||
|
public static $toMailCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array|string
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
$verificationUrl = $this->verificationUrl($notifiable);
|
||||||
|
|
||||||
|
if (static::$toMailCallback) {
|
||||||
|
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->buildMailMessage($verificationUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the verify email notification mail message for the given URL.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
protected function buildMailMessage($url)
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->subject('Verifikasi Alamat Email Anda')
|
||||||
|
->greeting('Halo!')
|
||||||
|
->line('Terima kasih telah mendaftar di aplikasi Recaje.')
|
||||||
|
->line('Silakan klik tombol di bawah ini untuk memverifikasi alamat email Anda.')
|
||||||
|
->action('Verifikasi Email', $url)
|
||||||
|
->line('Jika Anda tidak membuat akun, Anda dapat mengabaikan email ini.')
|
||||||
|
->salutation('Salam, Tim Recaje');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the verification URL for the given notifiable.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function verificationUrl($notifiable)
|
||||||
|
{
|
||||||
|
if (static::$createUrlCallback) {
|
||||||
|
return call_user_func(static::$createUrlCallback, $notifiable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return URL::temporarySignedRoute(
|
||||||
|
'verification.verify',
|
||||||
|
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||||
|
[
|
||||||
|
'id' => $notifiable->getKey(),
|
||||||
|
'hash' => sha1($notifiable->getEmailForVerification()),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a callback that should be used when creating the email verification URL.
|
||||||
|
*
|
||||||
|
* @param \Closure $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function createUrlUsing($callback)
|
||||||
|
{
|
||||||
|
static::$createUrlCallback = $callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a callback that should be used when building the notification mail message.
|
||||||
|
*
|
||||||
|
* @param \Closure $callback
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function toMailUsing($callback)
|
||||||
|
{
|
||||||
|
static::$toMailCallback = $callback;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path to your application's "home" route.
|
||||||
|
*
|
||||||
|
* Typically, users are redirected here after authentication.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const HOME = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define your route model bindings, pattern filters, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->configureRateLimiting();
|
||||||
|
|
||||||
|
$this->routes(function () {
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/web.php'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the rate limiters for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function configureRateLimiting()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
// Register the Composer autoloader...
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
// Bootstrap Laravel and handle the command...
|
||||||
|
/** @var Application $app */
|
||||||
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
$status = $app->handleCommand(new ArgvInput);
|
||||||
|
|
||||||
|
exit($status);
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
|
||||||
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
|
->withRouting(
|
||||||
|
web: __DIR__.'/../routes/web.php',
|
||||||
|
commands: __DIR__.'/../routes/console.php',
|
||||||
|
health: '/up',
|
||||||
|
)
|
||||||
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
|
//
|
||||||
|
})
|
||||||
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
|
//
|
||||||
|
})->create();
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
];
|
|
@ -0,0 +1,76 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://getcomposer.org/schema.json",
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The skeleton application for the Laravel framework.",
|
||||||
|
"keywords": ["laravel", "framework"],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.2",
|
||||||
|
"laravel/framework": "^12.0",
|
||||||
|
"laravel/socialite": "^5.20",
|
||||||
|
"laravel/tinker": "^2.10.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/pail": "^1.2.2",
|
||||||
|
"laravel/pint": "^1.13",
|
||||||
|
"laravel/sail": "^1.41",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"nunomaduro/collision": "^8.6",
|
||||||
|
"phpunit/phpunit": "^11.5.3"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"post-autoload-dump": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
|
"@php artisan package:discover --ansi"
|
||||||
|
],
|
||||||
|
"post-update-cmd": [
|
||||||
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||||
|
],
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
],
|
||||||
|
"post-create-project-cmd": [
|
||||||
|
"@php artisan key:generate --ansi",
|
||||||
|
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||||
|
"@php artisan migrate --graceful --ansi"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||||
|
],
|
||||||
|
"test": [
|
||||||
|
"@php artisan config:clear --ansi",
|
||||||
|
"@php artisan test"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true,
|
||||||
|
"php-http/discovery": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the name of your application, which will be used when the
|
||||||
|
| framework needs to place the application's name in a notification or
|
||||||
|
| other UI elements where an application name needs to be displayed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the "environment" your application is currently
|
||||||
|
| running in. This may determine how you prefer to configure various
|
||||||
|
| services the application utilizes. Set this in your ".env" file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Debug Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When your application is in debug mode, detailed error messages with
|
||||||
|
| stack traces will be shown on every error that occurs within your
|
||||||
|
| application. If disabled, a simple generic error page is shown.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application URL
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This URL is used by the console to properly generate URLs when using
|
||||||
|
| the Artisan command line tool. You should set this to the root of
|
||||||
|
| the application so that it's available within Artisan commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default timezone for your application, which
|
||||||
|
| will be used by the PHP date and date-time functions. The timezone
|
||||||
|
| is set to "UTC" by default as it is suitable for most use cases.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The application locale determines the default locale that will be used
|
||||||
|
| by Laravel's translation / localization methods. This option can be
|
||||||
|
| set to any locale for which you plan to have translation strings.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => env('APP_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This key is utilized by Laravel's encryption services and should be set
|
||||||
|
| to a random, 32 character string to ensure that all encrypted values
|
||||||
|
| are secure. You should do this prior to deploying the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'previous_keys' => [
|
||||||
|
...array_filter(
|
||||||
|
explode(',', env('APP_PREVIOUS_KEYS', ''))
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maintenance Mode Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options determine the driver used to determine and
|
||||||
|
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||||
|
| allow maintenance mode to be controlled across multiple machines.
|
||||||
|
|
|
||||||
|
| Supported drivers: "file", "cache"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'maintenance' => [
|
||||||
|
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||||
|
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
// ... other providers
|
||||||
|
/*
|
||||||
|
* Laravel Framework Service Providers...
|
||||||
|
*/
|
||||||
|
Illuminate\Auth\AuthServiceProvider::class,
|
||||||
|
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||||
|
Illuminate\Bus\BusServiceProvider::class,
|
||||||
|
Illuminate\Cache\CacheServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||||
|
Illuminate\Cookie\CookieServiceProvider::class,
|
||||||
|
Illuminate\Database\DatabaseServiceProvider::class,
|
||||||
|
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||||
|
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||||
|
Illuminate\Hashing\HashServiceProvider::class,
|
||||||
|
Illuminate\Mail\MailServiceProvider::class,
|
||||||
|
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||||
|
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||||
|
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||||
|
Illuminate\Queue\QueueServiceProvider::class,
|
||||||
|
Illuminate\Redis\RedisServiceProvider::class,
|
||||||
|
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||||
|
Illuminate\Session\SessionServiceProvider::class,
|
||||||
|
Illuminate\Translation\TranslationServiceProvider::class,
|
||||||
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Package Service Providers...
|
||||||
|
*/
|
||||||
|
Laravel\Socialite\SocialiteServiceProvider::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application Service Providers...
|
||||||
|
*/
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'aliases' => Facade::defaultAliases()->merge([
|
||||||
|
// ... other aliases
|
||||||
|
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
|
||||||
|
])->toArray(),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Defaults
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default authentication "guard" and password
|
||||||
|
| reset "broker" for your application. You may change these values
|
||||||
|
| as required, but they're a perfect start for most applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'defaults' => [
|
||||||
|
'guard' => env('AUTH_GUARD', 'web'),
|
||||||
|
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, you may define every authentication guard for your application.
|
||||||
|
| Of course, a great default configuration has been defined for you
|
||||||
|
| which utilizes session storage plus the Eloquent user provider.
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| Supported: "session"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guards' => [
|
||||||
|
'web' => [
|
||||||
|
'driver' => 'session',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| If you have multiple user tables or models you may configure multiple
|
||||||
|
| providers to represent the model / table. These providers may then
|
||||||
|
| be assigned to any extra authentication guards you have defined.
|
||||||
|
|
|
||||||
|
| Supported: "database", "eloquent"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
'users' => [
|
||||||
|
'driver' => 'eloquent',
|
||||||
|
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||||
|
],
|
||||||
|
|
||||||
|
// 'users' => [
|
||||||
|
// 'driver' => 'database',
|
||||||
|
// 'table' => 'users',
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Resetting Passwords
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options specify the behavior of Laravel's password
|
||||||
|
| reset functionality, including the table utilized for token storage
|
||||||
|
| and the user provider that is invoked to actually retrieve users.
|
||||||
|
|
|
||||||
|
| The expiry time is the number of minutes that each reset token will be
|
||||||
|
| considered valid. This security feature keeps tokens short-lived so
|
||||||
|
| they have less time to be guessed. You may change this as needed.
|
||||||
|
|
|
||||||
|
| The throttle setting is the number of seconds a user must wait before
|
||||||
|
| generating more password reset tokens. This prevents the user from
|
||||||
|
| quickly generating a very large amount of password reset tokens.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'passwords' => [
|
||||||
|
'users' => [
|
||||||
|
'provider' => 'users',
|
||||||
|
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||||
|
'expire' => 60,
|
||||||
|
'throttle' => 60,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Confirmation Timeout
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define the amount of seconds before a password confirmation
|
||||||
|
| window expires and users are asked to re-enter their password via the
|
||||||
|
| confirmation screen. By default, the timeout lasts for three hours.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default cache store that will be used by the
|
||||||
|
| framework. This connection is utilized if another isn't explicitly
|
||||||
|
| specified when running a cache operation inside the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('CACHE_STORE', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Stores
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define all of the cache "stores" for your application as
|
||||||
|
| well as their drivers. You may even define multiple stores for the
|
||||||
|
| same cache driver to group types of items stored in your caches.
|
||||||
|
|
|
||||||
|
| Supported drivers: "array", "database", "file", "memcached",
|
||||||
|
| "redis", "dynamodb", "octane", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stores' => [
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'driver' => 'array',
|
||||||
|
'serialize' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_CACHE_CONNECTION'),
|
||||||
|
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||||
|
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||||
|
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'file' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
'path' => storage_path('framework/cache/data'),
|
||||||
|
'lock_path' => storage_path('framework/cache/data'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'memcached' => [
|
||||||
|
'driver' => 'memcached',
|
||||||
|
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||||
|
'sasl' => [
|
||||||
|
env('MEMCACHED_USERNAME'),
|
||||||
|
env('MEMCACHED_PASSWORD'),
|
||||||
|
],
|
||||||
|
'options' => [
|
||||||
|
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||||
|
],
|
||||||
|
'servers' => [
|
||||||
|
[
|
||||||
|
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MEMCACHED_PORT', 11211),
|
||||||
|
'weight' => 100,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||||
|
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'dynamodb' => [
|
||||||
|
'driver' => 'dynamodb',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||||
|
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'octane' => [
|
||||||
|
'driver' => 'octane',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Key Prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||||
|
| stores, there might be other applications using the same cache. For
|
||||||
|
| that reason, you may prefix every cache key to avoid collisions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,174 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Database Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which of the database connections below you wish
|
||||||
|
| to use as your default connection for database operations. This is
|
||||||
|
| the connection which will be utilized unless another connection
|
||||||
|
| is explicitly specified when you execute a query / statement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Database Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below are all of the database connections defined for your application.
|
||||||
|
| An example configuration is provided for each database system which
|
||||||
|
| is supported by Laravel. You're free to add / remove connections.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sqlite' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||||
|
'prefix' => '',
|
||||||
|
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||||
|
'busy_timeout' => null,
|
||||||
|
'journal_mode' => null,
|
||||||
|
'synchronous' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'mysql' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'oyiwebid_recaje'),
|
||||||
|
'username' => env('DB_USERNAME', 'oyiwebid_faradina'),
|
||||||
|
'password' => env('DB_PASSWORD', 'Faradina14*'),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'mariadb' => [
|
||||||
|
'driver' => 'mariadb',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'pgsql' => [
|
||||||
|
'driver' => 'pgsql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '5432'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'search_path' => 'public',
|
||||||
|
'sslmode' => 'prefer',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqlsrv' => [
|
||||||
|
'driver' => 'sqlsrv',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
|
'port' => env('DB_PORT', '1433'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||||
|
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migration Repository Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This table keeps track of all the migrations that have already run for
|
||||||
|
| your application. Using this information, we can determine which of
|
||||||
|
| the migrations on disk haven't actually been run on the database.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'migrations' => [
|
||||||
|
'table' => 'migrations',
|
||||||
|
'update_date_on_publish' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Redis Databases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Redis is an open source, fast, and advanced key-value store that also
|
||||||
|
| provides a richer body of commands than a typical key-value system
|
||||||
|
| such as Memcached. You may define your connection settings here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
|
||||||
|
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
|
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||||
|
'persistent' => env('REDIS_PERSISTENT', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
'default' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_DB', '0'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_CACHE_DB', '1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Filesystem Disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default filesystem disk that should be used
|
||||||
|
| by the framework. The "local" disk, as well as a variety of cloud
|
||||||
|
| based disks are available to your application for file storage.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filesystem Disks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below you may configure as many filesystem disks as necessary, and you
|
||||||
|
| may even configure multiple disks for the same driver. Examples for
|
||||||
|
| most supported storage drivers are configured here for reference.
|
||||||
|
|
|
||||||
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disks' => [
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/private'),
|
||||||
|
'serve' => true,
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'public' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public'),
|
||||||
|
'url' => env('APP_URL').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
's3' => [
|
||||||
|
'driver' => 's3',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION'),
|
||||||
|
'bucket' => env('AWS_BUCKET'),
|
||||||
|
'url' => env('AWS_URL'),
|
||||||
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Symbolic Links
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the symbolic links that will be created when the
|
||||||
|
| `storage:link` Artisan command is executed. The array keys should be
|
||||||
|
| the locations of the links and the values should be their targets.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'links' => [
|
||||||
|
public_path('storage') => storage_path('app/public'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,132 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Monolog\Handler\NullHandler;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\SyslogUdpHandler;
|
||||||
|
use Monolog\Processor\PsrLogMessageProcessor;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default log channel that is utilized to write
|
||||||
|
| messages to your logs. The value provided here should match one of
|
||||||
|
| the channels present in the list of "channels" configured below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('LOG_CHANNEL', 'stack'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Deprecations Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the log channel that should be used to log warnings
|
||||||
|
| regarding deprecated PHP and library features. This allows you to get
|
||||||
|
| your application ready for upcoming major versions of dependencies.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'deprecations' => [
|
||||||
|
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||||
|
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log Channels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the log channels for your application. Laravel
|
||||||
|
| utilizes the Monolog PHP logging library, which includes a variety
|
||||||
|
| of powerful log handlers and formatters that you're free to use.
|
||||||
|
|
|
||||||
|
| Available drivers: "single", "daily", "slack", "syslog",
|
||||||
|
| "errorlog", "monolog", "custom", "stack"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'channels' => [
|
||||||
|
|
||||||
|
'stack' => [
|
||||||
|
'driver' => 'stack',
|
||||||
|
'channels' => explode(',', env('LOG_STACK', 'single')),
|
||||||
|
'ignore_exceptions' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'single' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'daily' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'days' => env('LOG_DAILY_DAYS', 14),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'driver' => 'slack',
|
||||||
|
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||||
|
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||||
|
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||||
|
'level' => env('LOG_LEVEL', 'critical'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'papertrail' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||||
|
'handler_with' => [
|
||||||
|
'host' => env('PAPERTRAIL_URL'),
|
||||||
|
'port' => env('PAPERTRAIL_PORT'),
|
||||||
|
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||||
|
],
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'stderr' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => StreamHandler::class,
|
||||||
|
'handler_with' => [
|
||||||
|
'stream' => 'php://stderr',
|
||||||
|
],
|
||||||
|
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'syslog' => [
|
||||||
|
'driver' => 'syslog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'errorlog' => [
|
||||||
|
'driver' => 'errorlog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'handler' => NullHandler::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'emergency' => [
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Mailer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default mailer that is used to send all email
|
||||||
|
| messages unless another mailer is explicitly specified when sending
|
||||||
|
| the message. All additional mailers can be configured within the
|
||||||
|
| "mailers" array. Examples of each type of mailer are provided.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('MAIL_MAILER', 'log'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Mailer Configurations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure all of the mailers used by your application plus
|
||||||
|
| their respective settings. Several examples have been configured for
|
||||||
|
| you and you are free to add your own as your application requires.
|
||||||
|
|
|
||||||
|
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||||
|
| when delivering an email. You may specify which one you're using for
|
||||||
|
| your mailers below. You may also add additional mailers if needed.
|
||||||
|
|
|
||||||
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||||
|
| "postmark", "resend", "log", "array",
|
||||||
|
| "failover", "roundrobin"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailers' => [
|
||||||
|
|
||||||
|
'smtp' => [
|
||||||
|
'transport' => 'smtp',
|
||||||
|
'scheme' => env('MAIL_SCHEME'),
|
||||||
|
'url' => env('MAIL_URL'),
|
||||||
|
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MAIL_PORT', 2525),
|
||||||
|
'username' => env('MAIL_USERNAME'),
|
||||||
|
'password' => env('MAIL_PASSWORD'),
|
||||||
|
'timeout' => null,
|
||||||
|
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'transport' => 'ses',
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'transport' => 'postmark',
|
||||||
|
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||||
|
// 'client' => [
|
||||||
|
// 'timeout' => 5,
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'transport' => 'resend',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sendmail' => [
|
||||||
|
'transport' => 'sendmail',
|
||||||
|
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'transport' => 'log',
|
||||||
|
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'transport' => 'array',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'transport' => 'failover',
|
||||||
|
'mailers' => [
|
||||||
|
'smtp',
|
||||||
|
'log',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
'roundrobin' => [
|
||||||
|
'transport' => 'roundrobin',
|
||||||
|
'mailers' => [
|
||||||
|
'ses',
|
||||||
|
'postmark',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global "From" Address
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You may wish for all emails sent by your application to be sent from
|
||||||
|
| the same address. Here you may specify a name and address that is
|
||||||
|
| used globally for all emails that are sent by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'from' => [
|
||||||
|
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||||
|
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Queue Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Laravel's queue supports a variety of backends via a single, unified
|
||||||
|
| API, giving you convenient access to each backend using identical
|
||||||
|
| syntax for each. The default queue connection is defined below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queue Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the connection options for every queue backend
|
||||||
|
| used by your application. An example configuration is provided for
|
||||||
|
| each backend supported by Laravel. You're also free to add more.
|
||||||
|
|
|
||||||
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sync' => [
|
||||||
|
'driver' => 'sync',
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||||
|
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||||
|
'queue' => env('DB_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'beanstalkd' => [
|
||||||
|
'driver' => 'beanstalkd',
|
||||||
|
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||||
|
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => 0,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqs' => [
|
||||||
|
'driver' => 'sqs',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||||
|
'queue' => env('SQS_QUEUE', 'default'),
|
||||||
|
'suffix' => env('SQS_SUFFIX'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||||
|
'queue' => env('REDIS_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => null,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Job Batching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following options configure the database and table that store job
|
||||||
|
| batching information. These options can be updated to any database
|
||||||
|
| connection and table which has been defined by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'batching' => [
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'job_batches',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Failed Queue Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These options configure the behavior of failed queue job logging so you
|
||||||
|
| can control how and where failed jobs are stored. Laravel ships with
|
||||||
|
| support for storing failed jobs in a simple file or in a database.
|
||||||
|
|
|
||||||
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => [
|
||||||
|
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'failed_jobs',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Third Party Services
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is for storing the credentials for third party services such
|
||||||
|
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||||
|
| location for this type of information, allowing packages to have
|
||||||
|
| a conventional file to locate the various service credentials.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'token' => env('POSTMARK_TOKEN'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'key' => env('RESEND_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'notifications' => [
|
||||||
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'google' => [
|
||||||
|
'client_id' => env('GOOGLE_CLIENT_ID'),
|
||||||
|
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
|
||||||
|
'redirect' => env('GOOGLE_REDIRECT'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,217 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Session Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines the default session driver that is utilized for
|
||||||
|
| incoming requests. Laravel supports a variety of storage options to
|
||||||
|
| persist session data. Database storage is a great default choice.
|
||||||
|
|
|
||||||
|
| Supported: "file", "cookie", "database", "apc",
|
||||||
|
| "memcached", "redis", "dynamodb", "array"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('SESSION_DRIVER', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Lifetime
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the number of minutes that you wish the session
|
||||||
|
| to be allowed to remain idle before it expires. If you want them
|
||||||
|
| to expire immediately when the browser is closed then you may
|
||||||
|
| indicate that via the expire_on_close configuration option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
|
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Encryption
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option allows you to easily specify that all of your session data
|
||||||
|
| should be encrypted before it's stored. All encryption is performed
|
||||||
|
| automatically by Laravel and you may use the session like normal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session File Location
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the "file" session driver, the session files are placed
|
||||||
|
| on disk. The default storage location is defined here; however, you
|
||||||
|
| are free to provide another location where they should be stored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'files' => storage_path('framework/sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" or "redis" session drivers, you may specify a
|
||||||
|
| connection that should be used to manage these sessions. This should
|
||||||
|
| correspond to a connection in your database configuration options.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('SESSION_CONNECTION'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" session driver, you may specify the table to
|
||||||
|
| be used to store sessions. Of course, a sensible default is defined
|
||||||
|
| for you; however, you're welcome to change this to another table.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'table' => env('SESSION_TABLE', 'sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using one of the framework's cache driven session backends, you may
|
||||||
|
| define the cache store which should be used to store the session data
|
||||||
|
| between requests. This must match one of your defined cache stores.
|
||||||
|
|
|
||||||
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => env('SESSION_STORE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Sweeping Lottery
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Some session drivers must manually sweep their storage location to get
|
||||||
|
| rid of old sessions from storage. Here are the chances that it will
|
||||||
|
| happen on a given request. By default, the odds are 2 out of 100.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lottery' => [2, 100],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the name of the session cookie that is created by
|
||||||
|
| the framework. Typically, you should not need to change this value
|
||||||
|
| since doing so does not grant a meaningful security improvement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cookie' => env(
|
||||||
|
'SESSION_COOKIE',
|
||||||
|
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||||
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The session cookie path determines the path for which the cookie will
|
||||||
|
| be regarded as available. Typically, this will be the root path of
|
||||||
|
| your application, but you're free to change this when necessary.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => env('SESSION_PATH', '/'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the domain and subdomains the session cookie is
|
||||||
|
| available to. By default, the cookie will be available to the root
|
||||||
|
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'domain' => env('SESSION_DOMAIN'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTPS Only Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By setting this option to true, session cookies will only be sent back
|
||||||
|
| to the server if the browser has a HTTPS connection. This will keep
|
||||||
|
| the cookie from being sent to you when it can't be done securely.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTP Access Only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will prevent JavaScript from accessing the
|
||||||
|
| value of the cookie and the cookie will only be accessible through
|
||||||
|
| the HTTP protocol. It's unlikely you should disable this option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Same-Site Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines how your cookies behave when cross-site requests
|
||||||
|
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||||
|
| will set this value to "lax" to permit secure cross-site requests.
|
||||||
|
|
|
||||||
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||||
|
|
|
||||||
|
| Supported: "lax", "strict", "none", null
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Partitioned Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will tie the cookie to the top-level site for
|
||||||
|
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||||
|
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1 @@
|
||||||
|
*.sqlite*
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The current password being used by the factory.
|
||||||
|
*/
|
||||||
|
protected static ?string $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => fake()->name(),
|
||||||
|
'email' => fake()->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*/
|
||||||
|
public function unverified(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (array $attributes) => [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?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::create('users', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
|
$table->string('password');
|
||||||
|
$table->rememberToken();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||||
|
$table->string('email')->primary();
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
|
$table->string('id')->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->string('ip_address', 45)->nullable();
|
||||||
|
$table->text('user_agent')->nullable();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->integer('last_activity')->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('users');
|
||||||
|
Schema::dropIfExists('password_reset_tokens');
|
||||||
|
Schema::dropIfExists('sessions');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?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::create('cache', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->mediumText('value');
|
||||||
|
$table->integer('expiration');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('cache_locks', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->string('owner');
|
||||||
|
$table->integer('expiration');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cache');
|
||||||
|
Schema::dropIfExists('cache_locks');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?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::create('jobs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('queue')->index();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->unsignedTinyInteger('attempts');
|
||||||
|
$table->unsignedInteger('reserved_at')->nullable();
|
||||||
|
$table->unsignedInteger('available_at');
|
||||||
|
$table->unsignedInteger('created_at');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('job_batches', function (Blueprint $table) {
|
||||||
|
$table->string('id')->primary();
|
||||||
|
$table->string('name');
|
||||||
|
$table->integer('total_jobs');
|
||||||
|
$table->integer('pending_jobs');
|
||||||
|
$table->integer('failed_jobs');
|
||||||
|
$table->longText('failed_job_ids');
|
||||||
|
$table->mediumText('options')->nullable();
|
||||||
|
$table->integer('cancelled_at')->nullable();
|
||||||
|
$table->integer('created_at');
|
||||||
|
$table->integer('finished_at')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->text('connection');
|
||||||
|
$table->text('queue');
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->longText('exception');
|
||||||
|
$table->timestamp('failed_at')->useCurrent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('jobs');
|
||||||
|
Schema::dropIfExists('job_batches');
|
||||||
|
Schema::dropIfExists('failed_jobs');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateContactMessagesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('contact_messages', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email');
|
||||||
|
$table->text('message');
|
||||||
|
$table->boolean('is_read')->default(false);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('contact_messages');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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('cafes', function (Blueprint $table) {
|
||||||
|
// Menambahkan kolom area setelah kolom lokasi dan sebelum kolom gambar
|
||||||
|
$table->string('area')->nullable()->after('lokasi');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cafes', function (Blueprint $table) {
|
||||||
|
// Menghapus kolom area jika migrasi di-rollback
|
||||||
|
$table->dropColumn('area');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateSearchHistoriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('search_histories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->json('weights')->nullable(); // Menyimpan bobot kriteria
|
||||||
|
$table->json('criteria')->nullable(); // Menyimpan kriteria yang dipilih
|
||||||
|
$table->string('location')->nullable(); // Menyimpan lokasi jika ada
|
||||||
|
$table->json('results')->nullable(); // Menyimpan hasil cafe dengan skor
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('search_histories');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('subcategory1')->nullable();
|
||||||
|
$table->string('subcategory2')->nullable();
|
||||||
|
$table->string('subcategory3')->nullable();
|
||||||
|
$table->string('subcategory4')->nullable();
|
||||||
|
$table->string('subcategory5')->nullable();
|
||||||
|
$table->integer('value1')->nullable();
|
||||||
|
$table->integer('value2')->nullable();
|
||||||
|
$table->integer('value3')->nullable();
|
||||||
|
$table->integer('value4')->nullable();
|
||||||
|
$table->integer('value5')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categories');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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('users', function (Blueprint $table) {
|
||||||
|
$table->string('google_id')->nullable()->after('email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('google_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -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('users', function (Blueprint $table) {
|
||||||
|
$table->string('role')->default('user')->after('email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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::create('cafes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('nama');
|
||||||
|
$table->string('lokasi');
|
||||||
|
$table->boolean('wifi')->default(false);
|
||||||
|
$table->string('jarak_kampus');
|
||||||
|
$table->text('fasilitas');
|
||||||
|
$table->string('harga');
|
||||||
|
$table->string('gambar')->nullable();
|
||||||
|
$table->decimal('latitude', 10, 7)->nullable();
|
||||||
|
$table->decimal('longitude', 10, 7)->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cafes');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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::create('categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->unique();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categories');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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::create('subcategories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('subcategories');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?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::create('weights', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('subcategory_id')->nullable()->constrained()->onDelete('cascade');
|
||||||
|
$table->decimal('weight_value', 5, 2); // Bobot untuk kategori atau subkategori
|
||||||
|
$table->decimal('normalized_weight', 5, 2); // Bobot yang sudah dinormalisasi
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('weights');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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('subcategories', function (Blueprint $table) {
|
||||||
|
$table->integer('value')->default(0)->after('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('subcategories', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('value');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?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
|
||||||
|
{
|
||||||
|
// Hapus tabel subcategories jika ada
|
||||||
|
Schema::dropIfExists('subcategories');
|
||||||
|
|
||||||
|
// Modifikasi tabel categories
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
// Tambahkan kolom untuk subkategori
|
||||||
|
$table->string('subcategory1')->nullable();
|
||||||
|
$table->string('subcategory2')->nullable();
|
||||||
|
$table->string('subcategory3')->nullable();
|
||||||
|
$table->string('subcategory4')->nullable();
|
||||||
|
$table->string('subcategory5')->nullable();
|
||||||
|
|
||||||
|
// Tambahkan kolom untuk nilai subkategori
|
||||||
|
$table->integer('value1')->default(1);
|
||||||
|
$table->integer('value2')->default(2);
|
||||||
|
$table->integer('value3')->default(3);
|
||||||
|
$table->integer('value4')->default(4);
|
||||||
|
$table->integer('value5')->default(5);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('categories', function (Blueprint $table) {
|
||||||
|
// Hapus kolom subkategori
|
||||||
|
$table->dropColumn([
|
||||||
|
'subcategory1', 'subcategory2', 'subcategory3', 'subcategory4', 'subcategory5',
|
||||||
|
'value1', 'value2', 'value3', 'value4', 'value5'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Buat ulang tabel subcategories
|
||||||
|
Schema::create('subcategories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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::create('cafe_ratings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('cafe_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('subcategory_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cafe_ratings');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// Langkah 1: Drop tabel cafe_ratings dahulu karena memiliki foreign key ke cafes
|
||||||
|
Schema::dropIfExists('cafe_ratings');
|
||||||
|
|
||||||
|
// Langkah 2: Buat tabel cafes_temp dengan struktur baru
|
||||||
|
Schema::create('cafes_temp', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('nama');
|
||||||
|
$table->string('lokasi');
|
||||||
|
$table->string('gambar')->nullable();
|
||||||
|
$table->decimal('latitude', 10, 7)->nullable();
|
||||||
|
$table->decimal('longitude', 10, 7)->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Langkah 3: Pindahkan data dari cafes ke cafes_temp
|
||||||
|
DB::statement('INSERT INTO cafes_temp (id, nama, lokasi, gambar, latitude, longitude, created_at, updated_at)
|
||||||
|
SELECT id, nama, lokasi, gambar, latitude, longitude, created_at, updated_at FROM cafes');
|
||||||
|
|
||||||
|
// Langkah 4: Drop tabel cafes lama
|
||||||
|
Schema::dropIfExists('cafes');
|
||||||
|
|
||||||
|
// Langkah 5: Rename cafes_temp menjadi cafes
|
||||||
|
Schema::rename('cafes_temp', 'cafes');
|
||||||
|
|
||||||
|
// Langkah 6: Buat kembali tabel cafe_ratings dengan struktur baru
|
||||||
|
Schema::create('cafe_ratings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('cafe_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('category_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('subcategory_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Tak perlu diimplementasikan karena ini adalah migrasi restrukturisasi
|
||||||
|
// Jika ingin rollback, perlu restore manual dari backup
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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::create('favorites', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('cafe_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// Pastikan kombinasi user_id dan cafe_id unik
|
||||||
|
$table->unique(['user_id', 'cafe_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('favorites');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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('cafe_images', function (Blueprint $table) {
|
||||||
|
$table->integer('sort_order')->default(0)->after('image_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cafe_images', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('sort_order');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('cafe_images', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('cafe_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('image_path');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cafe_images');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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('cafes', function (Blueprint $table) {
|
||||||
|
$table->decimal('harga_termurah', 10, 2)->nullable()->after('area');
|
||||||
|
$table->decimal('harga_termahal', 10, 2)->nullable()->after('harga_termurah');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('cafes', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['harga_termurah', 'harga_termahal']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AdminUserSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
User::create([
|
||||||
|
'name' => 'Admin',
|
||||||
|
'email' => 'admin@recaje.com',
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => Hash::make('admin123'),
|
||||||
|
'role' => 'admin',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->command->info('Admin user created successfully!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use App\Models\CafeRating;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CafeAndRatingsSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Hapus data cafe dan rating yang sudah ada
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
CafeRating::truncate();
|
||||||
|
Cafe::truncate();
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
|
||||||
|
// Data cafe dengan rating spesifik untuk setiap kategori
|
||||||
|
$cafes = [
|
||||||
|
['nama' => 'Poppins', 'lokasi' => null, 'harga' => 3, 'wifi' => 3, 'jam' => 5, 'fotogenik' => 4, 'jarak' => 3, 'fasilitas' => 3, 'area' => 'Indoor, Outdoor'],
|
||||||
|
['nama' => 'Teras JTI', 'lokasi' => null, 'harga' => 4, 'wifi' => 5, 'jam' => 3, 'fotogenik' => 3, 'jarak' => 5, 'fasilitas' => 4, 'area' => 'Indoor, Semi Outdoor, Outdoor'],
|
||||||
|
['nama' => 'Nugas Jember', 'lokasi' => null, 'harga' => 4, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 1, 'jarak' => 4, 'fasilitas' => 1, 'area' => 'Semi Outdoor'],
|
||||||
|
['nama' => 'Kopi Kampus', 'lokasi' => null, 'harga' => 4, 'wifi' => 3, 'jam' => 5, 'fotogenik' => 1, 'jarak' => 3, 'fasilitas' => 3, 'area' => 'Semi Outdoor'],
|
||||||
|
['nama' => 'Eterno', 'lokasi' => null, 'harga' => 2, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 4, 'jarak' => 3, 'fasilitas' => 5, 'area' => 'Indoor, Outdoor'],
|
||||||
|
['nama' => 'Kattappa', 'lokasi' => null, 'harga' => 3, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 4, 'jarak' => 3, 'fasilitas' => 4, 'area' => 'Indoor, Semi Outdoor, Outdoor'],
|
||||||
|
['nama' => 'Fifty-Fifty', 'lokasi' => null, 'harga' => 4, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 2, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Semi Outdoor'],
|
||||||
|
['nama' => 'Discuss Space & Coffee', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 4, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Subur', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 5, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Nuansa', 'lokasi' => null, 'harga' => 4, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 2, 'jarak' => 3, 'fasilitas' => 5, 'area' => 'Indoor, Semi Outdoor'],
|
||||||
|
['nama' => 'Nol Kilometer', 'lokasi' => null, 'harga' => 5, 'wifi' => 2, 'jam' => 3, 'fotogenik' => 1, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Semi Outdoor'],
|
||||||
|
['nama' => 'Tanaloka', 'lokasi' => null, 'harga' => 2, 'wifi' => 4, 'jam' => 2, 'fotogenik' => 5, 'jarak' => 3, 'fasilitas' => 5, 'area' => 'Indoor, Semi Outdoor, Outdoor'],
|
||||||
|
['nama' => 'Wafa', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 2, 'fasilitas' => 5, 'area' => 'Indoor, Outdoor'],
|
||||||
|
['nama' => '888', 'lokasi' => null, 'harga' => 2, 'wifi' => 5, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor, Semi Outdoor'],
|
||||||
|
['nama' => 'Sorai', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 3, 'area' => 'Indoor, Outdoor'],
|
||||||
|
['nama' => 'Tharuh', 'lokasi' => null, 'harga' => 3, 'wifi' => 2, 'jam' => 5, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor, Semi Outdoor'],
|
||||||
|
['nama' => 'Contact', 'lokasi' => null, 'harga' => 3, 'wifi' => 2, 'jam' => 5, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor, Semi Outdoor, Outdoor'],
|
||||||
|
['nama' => 'Cus Cus', 'lokasi' => null, 'harga' => 3, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 4, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor, Outdoor'],
|
||||||
|
['nama' => 'Grufi', 'lokasi' => null, 'harga' => 2, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 5, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Tomoro', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 4, 'fasilitas' => 4, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Fore', 'lokasi' => null, 'harga' => 2, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Fox', 'lokasi' => null, 'harga' => 3, 'wifi' => 3, 'jam' => 4, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 1, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Perasa', 'lokasi' => null, 'harga' => 2, 'wifi' => 3, 'jam' => 5, 'fotogenik' => 3, 'jarak' => 3, 'fasilitas' => 3, 'area' => 'Indoor'],
|
||||||
|
['nama' => 'Kopi Boss', 'lokasi' => null, 'harga' => 5, 'wifi' => 3, 'jam' => 5, 'fotogenik' => 1, 'jarak' => 3, 'fasilitas' => 3, 'area' => 'Semi Outdoor'],
|
||||||
|
['nama' => 'Navas', 'lokasi' => null, 'harga' => 3, 'wifi' => 4, 'jam' => 5, 'fotogenik' => 2, 'jarak' => 3, 'fasilitas' => 2, 'area' => 'Semi Outdoor'],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Get all categories and their subcategories
|
||||||
|
$categories = Category::all();
|
||||||
|
|
||||||
|
// Mendapatkan kategori berdasarkan namanya untuk memudahkan penugasan subcategory
|
||||||
|
$hargaCategory = Category::where('name', 'Harga')->first();
|
||||||
|
$wifiCategory = Category::where('name', 'Kecepatan WiFi')->first();
|
||||||
|
$jamOperasionalCategory = Category::where('name', 'Jam Operasional')->first();
|
||||||
|
$fotogenikCategory = Category::where('name', 'Fotogenik')->first();
|
||||||
|
$areaCategory = Category::where('name', 'Area (Outdoor/Indoor)')->first();
|
||||||
|
$jarakCategory = Category::where('name', 'Jarak dengan Kampus')->first();
|
||||||
|
$fasilitasCategory = Category::where('name', 'Fasilitas')->first();
|
||||||
|
|
||||||
|
// Membuat cafe dan ratings
|
||||||
|
foreach ($cafes as $cafeData) {
|
||||||
|
// Buat cafe dengan data dasar
|
||||||
|
$cafe = Cafe::create([
|
||||||
|
'nama' => $cafeData['nama'],
|
||||||
|
'lokasi' => $cafeData['lokasi'],
|
||||||
|
'area' => $cafeData['area'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assign ratings berdasarkan data yang sudah ditentukan
|
||||||
|
// Harga
|
||||||
|
if ($hargaCategory) {
|
||||||
|
$this->createRating($cafe->id, $hargaCategory->id, $cafeData['harga']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WiFi
|
||||||
|
if ($wifiCategory) {
|
||||||
|
$this->createRating($cafe->id, $wifiCategory->id, $cafeData['wifi']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jam Operasional
|
||||||
|
if ($jamOperasionalCategory) {
|
||||||
|
$this->createRating($cafe->id, $jamOperasionalCategory->id, $cafeData['jam']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fotogenik
|
||||||
|
if ($fotogenikCategory) {
|
||||||
|
$this->createRating($cafe->id, $fotogenikCategory->id, $cafeData['fotogenik']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jarak
|
||||||
|
if ($jarakCategory) {
|
||||||
|
$this->createRating($cafe->id, $jarakCategory->id, $cafeData['jarak']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fasilitas
|
||||||
|
if ($fasilitasCategory) {
|
||||||
|
$this->createRating($cafe->id, $fasilitasCategory->id, $cafeData['fasilitas']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Membuat rating berdasarkan category_id dan nilai
|
||||||
|
*/
|
||||||
|
private function createRating($cafeId, $categoryId, $value)
|
||||||
|
{
|
||||||
|
// Cari subcategory yang sesuai dengan category_id dan value
|
||||||
|
$subcategory = Subcategory::where('category_id', $categoryId)
|
||||||
|
->where('value', $value)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($subcategory) {
|
||||||
|
CafeRating::create([
|
||||||
|
'cafe_id' => $cafeId,
|
||||||
|
'category_id' => $categoryId,
|
||||||
|
'subcategory_id' => $subcategory->id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Cafe;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CafePriceSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Data harga berdasarkan ID cafe yang sudah ada
|
||||||
|
$priceData = [
|
||||||
|
1 => ['harga_termurah' => 18000, 'harga_termahal' => 25000], // Poppins
|
||||||
|
2 => ['harga_termurah' => 10000, 'harga_termahal' => 18000], // Teras JTI
|
||||||
|
3 => ['harga_termurah' => 10000, 'harga_termahal' => 20000], // Nugas Jember
|
||||||
|
4 => ['harga_termurah' => 4000, 'harga_termahal' => 18000], // Kopi Kampus
|
||||||
|
5 => ['harga_termurah' => 15000, 'harga_termahal' => 40000], // Eterno
|
||||||
|
7 => ['harga_termurah' => 8000, 'harga_termahal' => 20000], // Fifty-Fifty
|
||||||
|
8 => ['harga_termurah' => 10000, 'harga_termahal' => 35000], // Discuss Space & Coffee
|
||||||
|
9 => ['harga_termurah' => 12000, 'harga_termahal' => 34000], // Subur
|
||||||
|
10 => ['harga_termurah' => 6000, 'harga_termahal' => 15000], // Nuansa
|
||||||
|
11 => ['harga_termurah' => 6000, 'harga_termahal' => 8000], // Nol Kilometer
|
||||||
|
13 => ['harga_termurah' => 6000, 'harga_termahal' => 25000], // Wafa
|
||||||
|
14 => ['harga_termurah' => 15000, 'harga_termahal' => 45000], // 888
|
||||||
|
15 => ['harga_termurah' => 7000, 'harga_termahal' => 25000], // Sorai
|
||||||
|
16 => ['harga_termurah' => 8000, 'harga_termahal' => 23000], // Tharuh
|
||||||
|
17 => ['harga_termurah' => 12000, 'harga_termahal' => 38000], // Contact
|
||||||
|
18 => ['harga_termurah' => 14000, 'harga_termahal' => 20000], // Cus Cus
|
||||||
|
19 => ['harga_termurah' => 18000, 'harga_termahal' => 34000], // Grufi
|
||||||
|
20 => ['harga_termurah' => 15000, 'harga_termahal' => 25000], // Tomoro
|
||||||
|
21 => ['harga_termurah' => 22000, 'harga_termahal' => 40000], // Fore
|
||||||
|
22 => ['harga_termurah' => 1500, 'harga_termahal' => 37000], // Fox
|
||||||
|
23 => ['harga_termurah' => 12000, 'harga_termahal' => 45000], // Perasa
|
||||||
|
24 => ['harga_termurah' => 5000, 'harga_termahal' => 15000], // Kopi Boss
|
||||||
|
25 => ['harga_termurah' => 10000, 'harga_termahal' => 30000], // Navas
|
||||||
|
26 => ['harga_termurah' => 15000, 'harga_termahal' => 35000], // Kattappa (ID 26)
|
||||||
|
28 => ['harga_termurah' => 17000, 'harga_termahal' => 47000], // Tanaloka (ID 28)
|
||||||
|
];
|
||||||
|
|
||||||
|
// Update harga untuk setiap cafe
|
||||||
|
foreach ($priceData as $cafeId => $prices) {
|
||||||
|
$cafe = Cafe::find($cafeId);
|
||||||
|
|
||||||
|
if ($cafe) {
|
||||||
|
$cafe->update([
|
||||||
|
'harga_termurah' => $prices['harga_termurah'],
|
||||||
|
'harga_termahal' => $prices['harga_termahal']
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo "Updated cafe ID {$cafeId} ({$cafe->nama}): {$prices['harga_termurah']} - {$prices['harga_termahal']}\n";
|
||||||
|
} else {
|
||||||
|
echo "Cafe with ID {$cafeId} not found\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,236 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CategoryAndSubcategorySeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Hapus data yang sudah ada untuk menghindari duplikasi
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
Subcategory::truncate();
|
||||||
|
Category::truncate();
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
|
||||||
|
// Kategori 1: Harga
|
||||||
|
$harga = Category::create([
|
||||||
|
'name' => 'Harga'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Harga
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $harga->id,
|
||||||
|
'name' => 'Sangat Murah (<10k/porsi)',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $harga->id,
|
||||||
|
'name' => 'Murah (10k–15k)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $harga->id,
|
||||||
|
'name' => 'Sedang (15k–25k)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $harga->id,
|
||||||
|
'name' => 'Agak Mahal (25k–35k)',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $harga->id,
|
||||||
|
'name' => 'Mahal (>35k)',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 2: Kecepatan WiFi
|
||||||
|
$wifi = Category::create([
|
||||||
|
'name' => 'Kecepatan WiFi'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Kecepatan WiFi
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $wifi->id,
|
||||||
|
'name' => 'Sangat Cepat (>50 Mbps)',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $wifi->id,
|
||||||
|
'name' => 'Cepat (30–50 Mbps)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $wifi->id,
|
||||||
|
'name' => 'Sedang (15–30 Mbps)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $wifi->id,
|
||||||
|
'name' => 'Lambat (5–15 Mbps)',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $wifi->id,
|
||||||
|
'name' => 'Sangat Lambat (<5 Mbps)',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 3: Jam Operasional
|
||||||
|
$jamOperasional = Category::create([
|
||||||
|
'name' => 'Jam Operasional'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Jam Operasional
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jamOperasional->id,
|
||||||
|
'name' => '24 Jam',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jamOperasional->id,
|
||||||
|
'name' => '08.00–00.00 (16 jam)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jamOperasional->id,
|
||||||
|
'name' => '10.00–22.00 (12 jam)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jamOperasional->id,
|
||||||
|
'name' => '<10 jam operasional',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jamOperasional->id,
|
||||||
|
'name' => 'Tidak konsisten / Tidak tetap',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 4: Fotogenik
|
||||||
|
$fotogenik = Category::create([
|
||||||
|
'name' => 'Fotogenik'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Fotogenik
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fotogenik->id,
|
||||||
|
'name' => 'Sangat Fotogenik (Desain unik, banyak spot foto)',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fotogenik->id,
|
||||||
|
'name' => 'Fotogenik (Desain bagus, cukup spot foto)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fotogenik->id,
|
||||||
|
'name' => 'Cukup Fotogenik (estetis biasa saja)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fotogenik->id,
|
||||||
|
'name' => 'Kurang Fotogenik',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fotogenik->id,
|
||||||
|
'name' => 'Tidak Fotogenik',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 5: Area (Luas Tempat)
|
||||||
|
$area = Category::create([
|
||||||
|
'name' => 'Area (Outdoor/Indoor)'
|
||||||
|
]);
|
||||||
|
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $area->id,
|
||||||
|
'name' => 'Outdoor & Indoor',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $area->id,
|
||||||
|
'name' => 'Indoor',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $area->id,
|
||||||
|
'name' => 'Outdoor',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 6: Jarak dengan Kampus
|
||||||
|
$jarak = Category::create([
|
||||||
|
'name' => 'Jarak dengan Kampus'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Jarak dengan Kampus
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jarak->id,
|
||||||
|
'name' => 'Sangat Dekat (≤1 Km)',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jarak->id,
|
||||||
|
'name' => 'Dekat (1–2 Km)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jarak->id,
|
||||||
|
'name' => 'Sedang (2–5 Km)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jarak->id,
|
||||||
|
'name' => 'Jauh (5–10 Km)',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $jarak->id,
|
||||||
|
'name' => 'Sangat Jauh (>10 Km)',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Kategori 7: Fasilitas
|
||||||
|
$fasilitas = Category::create([
|
||||||
|
'name' => 'Fasilitas'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Subkategori Fasilitas
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fasilitas->id,
|
||||||
|
'name' => 'Sangat Lengkap (5 fasilitas)',
|
||||||
|
'value' => 5
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fasilitas->id,
|
||||||
|
'name' => 'Lengkap (4 fasilitas)',
|
||||||
|
'value' => 4
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fasilitas->id,
|
||||||
|
'name' => 'Cukup (3 fasilitas)',
|
||||||
|
'value' => 3
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fasilitas->id,
|
||||||
|
'name' => 'Kurang (2 fasilitas)',
|
||||||
|
'value' => 2
|
||||||
|
]);
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $fasilitas->id,
|
||||||
|
'name' => 'Minim / Tidak Lengkap (0–1 fasilitas)',
|
||||||
|
'value' => 1
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CategorySeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Hapus data yang ada terlebih dahulu
|
||||||
|
DB::table('categories')->truncate();
|
||||||
|
|
||||||
|
// Data kategori dengan subkategori
|
||||||
|
$categories = [
|
||||||
|
[
|
||||||
|
'name' => 'Jarak Kampus',
|
||||||
|
'subcategory1' => 'Sangat Dekat',
|
||||||
|
'subcategory2' => 'Dekat',
|
||||||
|
'subcategory3' => 'Sedang',
|
||||||
|
'subcategory4' => 'Jauh',
|
||||||
|
'subcategory5' => 'Sangat Jauh',
|
||||||
|
'value1' => 5,
|
||||||
|
'value2' => 4,
|
||||||
|
'value3' => 3,
|
||||||
|
'value4' => 2,
|
||||||
|
'value5' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Kisaran Harga',
|
||||||
|
'subcategory1' => 'Sangat Murah',
|
||||||
|
'subcategory2' => 'Murah',
|
||||||
|
'subcategory3' => 'Sedang',
|
||||||
|
'subcategory4' => 'Mahal',
|
||||||
|
'subcategory5' => 'Sangat Mahal',
|
||||||
|
'value1' => 5,
|
||||||
|
'value2' => 4,
|
||||||
|
'value3' => 3,
|
||||||
|
'value4' => 2,
|
||||||
|
'value5' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Fasilitas',
|
||||||
|
'subcategory1' => 'Sangat Lengkap',
|
||||||
|
'subcategory2' => 'Lengkap',
|
||||||
|
'subcategory3' => 'Cukup',
|
||||||
|
'subcategory4' => 'Kurang',
|
||||||
|
'subcategory5' => 'Sangat Kurang',
|
||||||
|
'value1' => 5,
|
||||||
|
'value2' => 4,
|
||||||
|
'value3' => 3,
|
||||||
|
'value4' => 2,
|
||||||
|
'value5' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'Kecepatan WiFi',
|
||||||
|
'subcategory1' => 'Sangat Cepat',
|
||||||
|
'subcategory2' => 'Cepat',
|
||||||
|
'subcategory3' => 'Sedang',
|
||||||
|
'subcategory4' => 'Lambat',
|
||||||
|
'subcategory5' => 'Sangat Lambat',
|
||||||
|
'value1' => 5,
|
||||||
|
'value2' => 4,
|
||||||
|
'value3' => 3,
|
||||||
|
'value4' => 2,
|
||||||
|
'value5' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// Insert data kategori
|
||||||
|
DB::table('categories')->insert($categories);
|
||||||
|
|
||||||
|
$this->command->info('Categories seeded successfully!');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Seed the application's database.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// User::factory(10)->create();
|
||||||
|
|
||||||
|
// User::factory()->create([
|
||||||
|
// 'name' => 'Test User',
|
||||||
|
// 'email' => 'test@example.com',
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
$this->call([
|
||||||
|
AdminUserSeeder::class,
|
||||||
|
// CategorySeeder::class,
|
||||||
|
// SubcategorySeeder::class,
|
||||||
|
CategoryAndSubcategorySeeder::class,
|
||||||
|
CafeAndRatingsSeeder::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\Subcategory;
|
||||||
|
use App\Models\Category;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class SubcategorySeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Hapus data yang ada terlebih dahulu
|
||||||
|
DB::table('subcategories')->truncate();
|
||||||
|
|
||||||
|
// Data subkategori berdasarkan kategori
|
||||||
|
$subcategories = [
|
||||||
|
'Jarak Kampus' => [
|
||||||
|
'Sangat Dekat (< 1 km)',
|
||||||
|
'Dekat (1-2 km)',
|
||||||
|
'Sedang (2-3 km)',
|
||||||
|
'Jauh (> 3 km)'
|
||||||
|
],
|
||||||
|
'Kisaran Harga' => [
|
||||||
|
'Sangat Murah (< Rp 10.000)',
|
||||||
|
'Murah (Rp 10.000 - Rp 20.000)',
|
||||||
|
'Sedang (Rp 20.000 - Rp 30.000)',
|
||||||
|
'Mahal (> Rp 30.000)'
|
||||||
|
],
|
||||||
|
'Fasilitas' => [
|
||||||
|
'Sangat Lengkap',
|
||||||
|
'Lengkap',
|
||||||
|
'Cukup',
|
||||||
|
'Minimal'
|
||||||
|
],
|
||||||
|
'Kecepatan WiFi' => [
|
||||||
|
'Sangat Cepat (> 50 Mbps)',
|
||||||
|
'Cepat (30-50 Mbps)',
|
||||||
|
'Sedang (10-30 Mbps)',
|
||||||
|
'Lambat (< 10 Mbps)'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
// Insert data subkategori
|
||||||
|
foreach ($subcategories as $categoryName => $items) {
|
||||||
|
$category = Category::where('name', $categoryName)->first();
|
||||||
|
|
||||||
|
if ($category) {
|
||||||
|
foreach ($items as $subcategoryName) {
|
||||||
|
Subcategory::create([
|
||||||
|
'category_id' => $category->id,
|
||||||
|
'name' => $subcategoryName,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->command->info('Subcategories seeded successfully!');
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build",
|
||||||
|
"dev": "vite"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/vite": "^4.0.0",
|
||||||
|
"axios": "^1.8.2",
|
||||||
|
"concurrently": "^9.0.1",
|
||||||
|
"laravel-vite-plugin": "^1.2.0",
|
||||||
|
"tailwindcss": "^4.0.0",
|
||||||
|
"vite": "^6.2.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"leaflet": "^1.9.4",
|
||||||
|
"leaflet-control-geocoder": "^3.1.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Unit">
|
||||||
|
<directory>tests/Unit</directory>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="Feature">
|
||||||
|
<directory>tests/Feature</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>app</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
<php>
|
||||||
|
<env name="APP_ENV" value="testing"/>
|
||||||
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||||
|
<env name="CACHE_STORE" value="array"/>
|
||||||
|
<env name="DB_CONNECTION" value="sqlite"/>
|
||||||
|
<env name="DB_DATABASE" value=":memory:"/>
|
||||||
|
<env name="MAIL_MAILER" value="array"/>
|
||||||
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||||
|
</php>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import laravel from 'laravel-vite-plugin';
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
laravel({
|
||||||
|
input: ['resources/css/app.css', 'resources/js/app.js'],
|
||||||
|
refresh: true,
|
||||||
|
}),
|
||||||
|
tailwindcss(),
|
||||||
|
],
|
||||||
|
});
|
Loading…
Reference in New Issue