This commit is contained in:
iFannJR 2026-05-30 13:55:07 +07:00
commit 9b4d97bd3b
148 changed files with 17917 additions and 0 deletions

18
.editorconfig Normal file
View File

@ -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
[compose.yaml]
indent_size = 4

65
.env.example Normal file
View File

@ -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}"

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db

33
README.md Normal file
View File

@ -0,0 +1,33 @@
```bash
# Clone & masuk folder
cd WebSAW-LOCAL
# Install dependency PHP
composer install
# Salin env
cp .env.example .env
php artisan key:generate
# Database (MySQL)
# Set di .env: DB_CONNECTION=mysql, DB_DATABASE=..., DB_USERNAME=..., DB_PASSWORD=...
php artisan migrate
php artisan db:seed
# Storage link (untuk gambar produk)
php artisan storage:link
# Frontend (wajib agar CSS/JS dan warna tampil)
npm install
npm run build
# Saat development: jalankan di terminal terpisah: npm run dev
```
## Menjalankan
```bash
php artisan serve
# Buka http://localhost:8000
- Admin: `admin@toy.com` / `password`
- User: `user@toy.com` / `password`
```

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreCriteriaRequest;
use App\Models\Criteria;
class CriteriaController extends Controller
{
public function index()
{
$criterias = Criteria::orderBy('weight_order')->get();
return view('admin.criterias.index', compact('criterias'));
}
public function create()
{
return view('admin.criterias.create');
}
public function store(StoreCriteriaRequest $request)
{
Criteria::create($request->validated());
return redirect()->route('admin.criterias.index')->with('success', 'Kriteria berhasil ditambahkan.');
}
public function edit(Criteria $criteria)
{
return view('admin.criterias.edit', compact('criteria'));
}
public function update(StoreCriteriaRequest $request, Criteria $criteria)
{
$criteria->update($request->validated());
return redirect()->route('admin.criterias.index')->with('success', 'Kriteria berhasil diubah.');
}
public function destroy(Criteria $criteria)
{
$criteria->delete();
return redirect()->route('admin.criterias.index')->with('success', 'Kriteria berhasil dihapus.');
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\Transaction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class DashboardController extends Controller
{
public function index(Request $request)
{
Transaction::cancelOverduePendingPickup();
$currentYear = (int) now()->year;
$selectedYear = (int) $request->input('year', $currentYear);
$monthInput = $request->input('month');
$selectedMonth = is_numeric($monthInput) ? (int) $monthInput : null;
if ($selectedYear < 2000 || $selectedYear > 2100) {
$selectedYear = $currentYear;
}
if ($selectedMonth !== null && ($selectedMonth < 1 || $selectedMonth > 12)) {
$selectedMonth = null;
}
$totalProducts = Product::count();
$totalTransactions = Transaction::count();
$salesChartQuery = Transaction::query()
->where('status', 'paid')
->whereYear('created_at', $selectedYear);
if ($selectedMonth !== null) {
$salesChartQuery->whereMonth('created_at', $selectedMonth);
}
$salesChart = $salesChartQuery
->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(total) as total'))
->groupBy('date')
->orderBy('date')
->get();
$monthlyRevenueRows = Transaction::query()
->where('status', 'paid')
->whereYear('created_at', $selectedYear)
->selectRaw('MONTH(created_at) as month_num, SUM(total) as total')
->groupBy('month_num')
->orderBy('month_num')
->get()
->keyBy('month_num');
$monthlyRevenue = collect(range(1, 12))->map(function ($month) use ($monthlyRevenueRows) {
$row = $monthlyRevenueRows->get($month);
return [
'month' => now()->month($month)->translatedFormat('M'),
'total' => (float) ($row->total ?? 0),
];
});
$statusBaseQuery = Transaction::query()->whereYear('created_at', $selectedYear);
if ($selectedMonth !== null) {
$statusBaseQuery->whereMonth('created_at', $selectedMonth);
}
$statusBreakdown = [
'pending' => (clone $statusBaseQuery)->where('status', 'pending')->count(),
'paid' => (clone $statusBaseQuery)->where('status', 'paid')->count(),
'cancelled' => (clone $statusBaseQuery)->where('status', 'cancelled')->count(),
];
$availableYears = Transaction::query()
->selectRaw('YEAR(created_at) as year')
->distinct()
->orderByDesc('year')
->pluck('year')
->map(fn ($year) => (int) $year)
->filter()
->values();
if ($availableYears->isEmpty()) {
$availableYears = collect([$currentYear]);
}
return view('admin.dashboard', compact(
'totalProducts',
'totalTransactions',
'salesChart',
'monthlyRevenue',
'statusBreakdown',
'selectedYear',
'selectedMonth',
'availableYears'
));
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProductRequest;
use App\Http\Requests\UpdateProductRequest;
use App\Models\Criteria;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
class ProductController extends Controller
{
public function index(Request $request)
{
$products = Product::with('criterias')
->when($request->search, fn ($q, $v) => $q->where('name', 'like', "%{$v}%"))
->latest()
->paginate(10)
->withQueryString();
return view('admin.products.index', compact('products'));
}
public function create()
{
$criterias = Criteria::orderBy('weight_order')->get();
return view('admin.products.create', compact('criterias'));
}
public function store(StoreProductRequest $request)
{
$data = $request->validated();
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('products', 'public');
}
$criteriaValuesById = $data['criteria_values'] ?? [];
unset($data['criteria_values']);
$product = Product::create($data);
$criterias = Criteria::all();
$sync = [];
foreach ($criterias as $c) {
if ($c->name === 'Harga') {
$val = $product->price;
} else {
$val = $criteriaValuesById[$c->id] ?? 0;
}
$sync[$c->id] = ['value' => $val];
}
$product->criterias()->sync($sync);
return redirect()->route('admin.products.index')->with('success', 'Produk berhasil ditambahkan.');
}
public function edit(Product $product)
{
$product->load('criterias');
$criterias = Criteria::orderBy('weight_order')->get();
return view('admin.products.edit', compact('product', 'criterias'));
}
public function update(UpdateProductRequest $request, Product $product)
{
$data = $request->validated();
if ($request->hasFile('image')) {
if ($product->image) {
Storage::disk('public')->delete($product->image);
}
$data['image'] = $request->file('image')->store('products', 'public');
}
$criteriaValuesById = $data['criteria_values'] ?? [];
unset($data['criteria_values']);
$product->update($data);
$criterias = Criteria::all();
$sync = [];
foreach ($criterias as $c) {
if ($c->name === 'Harga') {
$val = $product->fresh()->price;
} else {
$val = $criteriaValuesById[$c->id] ?? 0;
}
$sync[$c->id] = ['value' => $val];
}
$product->criterias()->sync($sync);
return redirect()->route('admin.products.index')->with('success', 'Produk berhasil diubah.');
}
public function destroy(Product $product)
{
if ($product->image) {
Storage::disk('public')->delete($product->image);
}
$product->delete();
return redirect()->route('admin.products.index')->with('success', 'Produk berhasil dihapus.');
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Transaction;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
class TransactionController extends Controller
{
public function index(Request $request)
{
Transaction::cancelOverduePendingPickup();
$query = Transaction::with('user', 'details.product');
if ($request->filled('status')) {
$query->where('status', $request->status);
}
if ($request->filled('from')) {
$query->whereDate('created_at', '>=', $request->from);
}
if ($request->filled('to')) {
$query->whereDate('created_at', '<=', $request->to);
}
$transactions = $query->latest()->paginate(15)->withQueryString();
return view('admin.transactions.index', compact('transactions'));
}
public function show(Transaction $transaction)
{
Transaction::cancelOverduePendingPickup();
$transaction->load('user', 'details.product');
return view('admin.transactions.show', compact('transaction'));
}
public function updateStatus(Request $request, Transaction $transaction)
{
$request->validate(['status' => ['required', 'in:pending,paid,cancelled']]);
$transaction->load('details');
$transaction->setStatus($request->status);
return back()->with('success', 'Status transaksi diperbarui.');
}
public function export(Request $request): StreamedResponse
{
Transaction::cancelOverduePendingPickup();
$query = Transaction::with('user', 'details.product');
if ($request->filled('from')) {
$query->whereDate('created_at', '>=', $request->from);
}
if ($request->filled('to')) {
$query->whereDate('created_at', '<=', $request->to);
}
$transactions = $query->latest()->get();
$filename = 'laporan-transaksi-' . now()->format('Y-m-d') . '.csv';
$headers = [
'Content-Type' => 'text/csv; charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"{$filename}\"",
];
return response()->stream(function () use ($transactions) {
$out = fopen('php://output', 'w');
fprintf($out, chr(0xEF) . chr(0xBB) . chr(0xBF));
fputcsv($out, ['Kode', 'Customer', 'Tanggal', 'Total', 'Status']);
foreach ($transactions as $t) {
fputcsv($out, [
$t->code,
$t->user->name ?? '-',
$t->created_at->format('d/m/Y H:i'),
$t->total,
$t->status,
]);
}
fclose($out);
}, 200, $headers);
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Mail\PasswordResetVerificationCodeMail;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
class ForgotPasswordController extends Controller
{
public function create()
{
return view('auth.forgot-password');
}
public function store(Request $request)
{
$request->validate([
'email' => ['required', 'email'],
]);
$user = DB::table('users')->where('email', $request->email)->first();
if (!$user) {
return back()->withErrors([
'email' => 'Email tidak ditemukan.',
])->onlyInput('email');
}
$code = (string) random_int(100000, 999999);
DB::table('password_reset_tokens')->updateOrInsert(
['email' => $request->email],
[
'token' => Hash::make($code),
'created_at' => now(),
]
);
Mail::to($request->email)->send(new PasswordResetVerificationCodeMail($code));
return redirect()->route('password.verify', ['email' => $request->email])->with(
'status',
'Kode verifikasi sudah dikirim ke email Anda.'
);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
public function showLoginForm()
{
return view('auth.login');
}
public function login(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
'password' => ['required'],
]);
if (Auth::attempt($credentials, $request->boolean('remember'))) {
$request->session()->regenerate();
if (Auth::user()->isAdmin()) {
return redirect()->intended(route('admin.dashboard'));
}
return redirect()->intended(route('dashboard'));
}
return back()->withErrors([
'email' => 'Email atau password salah.',
])->onlyInput('email');
}
public function logout(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\RegisterRequest;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class RegisterController extends Controller
{
public function showRegistrationForm()
{
return view('auth.register');
}
public function register(RegisterRequest $request)
{
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'role' => 'user',
]);
Auth::login($user);
return redirect()->route('dashboard')->with('success', 'Registrasi berhasil! Selamat datang.');
}
}

View File

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Illuminate\Validation\Rules\Password as PasswordRule;
class ResetPasswordController extends Controller
{
public function create(Request $request)
{
return view('auth.verify-reset-password', [
'email' => $request->query('email'),
]);
}
public function store(Request $request)
{
$request->validate([
'email' => ['required', 'email'],
'code' => ['required', 'digits:6'],
'password' => ['required', 'confirmed', PasswordRule::min(8)],
]);
$resetData = DB::table('password_reset_tokens')->where('email', $request->email)->first();
$isCodeExpired = !$resetData || now()->diffInMinutes(Carbon::parse($resetData->created_at)) > 15;
if ($isCodeExpired || !Hash::check($request->code, $resetData->token)) {
throw ValidationException::withMessages([
'code' => 'Kode verifikasi tidak valid atau sudah kedaluwarsa.',
]);
}
DB::table('users')
->where('email', $request->email)
->update([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
'updated_at' => now(),
]);
DB::table('password_reset_tokens')->where('email', $request->email)->delete();
return redirect()->route('login')->with('success', 'Password berhasil direset. Silakan login kembali.');
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace App\Http\Controllers;
use App\Models\Cart;
use App\Models\Product;
use Illuminate\Http\Request;
class CartController extends Controller
{
public function index()
{
$items = auth()->user()->carts()->with('product')->get();
$total = $items->sum(fn ($item) => $item->quantity * $item->product->price);
return view('user.cart', compact('items', 'total'));
}
public function store(Request $request)
{
$request->validate([
'product_id' => ['required', 'exists:products,id'],
'quantity' => ['nullable', 'integer', 'min:1'],
]);
$product = Product::findOrFail($request->product_id);
$requestedQty = $request->quantity ?? 1;
$cart = Cart::firstOrNew([
'user_id' => auth()->id(),
'product_id' => $product->id,
]);
$newQuantity = $cart->quantity + $requestedQty;
if ($product->stock < $newQuantity) {
return back()->with('error', 'Stok tidak mencukupi.');
}
$cart->quantity = $newQuantity;
$cart->save();
return back()->with('success', 'Produk ditambahkan ke keranjang.');
}
public function update(Request $request, Cart $cart)
{
$this->authorize('update', $cart);
$request->validate(['quantity' => ['required', 'integer', 'min:1']]);
if ($cart->product->stock < $request->quantity) {
return back()->with('error', 'Stok tidak mencukupi.');
}
$cart->update(['quantity' => $request->quantity]);
return back()->with('success', 'Keranjang diperbarui.');
}
public function destroy(Cart $cart)
{
$this->authorize('delete', $cart);
$cart->delete();
return back()->with('success', 'Item dihapus dari keranjang.');
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\CheckoutRequest;
use App\Models\Transaction;
use App\Models\TransactionDetail;
use Carbon\Carbon;
use Illuminate\Support\Str;
class CheckoutController extends Controller
{
public function show()
{
$items = auth()->user()->carts()->with('product')->get();
if ($items->isEmpty()) {
return redirect()->route('cart.index')->with('error', 'Keranjang kosong.');
}
$total = $items->sum(fn ($item) => $item->quantity * $item->product->price);
$pickupStart = config('store.pickup_start', '19:00');
$pickupEnd = config('store.pickup_end', '21:00');
return view('user.checkout', compact('items', 'total', 'pickupStart', 'pickupEnd'));
}
public function process(CheckoutRequest $request)
{
$user = auth()->user();
$items = $user->carts()->with('product')->get();
if ($items->isEmpty()) {
return redirect()->route('cart.index')->with('error', 'Keranjang kosong.');
}
foreach ($items as $item) {
if ($item->product->stock < $item->quantity) {
return back()->with('error', "Stok {$item->product->name} tidak mencukupi.");
}
}
$total = $items->sum(fn ($item) => $item->quantity * $item->product->price);
$code = 'TRX-' . strtoupper(Str::random(8));
$pickupDateTime = Carbon::parse($request->pickup_date . ' ' . $request->pickup_time);
$pickupStartDateTime = Carbon::parse($request->pickup_date . ' ' . config('store.pickup_start', '19:00'));
$pickupEndDateTime = Carbon::parse($request->pickup_date . ' ' . config('store.pickup_end', '21:00'));
if ($pickupDateTime->lt(now())) {
return back()->withInput()->withErrors([
'pickup_time' => 'Jam pengambilan harus lebih besar dari waktu saat ini.',
]);
}
if ($pickupDateTime->lt($pickupStartDateTime) || $pickupDateTime->gt($pickupEndDateTime)) {
$pickupStart = config('store.pickup_start', '07:00');
$pickupEnd = config('store.pickup_end', '21:00');
return back()->withInput()->withErrors([
'pickup_time' => "Jam pengambilan hanya tersedia antara jam {$pickupStart} sampai {$pickupEnd}.",
]);
}
$transaction = Transaction::create([
'user_id' => $user->id,
'code' => $code,
'address' => config('store.address'),
'phone' => $request->phone,
'pickup_at' => $pickupDateTime,
'status' => 'pending',
'total' => $total,
]);
foreach ($items as $item) {
TransactionDetail::create([
'transaction_id' => $transaction->id,
'product_id' => $item->product_id,
'quantity' => $item->quantity,
'price' => $item->product->price,
'subtotal' => $item->quantity * $item->product->price,
]);
$item->product->decrement('stock', $item->quantity);
}
$user->carts()->delete();
return redirect()->route('transactions.show', $transaction)
->with('success', 'Pesanan berhasil. Kode: ' . $code);
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
abstract class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers;
use App\Models\Product;
use App\Models\Transaction;
class HomeController extends Controller
{
public function index()
{
if (auth()->check()) {
if (auth()->user()->isAdmin()) {
return redirect()->route('admin.dashboard');
}
return redirect()->route('dashboard');
}
$featuredProducts = Product::where('stock', '>', 0)->latest()->take(8)->get();
return view('welcome', compact('featuredProducts'));
}
public function dashboard()
{
$user = auth()->user();
$totalTransactions = Transaction::where('user_id', $user->id)->count();
$recentTransactions = Transaction::where('user_id', $user->id)
->latest()
->take(3)
->get();
return view('user.dashboard', compact('totalTransactions', 'recentTransactions'));
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\RecommendationRequest;
use App\Models\Criteria;
use App\Services\ToyRecommendationService;
use Illuminate\Http\Request;
class RecommendationController extends Controller
{
public function __construct(
protected ToyRecommendationService $sawService
) {}
public function index()
{
$criterias = Criteria::orderBy('weight_order')->get();
return view('user.recommendation', compact('criterias'));
}
public function result(RecommendationRequest $request)
{
$input = [
'age_min' => $request->age_min,
'age_max' => $request->age_max,
'budget_min' => $request->budget_min,
'budget_max' => $request->budget_max,
'priorities' => $request->input('priorities', []),
];
$data = $this->sawService->getRecommendationsWithMatrix($input);
return view('user.recommendation-result', [
'recommendations' => $data['recommendations'],
'input' => $input,
'criterias' => $data['criterias'],
'decision_matrix' => $data['decision_matrix'],
'normalized_matrix' => $data['normalized_matrix'],
'weights' => $data['weights'],
'preference_scores' => $data['preference_scores'],
]);
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use App\Models\Product;
use Illuminate\Http\Request;
class ShopController extends Controller
{
public function index(Request $request)
{
$query = Product::query()->where('stock', '>', 0);
if ($request->filled('search')) {
$query->where(function ($q) use ($request) {
$q->where('name', 'like', '%' . $request->search . '%')
->orWhere('description', 'like', '%' . $request->search . '%');
});
}
if ($request->filled('age_range')) {
$query->where('age_range', 'like', '%' . $request->age_range . '%');
}
if ($request->filled('category')) {
$query->where('category', $request->category);
}
if ($request->filled('min_price')) {
$query->where('price', '>=', $request->min_price);
}
if ($request->filled('max_price')) {
$query->where('price', '<=', $request->max_price);
}
$products = $query->latest()->paginate(12)->withQueryString();
$categories = Product::whereNotNull('category')->distinct()->pluck('category');
return view('user.shop', compact('products', 'categories'));
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Controllers;
use App\Models\Transaction;
class TransactionController extends Controller
{
public function index()
{
Transaction::cancelOverduePendingPickup();
$transactions = auth()->user()
->transactions()
->with('details.product')
->latest()
->paginate(10);
return view('user.transactions', compact('transactions'));
}
public function show(Transaction $transaction)
{
Transaction::cancelOverduePendingPickup();
if ($transaction->user_id !== auth()->id()) {
abort(403);
}
$transaction->load('details.product');
return view('user.transaction-detail', compact('transaction'));
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureUserIsAdmin
{
public function handle(Request $request, Closure $next): Response
{
if (! $request->user() || ! $request->user()->isAdmin()) {
abort(403, 'Akses ditolak.');
}
return $next($request);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CheckoutRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'phone' => ['required', 'string', 'max:20'],
'pickup_date' => ['required', 'date'],
'pickup_time' => ['required', 'date_format:H:i'],
];
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RecommendationRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'age_min' => ['required', 'integer', 'min:0', 'max:18'],
'age_max' => ['required', 'integer', 'min:0', 'max:18', 'gte:age_min'],
'budget_min' => ['required', 'numeric', 'min:0'],
'budget_max' => ['required', 'numeric', 'min:0', 'gte:budget_min'],
'priorities' => ['nullable', 'array'],
'priorities.*' => ['nullable', 'numeric', 'min:1', 'max:5'],
];
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreCriteriaRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->isAdmin() ?? false;
}
public function rules(): array
{
$criteriaId = $this->route('criteria')?->id ?? $this->route('criteria');
return [
'name' => ['required', 'string', 'max:255'],
'type' => ['required', 'in:cost,benefit'],
'weight_order' => [
'nullable',
'integer',
'min:0',
Rule::unique('criterias', 'weight_order')->ignore($criteriaId),
],
];
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests;
use App\Models\Criteria;
use Illuminate\Foundation\Http\FormRequest;
class StoreProductRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->isAdmin() ?? false;
}
public function rules(): array
{
$rules = [
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'price' => ['required', 'numeric', 'min:0'],
'stock' => ['required', 'integer', 'min:0'],
'age_range' => ['nullable', 'string', 'max:50'],
'category' => ['nullable', 'string', 'max:100'],
'image' => ['nullable', 'image', 'max:2048'],
'criteria_values' => ['nullable', 'array'],
];
foreach (Criteria::orderBy('weight_order')->get() as $c) {
if ($c->name === 'Harga') {
continue;
}
$rules['criteria_values.'.$c->id] = ['required', 'numeric', 'min:0', 'max:5'];
}
return $rules;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests;
use App\Models\Criteria;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProductRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->isAdmin() ?? false;
}
public function rules(): array
{
$rules = [
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string'],
'price' => ['required', 'numeric', 'min:0'],
'stock' => ['required', 'integer', 'min:0'],
'age_range' => ['nullable', 'string', 'max:50'],
'category' => ['nullable', 'string', 'max:100'],
'image' => ['nullable', 'image', 'max:2048'],
'criteria_values' => ['nullable', 'array'],
];
foreach (Criteria::orderBy('weight_order')->get() as $c) {
if ($c->name === 'Harga') {
continue;
}
$rules['criteria_values.'.$c->id] = ['required', 'numeric', 'min:0', 'max:5'];
}
return $rules;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class PasswordResetVerificationCodeMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public string $code)
{
}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Kode Verifikasi Reset Password',
);
}
public function content(): Content
{
return new Content(
view: 'emails.password-reset-verification',
with: ['code' => $this->code],
);
}
}

26
app/Models/Cart.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Cart extends Model
{
protected $fillable = ['user_id', 'product_id', 'quantity'];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function getSubtotalAttribute(): float
{
return (float) $this->product->price * $this->quantity;
}
}

21
app/Models/Criteria.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Criteria extends Model
{
use HasFactory;
protected $fillable = ['name', 'type', 'weight_order'];
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class, 'product_criterias')
->withPivot('value')
->withTimestamps();
}
}

32
app/Models/Product.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Product extends Model
{
use HasFactory;
protected $fillable = [
'name', 'description', 'price', 'stock', 'age_range', 'category', 'image',
];
protected $casts = [
'price' => 'decimal:2',
];
public function criterias(): BelongsToMany
{
return $this->belongsToMany(Criteria::class, 'product_criterias')
->withPivot('value')
->withTimestamps();
}
public function cartItems()
{
return $this->hasMany(Cart::class);
}
}

101
app/Models/Transaction.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace App\Models;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Models\Product;
class Transaction extends Model
{
protected $fillable = ['user_id', 'code', 'address', 'phone', 'pickup_at', 'stock_restored_at', 'status', 'total'];
protected $casts = [
'total' => 'decimal:2',
'pickup_at' => 'datetime',
'stock_restored_at' => 'datetime',
];
public static function cancelOverduePendingPickup(): void
{
static::query()
->where('status', 'pending')
->whereNotNull('pickup_at')
->where('pickup_at', '<', now())
->select('id')
->orderBy('id')
->chunkById(100, function ($rows) {
$ids = $rows->pluck('id')->all();
$transactions = static::query()->with('details')->whereIn('id', $ids)->get();
foreach ($transactions as $t) {
$t->setStatus('cancelled');
}
});
}
public function setStatus(string $newStatus): void
{
$oldStatus = (string) $this->status;
if ($oldStatus === $newStatus) {
return;
}
DB::transaction(function () use ($newStatus, $oldStatus) {
$this->refresh();
// Cancelled: restore stock once
if ($newStatus === 'cancelled') {
$this->restoreStockIfNeeded();
$this->forceFill(['status' => 'cancelled'])->save();
return;
}
// If reverting from cancelled -> pending/paid, reserve stock again
if ($oldStatus === 'cancelled' && $newStatus !== 'cancelled') {
$this->reserveStockIfWasRestored();
}
$this->forceFill(['status' => $newStatus])->save();
});
}
protected function restoreStockIfNeeded(): void
{
if ($this->stock_restored_at !== null) {
return;
}
$details = $this->relationLoaded('details') ? $this->details : $this->details()->get();
foreach ($details as $d) {
Product::whereKey($d->product_id)->increment('stock', (int) $d->quantity);
}
$this->forceFill(['stock_restored_at' => now()])->save();
}
protected function reserveStockIfWasRestored(): void
{
if ($this->stock_restored_at === null) {
return;
}
$details = $this->relationLoaded('details') ? $this->details : $this->details()->get();
foreach ($details as $d) {
Product::whereKey($d->product_id)->decrement('stock', (int) $d->quantity);
}
$this->forceFill(['stock_restored_at' => null])->save();
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function details(): HasMany
{
return $this->hasMany(TransactionDetail::class, 'transaction_id');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class TransactionDetail extends Model
{
protected $fillable = ['transaction_id', 'product_id', 'quantity', 'price', 'subtotal'];
protected $casts = [
'price' => 'decimal:2',
'subtotal' => 'decimal:2',
];
public function transaction(): BelongsTo
{
return $this->belongsTo(Transaction::class);
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
}

67
app/Models/User.php Normal file
View File

@ -0,0 +1,67 @@
<?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;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
'role',
'phone',
'address',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
// Password tidak memakai cast 'hashed': nilai di DB selalu hasil Hash::make() (bcrypt)
// agar seeder & kode lain konsisten dan Auth::attempt('password_plain') pasti cocok.
];
}
public function carts()
{
return $this->hasMany(Cart::class);
}
public function transactions()
{
return $this->hasMany(Transaction::class);
}
public function isAdmin(): bool
{
return $this->role === 'admin';
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Policies;
use App\Models\Cart;
use App\Models\User;
class CartPolicy
{
public function update(User $user, Cart $cart): bool
{
return $cart->user_id === $user->id;
}
public function delete(User $user, Cart $cart): bool
{
return $cart->user_id === $user->id;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Paginator::defaultView('pagination::tailwind');
}
}

View File

@ -0,0 +1,306 @@
<?php
namespace App\Services;
use App\Models\Criteria;
use App\Models\Product;
use Illuminate\Support\Collection;
class ToyRecommendationService
{
/**
* Hitung rekomendasi SAW.
*
* @param array $input ['age_min', 'age_max', 'budget_min', 'budget_max', 'priorities' => [criteria_id=>1-5, ...]]
* @return Collection<int, array{rank: int, product: Product, score: float, explanation: string}>
*/
public function getRecommendations(array $input): Collection
{
$ageMin = (int) ($input['age_min'] ?? 0);
$ageMax = (int) ($input['age_max'] ?? 99);
$budgetMin = (float) ($input['budget_min'] ?? 0);
$budgetMax = (float) ($input['budget_max'] ?? 999999999);
$priorities = $input['priorities'] ?? [];
$products = $this->getFilteredProducts($ageMin, $ageMax, $budgetMin, $budgetMax);
if ($products->isEmpty()) {
return collect();
}
$criterias = Criteria::orderBy('weight_order')->get();
if ($criterias->isEmpty()) {
return $products->take(5)->map(fn ($p, $i) => [
'rank' => $i + 1,
'product' => $p,
'score' => 0.0,
'explanation' => 'Produk ini tersedia dalam rentang usia dan budget Anda.',
]);
}
$weights = $this->buildWeightsFromPriorities($priorities, $criterias);
$matrix = $this->buildMatrix($products, $criterias);
$normalized = $this->normalizeMatrix($matrix, $criterias);
$scores = $this->calculatePreferenceScores($normalized, $weights, $criterias);
$ranked = $scores->sortByDesc('score')->take(5)->values();
$criteriaNames = $criterias->keyBy('id')->map->name;
return $ranked->map(function ($item, $index) use ($products, $criteriaNames, $priorities) {
$product = $products->firstWhere('id', $item['product_id']);
if (! $product) {
return null;
}
$explanation = $this->buildExplanation($product, $item['score'], $priorities, $criteriaNames);
return [
'rank' => $index + 1,
'product' => $product,
'score' => round($item['score'], 4),
'explanation' => $explanation,
];
})->filter()->values();
}
/**
* Hitung rekomendasi SAW beserta data matriks untuk tampilan (skripsi).
*
* @return array{recommendations: Collection, criterias: array, decision_matrix: array, normalized_matrix: array, weights: array, preference_scores: array}
*/
public function getRecommendationsWithMatrix(array $input): array
{
$ageMin = (int) ($input['age_min'] ?? 0);
$ageMax = (int) ($input['age_max'] ?? 99);
$budgetMin = (float) ($input['budget_min'] ?? 0);
$budgetMax = (float) ($input['budget_max'] ?? 999999999);
$priorities = $input['priorities'] ?? [];
$products = $this->getFilteredProducts($ageMin, $ageMax, $budgetMin, $budgetMax);
if ($products->isEmpty()) {
return [
'recommendations' => collect(),
'criterias' => [],
'decision_matrix' => [],
'normalized_matrix' => [],
'weights' => [],
'preference_scores' => [],
];
}
$criterias = Criteria::orderBy('weight_order')->get();
if ($criterias->isEmpty()) {
$recommendations = $products->take(5)->map(fn ($p, $i) => [
'rank' => $i + 1,
'product' => $p,
'score' => 0.0,
'explanation' => 'Produk ini tersedia dalam rentang usia dan budget Anda.',
]);
return [
'recommendations' => $recommendations,
'criterias' => [],
'decision_matrix' => [],
'normalized_matrix' => [],
'weights' => [],
'preference_scores' => [],
];
}
$weights = $this->buildWeightsFromPriorities($priorities, $criterias);
$matrix = $this->buildMatrix($products, $criterias);
$normalized = $this->normalizeMatrix($matrix, $criterias);
$scores = $this->calculatePreferenceScores($normalized, $weights, $criterias);
$ranked = $scores->sortByDesc('score')->take(5)->values();
$topProductIds = $ranked->pluck('product_id')->all();
$rankedScoresByProductId = $ranked
->mapWithKeys(fn ($item) => [$item['product_id'] => round($item['score'], 4)])
->all();
$criteriasWithWeight = [];
foreach ($criterias as $c) {
$criteriasWithWeight[] = [
'name' => $c->name,
'type' => $c->type,
'weight' => $weights[$c->name] ?? 0,
];
}
$decisionMatrix = [];
foreach ($topProductIds as $productId) {
$row = $matrix[$productId] ?? null;
if (! $row) {
continue;
}
$product = $products->firstWhere('id', $productId);
$r = ['product_id' => $productId, 'product_name' => $product ? $product->name : '-'];
foreach ($criterias as $c) {
$r[$c->name] = $row[$c->name] ?? 0;
}
$decisionMatrix[] = $r;
}
$normalizedMatrix = [];
foreach ($topProductIds as $productId) {
$row = $normalized[$productId] ?? null;
if (! $row) {
continue;
}
$product = $products->firstWhere('id', $productId);
$r = ['product_id' => $productId, 'product_name' => $product ? $product->name : '-'];
foreach ($criterias as $c) {
$val = $row[$c->name] ?? 0;
$r[$c->name] = round((float) $val, 4);
}
$normalizedMatrix[] = $r;
}
$preferenceScores = $rankedScoresByProductId;
$criteriaNames = $criterias->keyBy('id')->map->name;
$recommendations = $ranked->map(function ($item, $index) use ($products, $criteriaNames, $priorities) {
$product = $products->firstWhere('id', $item['product_id']);
if (! $product) {
return null;
}
$explanation = $this->buildExplanation($product, $item['score'], $priorities, $criteriaNames);
return [
'rank' => $index + 1,
'product' => $product,
'score' => round($item['score'], 4),
'explanation' => $explanation,
];
})->filter()->values();
return [
'recommendations' => $recommendations,
'criterias' => $criteriasWithWeight,
'decision_matrix' => $decisionMatrix,
'normalized_matrix' => $normalizedMatrix,
'weights' => $weights,
'preference_scores' => $preferenceScores,
];
}
protected function getFilteredProducts(int $ageMin, int $ageMax, float $budgetMin, float $budgetMax): Collection
{
return Product::with('criterias')
->where('stock', '>', 0)
->whereBetween('price', [$budgetMin, $budgetMax])
->get()
->filter(function ($product) use ($ageMin, $ageMax) {
if (empty($product->age_range)) {
return true;
}
return $this->ageRangeOverlaps($product->age_range, $ageMin, $ageMax);
})
->values();
}
protected function ageRangeOverlaps(string $ageRange, int $childMin, int $childMax): bool
{
if (preg_match('/^(\d+)\s*-\s*(\d+)$/', trim($ageRange), $m)) {
$pMin = (int) $m[1];
$pMax = (int) $m[2];
return $childMax >= $pMin && $childMin <= $pMax;
}
return true;
}
protected function buildWeightsFromPriorities(array $priorities, Collection $criterias): array
{
// priorities: [criteria_id => 1..5]
// return weights by criteria name: ['Harga' => 0.2, 'Kualitas' => 0.2, ...]
$raw = [];
$sum = 0.0;
foreach ($criterias as $c) {
$w = (float) ($priorities[(string) $c->id] ?? $priorities[$c->id] ?? 1);
if ($w < 1) $w = 1;
if ($w > 5) $w = 5;
$raw[$c->name] = $w;
$sum += $w;
}
$count = max(1, $criterias->count());
$weights = [];
foreach ($raw as $name => $v) {
$weights[$name] = $sum > 0 ? $v / $sum : 1 / $count;
}
return $weights;
}
protected function buildMatrix(Collection $products, Collection $criterias): array
{
$matrix = [];
foreach ($products as $product) {
$row = ['product_id' => $product->id];
foreach ($product->criterias as $pc) {
$criteria = $criterias->firstWhere('id', $pc->id);
if ($criteria) {
$row[$criteria->name] = (float) $pc->pivot->value;
}
}
foreach ($criterias as $c) {
if (! isset($row[$c->name])) {
$row[$c->name] = $c->name === 'Harga' ? (float) $product->price : 0;
}
}
$matrix[$product->id] = $row;
}
return $matrix;
}
protected function normalizeMatrix(array $matrix, Collection $criterias): array
{
if (empty($matrix)) {
return [];
}
$normalized = [];
foreach (array_keys($matrix) as $pid) {
$normalized[$pid] = ['product_id' => $pid];
}
foreach ($criterias as $criteria) {
$key = $criteria->name;
$values = array_column($matrix, $key);
$max = max($values);
$min = min($values);
$isCost = $criteria->type === 'cost';
if ($isCost) {
foreach ($matrix as $pid => $row) {
$val = (float) ($row[$key] ?? 0);
$normalized[$pid][$key] = $min > 0 && $val > 0 ? $min / $val : 0;
}
} else {
foreach ($matrix as $pid => $row) {
$val = (float) ($row[$key] ?? 0);
$normalized[$pid][$key] = $max > 0 ? $val / $max : 0;
}
}
}
return $normalized;
}
protected function calculatePreferenceScores(array $normalized, array $weights, Collection $criterias): Collection
{
$result = collect();
foreach ($normalized as $productId => $row) {
$vi = 0;
foreach ($criterias as $c) {
$w = (float) ($weights[$c->name] ?? (1 / max(1, $criterias->count())));
$r = (float) ($row[$c->name] ?? 0);
$vi += $w * $r;
}
$result->push(['product_id' => $productId, 'score' => $vi]);
}
return $result;
}
protected function buildExplanation($product, float $score, array $priorities, $criteriaNames): string
{
return 'Produk ini direkomendasikan karena memiliki nilai tinggi pada kriteria yang Anda prioritaskan.';
}
}

18
artisan Executable file
View File

@ -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);

20
bootstrap/app.php Normal file
View File

@ -0,0 +1,20 @@
<?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): void {
$middleware->alias([
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class,
]);
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();

2
bootstrap/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

5
bootstrap/providers.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
App\Providers\AppServiceProvider::class,
];

86
composer.json Normal file
View File

@ -0,0 +1,86 @@
{
"$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/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"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": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"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"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"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
}

8408
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

126
config/app.php Normal file
View File

@ -0,0 +1,126 @@
<?php
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' => 'Asia/Jakarta',
/*
|--------------------------------------------------------------------------
| 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(',', (string) 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'),
],
];

115
config/auth.php Normal file
View File

@ -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 number 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),
];

117
config/cache.php Normal file
View File

@ -0,0 +1,117 @@
<?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', 'database'),
/*
|--------------------------------------------------------------------------
| 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",
| "failover", "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',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| 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((string) env('APP_NAME', 'laravel')).'-cache-'),
];

183
config/database.php Normal file
View File

@ -0,0 +1,183 @@
<?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,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'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([
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \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([
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \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' => env('DB_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((string) 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'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'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'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];

80
config/filesystems.php Normal file
View File

@ -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' => rtrim(env('APP_URL', 'http://localhost'), '/').'/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'),
],
];

132
config/logging.php Normal file
View File

@ -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(',', (string) 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'),
],
],
];

118
config/mail.php Normal file
View File

@ -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((string) 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'),
],
];

129
config/queue.php Normal file
View File

@ -0,0 +1,129 @@
<?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",
| "deferred", "background", "failover", "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,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| 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',
],
];

38
config/services.php Normal file
View File

@ -0,0 +1,38 @@
<?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' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];

217
config/session.php Normal file
View File

@ -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", "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: "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((string) 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 without 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),
];

9
config/store.php Normal file
View File

@ -0,0 +1,9 @@
<?php
return [
'name' => 'Toko Mainan SAW',
'address' => '',
'phone' => '0812-3456-7890',
'pickup_start' => '07:00',
'pickup_end' => '21:00',
];

1
database/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.sqlite*

View File

@ -0,0 +1,45 @@
<?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),
'role' => 'user',
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@ -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');
}
};

View File

@ -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')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@ -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');
}
};

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->enum('role', ['admin', 'user'])->default('user')->after('email');
$table->string('phone')->nullable()->after('name');
$table->text('address')->nullable()->after('phone');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['role', 'phone', 'address']);
});
}
};

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('criterias', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->enum('type', ['cost', 'benefit']);
$table->integer('weight_order')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('criterias');
}
};

View File

@ -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
{
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->decimal('price', 12, 2);
$table->integer('stock')->default(0);
$table->string('age_range')->nullable(); // e.g. "3-6", "0-3"
$table->string('category')->nullable();
$table->string('image')->nullable();
$table->timestamps();
$table->index(['age_range', 'category']);
$table->index('price');
});
}
public function down(): void
{
Schema::dropIfExists('products');
}
};

View File

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('product_criterias', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->foreignId('criteria_id')->constrained()->cascadeOnDelete();
$table->decimal('value', 8, 2);
$table->timestamps();
$table->unique(['product_id', 'criteria_id']);
});
}
public function down(): void
{
Schema::dropIfExists('product_criterias');
}
};

View File

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('carts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->integer('quantity')->default(1);
$table->timestamps();
$table->unique(['user_id', 'product_id']);
});
}
public function down(): void
{
Schema::dropIfExists('carts');
}
};

View File

@ -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
{
public function up(): void
{
Schema::create('transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('code')->unique();
$table->text('address');
$table->string('phone');
$table->enum('status', ['pending', 'paid', 'processing', 'shipped', 'completed', 'cancelled'])->default('pending');
$table->decimal('total', 12, 2);
$table->timestamps();
$table->index(['user_id', 'created_at']);
$table->index('status');
});
}
public function down(): void
{
Schema::dropIfExists('transactions');
}
};

View File

@ -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
{
public function up(): void
{
Schema::create('transaction_details', function (Blueprint $table) {
$table->id();
$table->foreignId('transaction_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->integer('quantity');
$table->decimal('price', 12, 2);
$table->decimal('subtotal', 12, 2);
$table->timestamps();
$table->index('transaction_id');
});
}
public function down(): void
{
Schema::dropIfExists('transaction_details');
}
};

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('transactions', function (Blueprint $table) {
$table->timestamp('pickup_at')->nullable()->after('phone');
});
}
public function down(): void
{
Schema::table('transactions', function (Blueprint $table) {
$table->dropColumn('pickup_at');
});
}
};

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('transactions', function (Blueprint $table) {
$table->timestamp('stock_restored_at')->nullable()->after('pickup_at');
});
}
public function down(): void
{
Schema::table('transactions', function (Blueprint $table) {
$table->dropColumn('stock_restored_at');
});
}
};

View File

@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use App\Models\Criteria;
use Illuminate\Database\Seeder;
class CriteriaSeeder extends Seeder
{
public function run(): void
{
$data = [
['name' => 'Harga', 'type' => 'cost', 'weight_order' => 1],
['name' => 'Kualitas', 'type' => 'benefit', 'weight_order' => 2],
['name' => 'Keamanan', 'type' => 'benefit', 'weight_order' => 3],
['name' => 'Edukasi', 'type' => 'benefit', 'weight_order' => 4],
['name' => 'Popularitas', 'type' => 'benefit', 'weight_order' => 5],
];
foreach ($data as $row) {
Criteria::updateOrCreate(
['name' => $row['name']],
$row
);
}
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call([
CriteriaSeeder::class,
UserSeeder::class,
ProductSeeder::class,
ProductCriteriaSeeder::class,
]);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Database\Seeders;
use App\Models\Criteria;
use App\Models\Product;
use Illuminate\Database\Seeder;
class ProductCriteriaSeeder extends Seeder
{
public function run(): void
{
$criterias = Criteria::all()->keyBy('name');
$products = Product::with('criterias')->get();
$values = [
'Lego Classic Brick Box' => ['Harga' => 250000, 'Kualitas' => 5, 'Keamanan' => 5, 'Edukasi' => 5, 'Popularitas' => 5],
'Puzzle Kayu Hewan' => ['Harga' => 85000, 'Kualitas' => 4, 'Keamanan' => 5, 'Edukasi' => 5, 'Popularitas' => 4],
'Mainan Edukasi Bentuk' => ['Harga' => 65000, 'Kualitas' => 4, 'Keamanan' => 5, 'Edukasi' => 5, 'Popularitas' => 4],
'Action Figure Superhero' => ['Harga' => 120000, 'Kualitas' => 4, 'Keamanan' => 4, 'Edukasi' => 3, 'Popularitas' => 5],
'Board Game Keluarga' => ['Harga' => 180000, 'Kualitas' => 5, 'Keamanan' => 5, 'Edukasi' => 5, 'Popularitas' => 4],
'Stuffed Toy Beruang' => ['Harga' => 95000, 'Kualitas' => 4, 'Keamanan' => 5, 'Edukasi' => 2, 'Popularitas' => 5],
'Set Alat Musik Mainan' => ['Harga' => 150000, 'Kualitas' => 4, 'Keamanan' => 4, 'Edukasi' => 4, 'Popularitas' => 4],
'Mobil Remote Control' => ['Harga' => 220000, 'Kualitas' => 4, 'Keamanan' => 4, 'Edukasi' => 2, 'Popularitas' => 5],
'Blok Bayi Soft' => ['Harga' => 75000, 'Kualitas' => 4, 'Keamanan' => 5, 'Edukasi' => 3, 'Popularitas' => 4],
'Science Kit Anak' => ['Harga' => 195000, 'Kualitas' => 5, 'Keamanan' => 4, 'Edukasi' => 5, 'Popularitas' => 4],
];
foreach ($products as $product) {
$row = $values[$product->name] ?? null;
if (! $row) {
continue;
}
$sync = [];
foreach ($row as $criteriaName => $value) {
$criteria = $criterias->get($criteriaName);
if ($criteria) {
$sync[$criteria->id] = ['value' => $value];
}
}
$product->criterias()->sync($sync);
}
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Database\Seeders;
use App\Models\Product;
use Illuminate\Database\Seeder;
class ProductSeeder extends Seeder
{
public function run(): void
{
$products = [
['name' => 'Lego Classic Brick Box', 'description' => 'Mainan bongkar pasang kreatif untuk anak.', 'price' => 250000, 'stock' => 30, 'age_range' => '4-99', 'category' => 'Building'],
['name' => 'Puzzle Kayu Hewan', 'description' => 'Puzzle edukatif mengenal hewan.', 'price' => 85000, 'stock' => 25, 'age_range' => '2-6', 'category' => 'Puzzle'],
['name' => 'Mainan Edukasi Bentuk', 'description' => 'Mengenal bentuk dan warna.', 'price' => 65000, 'stock' => 40, 'age_range' => '1-4', 'category' => 'Edukasi'],
['name' => 'Action Figure Superhero', 'description' => 'Figure action untuk koleksi dan bermain peran.', 'price' => 120000, 'stock' => 20, 'age_range' => '5-12', 'category' => 'Action'],
['name' => 'Board Game Keluarga', 'description' => 'Permainan papan untuk seluruh keluarga.', 'price' => 180000, 'stock' => 15, 'age_range' => '6-99', 'category' => 'Board Game'],
['name' => 'Stuffed Toy Beruang', 'description' => 'Boneka lembut aman untuk bayi.', 'price' => 95000, 'stock' => 50, 'age_range' => '0-5', 'category' => 'Boneka'],
['name' => 'Set Alat Musik Mainan', 'description' => 'Piano dan drum mainan untuk pengenalan musik.', 'price' => 150000, 'stock' => 18, 'age_range' => '3-8', 'category' => 'Musik'],
['name' => 'Mobil Remote Control', 'description' => 'Mobil RC tahan banting untuk outdoor.', 'price' => 220000, 'stock' => 12, 'age_range' => '6-14', 'category' => 'RC'],
['name' => 'Blok Bayi Soft', 'description' => 'Blok empuk aman untuk bayi 0+.', 'price' => 75000, 'stock' => 35, 'age_range' => '0-3', 'category' => 'Bayi'],
['name' => 'Science Kit Anak', 'description' => 'Eksperimen sains sederhana untuk anak.', 'price' => 195000, 'stock' => 10, 'age_range' => '8-14', 'category' => 'Edukasi'],
];
foreach ($products as $p) {
Product::updateOrCreate(
['name' => $p['name']],
array_merge($p, ['image' => null])
);
}
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class UserSeeder extends Seeder
{
public function run(): void
{
// Password plain di login: "password". Di database hanya hash bcrypt (Hash::make).
$hashed = Hash::make('password');
User::updateOrCreate(
['email' => 'admin@toy.com'],
[
'name' => 'Administrator',
'password' => $hashed,
'role' => 'admin',
]
);
User::updateOrCreate(
['email' => 'user@toy.com'],
[
'name' => 'Budi Santoso',
'password' => $hashed,
'role' => 'user',
'phone' => '08123456789',
'address' => 'Jl. Contoh No. 1, Jakarta',
]
);
}
}

2594
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"$schema": "https://www.schemastore.org/package.json",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"autoprefixer": "^10.4.27",
"axios": "^1.11.0",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"postcss": "^8.5.6",
"tailwindcss": "^4.2.1",
"vite": "^7.0.7"
}
}

35
phpunit.xml Normal file
View File

@ -0,0 +1,35 @@
<?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="BROADCAST_CONNECTION" value="null"/>
<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="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="PULSE_ENABLED" value="false"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="NIGHTWATCH_ENABLED" value="false"/>
</php>
</phpunit>

25
public/.htaccess Normal file
View File

@ -0,0 +1,25 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

0
public/favicon.ico Normal file
View File

20
public/index.php Normal file
View File

@ -0,0 +1,20 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';
$app->handleRequest(Request::capture());

2
public/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow:

93
resources/css/app.css Normal file
View File

@ -0,0 +1,93 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
/* ========== DESIGN SYSTEM ========== */
@theme {
/* Typography - Inter */
--font-sans: 'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
/* Primary - Indigo / Sky soft */
--color-primary-50: #eef2ff;
--color-primary-100: #e0e7ff;
--color-primary-200: #c7d2fe;
--color-primary-300: #a5b4fc;
--color-primary-400: #818cf8;
--color-primary-500: #6366f1;
--color-primary-600: #4f46e5;
--color-primary-700: #4338ca;
--color-primary-800: #3730a3;
--color-primary-900: #312e81;
/* Secondary - Emerald / Teal */
--color-secondary-50: #ecfdf5;
--color-secondary-100: #d1fae5;
--color-secondary-200: #a7f3d0;
--color-secondary-300: #6ee7b7;
--color-secondary-400: #34d399;
--color-secondary-500: #10b981;
--color-secondary-600: #059669;
--color-secondary-700: #047857;
--color-secondary-800: #065f46;
--color-secondary-900: #064e3b;
}
/* Base */
body {
@apply text-gray-600 antialiased;
line-height: 1.6;
}
/* Sidebar overlay */
.sidebar-overlay {
@apply fixed inset-0 z-40 bg-gray-900/50 backdrop-blur-sm opacity-0 pointer-events-none transition-opacity duration-300;
}
.sidebar-overlay.active {
@apply opacity-100 pointer-events-auto;
}
/* Nav drawer (mobile) */
.nav-drawer {
@apply fixed top-0 right-0 z-50 h-full w-full max-w-sm bg-white shadow-xl transform translate-x-full transition-transform duration-300 ease-out;
}
.nav-drawer.open {
@apply translate-x-0;
}
/* Fade-in animation for result cards */
@keyframes fade-in-up {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-fade-in-up {
animation: fade-in-up 0.4s ease-out forwards;
}
/* Stagger children */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
/* Sidebar collapsed (desktop) */
.sidebar.sidebar-collapsed {
width: 5rem;
}
.sidebar.sidebar-collapsed .sidebar-label {
display: none;
}
.sidebar.sidebar-collapsed .sidebar-user {
justify-content: center;
padding-left: 0.75rem;
padding-right: 0.75rem;
}

127
resources/js/app.js Normal file
View File

@ -0,0 +1,127 @@
import './bootstrap';
document.addEventListener('DOMContentLoaded', function () {
// ----- Sidebar (app layout): toggle mobile, collapse desktop -----
var sidebar = document.getElementById('sidebar');
var sidebarOverlay = document.getElementById('sidebar-overlay');
var sidebarToggleBtns = document.querySelectorAll('[data-action="sidebar-toggle"]');
var sidebarCollapseBtn = document.querySelector('[data-action="sidebar-collapse"]');
function sidebarOpen() {
if (!sidebar || !sidebarOverlay) return;
sidebar.classList.remove('-translate-x-full');
sidebarOverlay.classList.add('active', 'opacity-100', 'pointer-events-auto');
}
function sidebarClose() {
if (!sidebar || !sidebarOverlay) return;
sidebar.classList.add('-translate-x-full');
sidebarOverlay.classList.remove('active', 'opacity-100', 'pointer-events-auto');
}
function sidebarToggle() {
if (!sidebar) return;
if (sidebar.classList.contains('-translate-x-full')) {
sidebarOpen();
} else {
sidebarClose();
}
}
sidebarToggleBtns.forEach(function (btn) {
btn.addEventListener('click', sidebarToggle);
});
if (sidebarOverlay) {
sidebarOverlay.addEventListener('click', sidebarClose);
}
if (sidebarCollapseBtn) {
sidebarCollapseBtn.addEventListener('click', function () {
if (!sidebar) return;
var collapsed = sidebar.getAttribute('data-collapsed') === 'true';
sidebar.setAttribute('data-collapsed', !collapsed);
sidebar.classList.toggle('sidebar-collapsed', !collapsed);
try {
localStorage.setItem('sidebarCollapsed', !collapsed);
} catch (e) {}
});
}
if (sidebar && window.matchMedia('(min-width: 768px)').matches) {
try {
if (localStorage.getItem('sidebarCollapsed') === 'true') {
sidebar.setAttribute('data-collapsed', 'true');
sidebar.classList.add('sidebar-collapsed');
}
} catch (e) {}
}
// ----- Nav drawer (guest layout) -----
var navToggle = document.getElementById('nav-toggle');
var navClose = document.getElementById('nav-close');
var navOverlay = document.getElementById('nav-overlay');
var navDrawer = document.getElementById('nav-drawer');
function navDrawerOpen() {
if (!navDrawer || !navOverlay) return;
navDrawer.classList.add('open');
navDrawer.setAttribute('aria-hidden', 'false');
navOverlay.classList.add('opacity-100', 'pointer-events-auto');
}
function navDrawerClose() {
if (!navDrawer || !navOverlay) return;
navDrawer.classList.remove('open');
navDrawer.setAttribute('aria-hidden', 'true');
navOverlay.classList.remove('opacity-100', 'pointer-events-auto');
}
if (navToggle) navToggle.addEventListener('click', navDrawerOpen);
if (navClose) navClose.addEventListener('click', navDrawerClose);
if (navOverlay) navOverlay.addEventListener('click', navDrawerClose);
document.querySelectorAll('.nav-drawer-link').forEach(function (link) {
link.addEventListener('click', navDrawerClose);
});
// ----- Shop filter toggle (mobile) -----
var filterToggle = document.getElementById('filter-toggle');
var filterPanel = document.getElementById('filter-panel');
var filterIcon = document.getElementById('filter-icon');
if (filterToggle && filterPanel) {
filterToggle.addEventListener('click', function () {
filterPanel.classList.toggle('hidden');
if (filterIcon) filterIcon.classList.toggle('rotate-180');
});
}
// ----- Recommendation sliders: update value display -----
document.querySelectorAll('input[type="range"][name^="priorities"]').forEach(function (el) {
var name = el.getAttribute('name');
var key = name && name.match(/\[(\w+)\]$/) ? name.match(/\[(\w+)\]/)[1] : null;
if (!key) return;
var valEl = document.getElementById('val-' + key);
function update() {
if (valEl) valEl.textContent = el.value;
}
el.addEventListener('input', update);
update();
});
// ----- Forms with data-confirm: confirm before submit -----
document.querySelectorAll('form[data-confirm]').forEach(function (form) {
form.addEventListener('submit', function (e) {
var msg = form.getAttribute('data-confirm') || 'Lanjutkan?';
if (!window.confirm(msg)) {
e.preventDefault();
}
});
});
// ----- Print buttons (invoice) -----
document.querySelectorAll('[data-action="print"]').forEach(function (btn) {
btn.addEventListener('click', function (e) {
e.preventDefault();
window.print();
});
});
});

4
resources/js/bootstrap.js vendored Normal file
View File

@ -0,0 +1,4 @@
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

View File

@ -0,0 +1,26 @@
@extends('layouts.app')
@section('title', 'Tambah Kriteria')
@section('content')
<div class="max-w-md space-y-6">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Tambah Kriteria</h2>
<form method="POST" action="{{ route('admin.criterias.store') }}" class="space-y-6">
@csrf
<x-card>
<div class="space-y-4">
<x-input label="Nama *" name="name" value="{{ old('name') }}" required />
<x-select label="Tipe *" name="type" required>
<option value="benefit">Benefit</option>
<option value="cost">Cost</option>
</x-select>
<x-input label="Urutan bobot" name="weight_order" type="number" value="{{ old('weight_order', 0) }}" min="0" />
</div>
</x-card>
<div class="flex items-center gap-3">
<x-button type="submit" variant="primary" size="md">Simpan</x-button>
<a href="{{ route('admin.criterias.index') }}" class="text-gray-600 hover:text-gray-900 font-medium">Batal</a>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,27 @@
@extends('layouts.app')
@section('title', 'Edit Kriteria')
@section('content')
<div class="max-w-md space-y-6">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Edit Kriteria</h2>
<form method="POST" action="{{ route('admin.criterias.update', $criteria) }}" class="space-y-6">
@csrf
@method('PUT')
<x-card>
<div class="space-y-4">
<x-input label="Nama *" name="name" value="{{ old('name', $criteria->name) }}" required />
<x-select label="Tipe *" name="type" required>
<option value="benefit" {{ old('type', $criteria->type) === 'benefit' ? 'selected' : '' }}>Benefit</option>
<option value="cost" {{ old('type', $criteria->type) === 'cost' ? 'selected' : '' }}>Cost</option>
</x-select>
<x-input label="Urutan bobot" name="weight_order" type="number" value="{{ old('weight_order', $criteria->weight_order) }}" min="0" />
</div>
</x-card>
<div class="flex items-center gap-3">
<x-button type="submit" variant="primary" size="md">Simpan</x-button>
<a href="{{ route('admin.criterias.index') }}" class="text-gray-600 hover:text-gray-900 font-medium">Batal</a>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,50 @@
@extends('layouts.app')
@section('title', 'Manajemen Kriteria')
@section('content')
<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Manajemen Kriteria</h2>
<x-button href="{{ route('admin.criterias.create') }}" variant="primary" size="md">
<i class="fa-solid fa-plus"></i> Tambah Kriteria
</x-button>
</div>
<x-card :padding="false">
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Nama</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Tipe</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Urutan</th>
<th class="text-right px-6 py-4 font-semibold text-gray-700">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@forelse($criterias as $c)
<tr class="hover:bg-gray-50/50 transition">
<td class="px-6 py-4 font-medium text-gray-900">{{ $c->name }}</td>
<td class="px-6 py-4">
<x-badge :variant="$c->type === 'cost' ? 'warning' : 'success'">{{ $c->type }}</x-badge>
</td>
<td class="px-6 py-4 text-gray-600">{{ $c->weight_order }}</td>
<td class="px-6 py-4 text-right">
<a href="{{ route('admin.criterias.edit', $c) }}" class="inline-flex items-center px-3 py-1.5 rounded-lg text-primary-600 hover:bg-primary-50 font-medium transition">Edit</a>
<form action="{{ route('admin.criterias.destroy', $c) }}" method="POST" class="inline ml-1" data-confirm="Hapus kriteria?">
@csrf
@method('DELETE')
<button type="submit" class="inline-flex items-center px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 font-medium transition">Hapus</button>
</form>
</td>
</tr>
@empty
<tr><td colspan="4" class="px-6 py-12 text-center text-gray-500">Belum ada kriteria.</td></tr>
@endforelse
</tbody>
</table>
</div>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,217 @@
@extends('layouts.app')
@section('title', 'Dashboard Admin')
@section('content')
<div class="space-y-8">
<div>
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Dashboard</h2>
<p class="mt-1 text-gray-500">Ringkasan toko dan penjualan.</p>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
<x-metric-card title="Total Produk" :value="$totalProducts" href="{{ route('admin.products.index') }}" icon='<i class="fa-solid fa-cube"></i>'>
<p class="mt-1 text-sm font-medium text-primary-600">Kelola </p>
</x-metric-card>
<x-metric-card title="Total Transaksi" :value="$totalTransactions" href="{{ route('admin.transactions.index') }}" icon='<i class="fa-solid fa-receipt"></i>'>
<p class="mt-1 text-sm font-medium text-primary-600">Lihat </p>
</x-metric-card>
</div>
<x-card>
<form method="GET" class="flex flex-wrap items-end gap-3">
<div>
<label for="month" class="block text-sm font-medium text-gray-700 mb-1">Bulan</label>
<select id="month" name="month" class="rounded-xl border border-gray-200 px-3 py-2 text-sm focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
<option value="">Semua bulan</option>
@foreach(range(1, 12) as $m)
<option value="{{ $m }}" {{ (int) $selectedMonth === $m ? 'selected' : '' }}>
{{ \Carbon\Carbon::create()->month($m)->translatedFormat('F') }}
</option>
@endforeach
</select>
</div>
<div>
<label for="year" class="block text-sm font-medium text-gray-700 mb-1">Tahun</label>
<select id="year" name="year" class="rounded-xl border border-gray-200 px-3 py-2 text-sm focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
@foreach($availableYears as $year)
<option value="{{ $year }}" {{ (int) $selectedYear === (int) $year ? 'selected' : '' }}>{{ $year }}</option>
@endforeach
</select>
</div>
<x-button type="submit" variant="outline" size="sm">Terapkan Filter</x-button>
<x-button href="{{ route('admin.dashboard') }}" variant="ghost" size="sm">Reset</x-button>
</form>
</x-card>
<x-card>
<h3 class="font-semibold text-gray-900 mb-4">Penjualan Paid {{ $selectedMonth ? \Carbon\Carbon::create()->month($selectedMonth)->translatedFormat('F') : 'Semua Bulan' }} {{ $selectedYear }}</h3>
@if($salesChart->isEmpty())
<div class="py-12 text-center text-gray-500">Belum ada data penjualan.</div>
@else
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="text-left px-6 py-3 font-semibold text-gray-700">Tanggal</th>
<th class="text-right px-6 py-3 font-semibold text-gray-700">Total</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@foreach($salesChart as $row)
<tr class="hover:bg-gray-50/50 transition">
<td class="px-6 py-3 text-gray-700">{{ $row->date }}</td>
<td class="px-6 py-3 text-right font-medium text-gray-900">Rp {{ number_format($row->total, 0, ',', '.') }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</x-card>
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
<x-card>
<h3 class="font-semibold text-gray-900 mb-1">Grafik Pendapatan Per Bulan</h3>
<p class="text-sm text-gray-500 mb-6">Line chart pendapatan transaksi dengan status <span class="font-semibold text-green-600">Paid</span> pada tahun {{ $selectedYear }}.</p>
<div class="rounded-2xl border border-gray-100 bg-white p-4">
<canvas id="monthlyRevenueLineChart" height="220"></canvas>
</div>
</x-card>
<x-card>
<h3 class="font-semibold text-gray-900 mb-1">Pie Chart Status Transaksi</h3>
<p class="text-sm text-gray-500 mb-6">Distribusi status transaksi. Fokus utama pada status <span class="font-semibold text-green-600">Paid</span>.</p>
@php
$pendingCount = (int) ($statusBreakdown['pending'] ?? 0);
$paidCount = (int) ($statusBreakdown['paid'] ?? 0);
$cancelledCount = (int) ($statusBreakdown['cancelled'] ?? 0);
@endphp
<div class="rounded-2xl border border-gray-100 bg-white p-4">
<canvas id="transactionStatusPieChart" height="220"></canvas>
</div>
<div class="mt-4 space-y-3 w-full">
<div class="flex items-center justify-between text-sm">
<span class="flex items-center gap-2 text-gray-700"><span class="w-3 h-3 rounded-full bg-amber-400"></span>Pending</span>
<span class="font-semibold text-gray-900">{{ $pendingCount }}</span>
</div>
<div class="flex items-center justify-between text-sm">
<span class="flex items-center gap-2 text-gray-700"><span class="w-3 h-3 rounded-full bg-emerald-400"></span>Paid</span>
<span class="font-semibold text-gray-900">{{ $paidCount }}</span>
</div>
<div class="flex items-center justify-between text-sm">
<span class="flex items-center gap-2 text-gray-700"><span class="w-3 h-3 rounded-full bg-rose-400"></span>Cancelled</span>
<span class="font-semibold text-gray-900">{{ $cancelledCount }}</span>
</div>
<div class="pt-2 border-t border-gray-100 flex items-center justify-between text-sm">
<span class="text-gray-500">Total transaksi</span>
<span class="font-bold text-gray-900">{{ $pendingCount + $paidCount + $cancelledCount }}</span>
</div>
</div>
</x-card>
</div>
</div>
@php
$lineLabels = $monthlyRevenue->pluck('month')->values();
$lineValues = $monthlyRevenue->pluck('total')->map(fn ($v) => (float) $v)->values();
@endphp
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const lineCanvas = document.getElementById('monthlyRevenueLineChart');
const pieCanvas = document.getElementById('transactionStatusPieChart');
if (!lineCanvas || !pieCanvas || typeof Chart === 'undefined') {
return;
}
const lineLabels = @json($lineLabels);
const lineValues = @json($lineValues);
const statusValues = @json([$pendingCount, $paidCount, $cancelledCount]);
const lineCtx = lineCanvas.getContext('2d');
const gradient = lineCtx.createLinearGradient(0, 0, 0, lineCanvas.height);
gradient.addColorStop(0, 'rgba(16, 185, 129, 0.35)');
gradient.addColorStop(1, 'rgba(16, 185, 129, 0.02)');
new Chart(lineCtx, {
type: 'line',
data: {
labels: lineLabels,
datasets: [{
label: 'Pendapatan Paid',
data: lineValues,
tension: 0.45,
fill: true,
borderWidth: 2.5,
borderColor: '#10b981',
backgroundColor: gradient,
pointRadius: 3,
pointHoverRadius: 5,
pointBackgroundColor: '#10b981'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: function (context) {
return 'Rp ' + Number(context.parsed.y || 0).toLocaleString('id-ID');
}
}
}
},
scales: {
x: {
grid: { color: 'rgba(203, 213, 225, 0.35)' },
ticks: { color: '#64748b' }
},
y: {
beginAtZero: true,
grid: { color: 'rgba(203, 213, 225, 0.35)' },
ticks: {
color: '#64748b',
callback: function (value) {
return 'Rp ' + Number(value).toLocaleString('id-ID');
}
}
}
}
}
});
new Chart(pieCanvas, {
type: 'doughnut',
data: {
labels: ['Pending', 'Paid', 'Cancelled'],
datasets: [{
data: statusValues,
backgroundColor: ['#fbbf24', '#34d399', '#fb7185'],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutout: '58%',
plugins: {
legend: {
position: 'bottom',
labels: {
boxWidth: 12,
boxHeight: 12,
color: '#475569'
}
}
}
}
});
});
</script>
@endsection

View File

@ -0,0 +1,59 @@
@extends('layouts.app')
@section('title', 'Tambah Produk')
@section('content')
<div class="max-w-2xl space-y-6">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Tambah Produk</h2>
<form method="POST" action="{{ route('admin.products.store') }}" enctype="multipart/form-data" class="space-y-6">
@csrf
<x-card>
<div class="space-y-4">
<x-input label="Nama *" name="name" value="{{ old('name') }}" required />
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Deskripsi</label>
<textarea name="description" rows="2" class="w-full rounded-xl border border-gray-200 bg-white px-4 py-2.5 focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">{{ old('description') }}</textarea>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<x-input label="Harga *" name="price" type="number" value="{{ old('price') }}" min="0" required />
<x-input label="Stok *" name="stock" type="number" value="{{ old('stock', 0) }}" min="0" required />
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<x-input label="Rentang usia (contoh: 3-6)" name="age_range" value="{{ old('age_range') }}" placeholder="3-6" />
<x-input label="Kategori" name="category" value="{{ old('category') }}" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Gambar</label>
<input type="file" name="image" accept="image/*" class="w-full rounded-xl border border-gray-200 bg-white px-4 py-2.5 file:mr-3 file:rounded-lg file:border-0 file:bg-primary-50 file:px-4 file:py-2 file:text-primary-700 file:font-medium focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
</div>
<h3 class="font-semibold text-gray-900 pt-2">Nilai Kriteria (05)</h3>
<p class="text-sm text-gray-500 mb-2">Kriteria <strong>Harga</strong> diambil dari field Harga di atas. Kriteria lain mengikuti yang ada di admin.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
@foreach($criterias as $c)
@if($c->name === 'Harga')
@continue
@endif
<div>
<x-input
:label="$c->name . ' *'"
:name="'criteria_values['.$c->id.']'"
type="number"
:value="old('criteria_values.'.$c->id, 3)"
min="0"
max="5"
step="0.5"
required
/>
<p class="text-xs text-gray-400 mt-0.5">{{ $c->type === 'cost' ? 'Cost' : 'Benefit' }}</p>
</div>
@endforeach
</div>
</div>
</x-card>
<div class="flex items-center gap-3">
<x-button type="submit" variant="primary" size="md">Simpan</x-button>
<a href="{{ route('admin.products.index') }}" class="text-gray-600 hover:text-gray-900 font-medium">Batal</a>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,64 @@
@extends('layouts.app')
@section('title', 'Edit Produk')
@section('content')
<div class="max-w-2xl space-y-6">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Edit Produk</h2>
<form method="POST" action="{{ route('admin.products.update', $product) }}" enctype="multipart/form-data" class="space-y-6">
@csrf
@method('PUT')
<x-card>
<div class="space-y-4">
<x-input label="Nama *" name="name" value="{{ old('name', $product->name) }}" required />
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Deskripsi</label>
<textarea name="description" rows="2" class="w-full rounded-xl border border-gray-200 bg-white px-4 py-2.5 focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">{{ old('description', $product->description) }}</textarea>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<x-input label="Harga *" name="price" type="number" value="{{ old('price', $product->price) }}" min="0" required />
<x-input label="Stok *" name="stock" type="number" value="{{ old('stock', $product->stock) }}" min="0" required />
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<x-input label="Rentang usia" name="age_range" value="{{ old('age_range', $product->age_range) }}" placeholder="3-6" />
<x-input label="Kategori" name="category" value="{{ old('category', $product->category) }}" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Gambar (kosongkan jika tidak ubah)</label>
@if($product->image)
<p class="text-gray-500 text-sm mb-1">Saat ini: <img src="{{ Storage::url($product->image) }}" alt="" class="inline w-12 h-12 object-cover rounded-xl"></p>
@endif
<input type="file" name="image" accept="image/*" class="w-full rounded-xl border border-gray-200 bg-white px-4 py-2.5 file:mr-3 file:rounded-lg file:border-0 file:bg-primary-50 file:px-4 file:py-2 file:text-primary-700 file:font-medium focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
</div>
@php $pcById = $product->criterias->keyBy('id'); @endphp
<h3 class="font-semibold text-gray-900 pt-2">Nilai Kriteria (05)</h3>
<p class="text-sm text-gray-500 mb-2">Kriteria <strong>Harga</strong> mengikuti field Harga di atas. Kriteria lain mengikuti yang ada di admin.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
@foreach($criterias as $c)
@if($c->name === 'Harga')
@continue
@endif
<div>
<x-input
:label="$c->name . ' *'"
:name="'criteria_values['.$c->id.']'"
type="number"
:value="old('criteria_values.'.$c->id, $pcById->get($c->id)?->pivot->value ?? 3)"
min="0"
max="5"
step="0.5"
required
/>
<p class="text-xs text-gray-400 mt-0.5">{{ $c->type === 'cost' ? 'Cost' : 'Benefit' }}</p>
</div>
@endforeach
</div>
</div>
</x-card>
<div class="flex items-center gap-3">
<x-button type="submit" variant="primary" size="md">Simpan</x-button>
<a href="{{ route('admin.products.index') }}" class="text-gray-600 hover:text-gray-900 font-medium">Batal</a>
</div>
</form>
</div>
@endsection

View File

@ -0,0 +1,64 @@
@extends('layouts.app')
@section('title', 'Manajemen Produk')
@section('content')
<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Manajemen Produk</h2>
<x-button href="{{ route('admin.products.create') }}" variant="primary" size="md">
<i class="fa-solid fa-plus"></i> Tambah Produk
</x-button>
</div>
<form method="GET" class="flex flex-wrap items-center gap-3">
<x-input name="search" value="{{ request('search') }}" placeholder="Cari produk..." class="w-64" />
<x-button type="submit" variant="outline" size="md">Cari</x-button>
</form>
<x-card :padding="false">
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Gambar</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Nama</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Harga</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Stok</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Usia</th>
<th class="text-right px-6 py-4 font-semibold text-gray-700">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@forelse($products as $p)
<tr class="hover:bg-gray-50/50 transition">
<td class="px-6 py-4">
@if($p->image)
<img src="{{ Storage::url($p->image) }}" alt="" class="w-12 h-12 object-cover rounded-xl">
@else
<span class="inline-flex w-12 h-12 items-center justify-center rounded-xl bg-gray-100 text-2xl">🧸</span>
@endif
</td>
<td class="px-6 py-4 font-medium text-gray-900">{{ $p->name }}</td>
<td class="px-6 py-4 text-gray-700">Rp {{ number_format($p->price, 0, ',', '.') }}</td>
<td class="px-6 py-4">{{ $p->stock }}</td>
<td class="px-6 py-4 text-gray-600">{{ $p->age_range ?? '-' }}</td>
<td class="px-6 py-4 text-right">
<a href="{{ route('admin.products.edit', $p) }}" class="inline-flex items-center px-3 py-1.5 rounded-lg text-primary-600 hover:bg-primary-50 font-medium transition">Edit</a>
<form action="{{ route('admin.products.destroy', $p) }}" method="POST" class="inline ml-1" data-confirm="Hapus produk?">
@csrf
@method('DELETE')
<button type="submit" class="inline-flex items-center px-3 py-1.5 rounded-lg text-red-600 hover:bg-red-50 font-medium transition">Hapus</button>
</form>
</td>
</tr>
@empty
<tr><td colspan="6" class="px-6 py-12 text-center text-gray-500">Belum ada produk.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="px-6 py-4 border-t border-gray-100 flex justify-center">{{ $products->links() }}</div>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,73 @@
@extends('layouts.app')
@section('title', 'Manajemen Transaksi')
@section('content')
<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<h2 class="text-2xl font-bold text-gray-900 tracking-tight">Manajemen Transaksi</h2>
<form method="GET" class="flex flex-wrap gap-2 items-center">
<input type="date" name="from" value="{{ request('from') }}" class="rounded-xl border border-gray-200 px-3 py-2 text-sm focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
<input type="date" name="to" value="{{ request('to') }}" class="rounded-xl border border-gray-200 px-3 py-2 text-sm focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
<select name="status" class="rounded-xl border border-gray-200 px-3 py-2 text-sm focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
<option value="">Semua status</option>
@foreach(['pending','paid','cancelled'] as $s)
<option value="{{ $s }}" {{ request('status') == $s ? 'selected' : '' }}>{{ ucfirst($s) }}</option>
@endforeach
</select>
<x-button type="submit" variant="outline" size="sm">Filter</x-button>
<x-button href="{{ route('admin.transactions.export', request()->query()) }}" variant="outline" size="sm" class="!border-secondary-200 !text-secondary-700 hover:!bg-secondary-50">Export CSV</x-button>
</form>
</div>
<x-card :padding="false">
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Kode</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Customer</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Tanggal</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Total</th>
<th class="text-left px-6 py-4 font-semibold text-gray-700">Status</th>
<th class="text-right px-6 py-4 font-semibold text-gray-700">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@forelse($transactions as $t)
<tr class="hover:bg-gray-50/50 transition">
<td class="px-6 py-4 font-mono font-medium text-gray-900">{{ $t->code }}</td>
<td class="px-6 py-4 text-gray-700">{{ $t->user->name ?? '-' }}</td>
<td class="px-6 py-4 text-gray-600">{{ $t->created_at->format('d/m/Y H:i') }}</td>
<td class="px-6 py-4 font-medium text-gray-900">Rp {{ number_format($t->total, 0, ',', '.') }}</td>
<td class="px-6 py-4">
<form action="{{ route('admin.transactions.status', $t) }}" method="POST" class="inline">
@csrf
@method('PUT')
<select name="status" onchange="this.form.submit()" class="rounded-lg border border-gray-200 px-2.5 py-1.5 text-xs font-medium focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20">
@foreach(['pending','paid','cancelled'] as $s)
<option value="{{ $s }}" {{ $t->status === $s ? 'selected' : '' }}>{{ ucfirst($s) }}</option>
@endforeach
</select>
</form>
</td>
<td class="px-6 py-4 text-right">
@if($t->status === 'paid')
<a href="{{ route('admin.transactions.show', $t) }}" class="inline-flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-semibold text-primary-600 hover:bg-primary-50">
<i class="fa-solid fa-file-invoice"></i> Invoice
</a>
@else
<span class="text-xs text-gray-400"></span>
@endif
</td>
</tr>
@empty
<tr><td colspan="6" class="px-6 py-12 text-center text-gray-500">Tidak ada transaksi.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="px-6 py-4 border-t border-gray-100 flex justify-center">{{ $transactions->links() }}</div>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,86 @@
@extends('layouts.app')
@section('title', 'Invoice ' . $transaction->code)
@section('content')
<div class="max-w-4xl mx-auto space-y-6">
<div class="flex items-center justify-between gap-4">
<a href="{{ route('admin.transactions.index') }}" class="inline-flex items-center gap-2 text-sm font-medium text-primary-600 hover:text-primary-700">
<i class="fa-solid fa-arrow-left"></i> Kembali ke daftar transaksi
</a>
<x-button type="button" variant="outline" size="sm" data-action="print">
<i class="fa-solid fa-print"></i> Cetak Invoice
</x-button>
</div>
<x-card :padding="false" class="print:bg-white print:shadow-none">
<div class="px-6 py-5 border-b border-gray-100 flex flex-wrap items-start justify-between gap-4">
<div>
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase">Invoice</p>
<h2 class="text-2xl font-bold text-gray-900 mt-1">{{ $transaction->code }}</h2>
<p class="text-sm text-gray-500 mt-1">Tanggal: {{ $transaction->created_at->format('d F Y, H:i') }}</p>
</div>
<div class="text-right space-y-2">
<div>
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase">Status</p>
<x-badge :variant="$transaction->status === 'paid' ? 'success' : ($transaction->status === 'cancelled' ? 'danger' : 'warning')">
{{ ucfirst($transaction->status) }}
</x-badge>
</div>
<div>
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase">Total</p>
<p class="text-lg font-bold text-gray-900">Rp {{ number_format($transaction->total, 0, ',', '.') }}</p>
</div>
</div>
</div>
<div class="px-6 py-5 grid grid-cols-1 sm:grid-cols-2 gap-6 border-b border-gray-100">
<div>
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase mb-1">Data Pembeli</p>
<p class="text-sm font-medium text-gray-900">{{ $transaction->user->name ?? '-' }}</p>
<p class="text-sm text-gray-600 mt-1">Telp pembeli: {{ $transaction->phone }}</p>
</div>
<div class="sm:text-right">
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase mb-1">Informasi Pickup Toko</p>
<p class="text-sm text-gray-700 font-medium">{{ config('store.name') }}</p>
<p class="text-sm text-gray-500 mt-1">{{ config('store.address') }}</p>
<p class="text-sm text-gray-500 mt-1">Telp toko: {{ config('store.phone') }}</p>
<p class="text-sm text-gray-500 mt-1">Jam pengambilan: {{ optional($transaction->pickup_at)->format('d F Y, H:i') ?? '-' }}</p>
</div>
</div>
<div class="px-6 py-5">
<p class="text-xs font-semibold text-gray-500 tracking-wider uppercase mb-3">Detail item</p>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50 border-b border-gray-100">
<tr>
<th class="text-left px-4 py-2 font-semibold text-gray-700">Produk</th>
<th class="text-right px-4 py-2 font-semibold text-gray-700">Qty</th>
<th class="text-right px-4 py-2 font-semibold text-gray-700">Harga</th>
<th class="text-right px-4 py-2 font-semibold text-gray-700">Subtotal</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@foreach($transaction->details as $d)
<tr>
<td class="px-4 py-2 text-gray-800">{{ $d->product->name ?? '-' }}</td>
<td class="px-4 py-2 text-right text-gray-700">{{ $d->quantity }}</td>
<td class="px-4 py-2 text-right text-gray-700">Rp {{ number_format($d->price, 0, ',', '.') }}</td>
<td class="px-4 py-2 text-right font-medium text-gray-900">Rp {{ number_format($d->subtotal, 0, ',', '.') }}</td>
</tr>
@endforeach
</tbody>
<tfoot class="border-t border-gray-100">
<tr>
<td colspan="3" class="px-4 py-3 text-right text-sm font-semibold text-gray-700">Total</td>
<td class="px-4 py-3 text-right font-bold text-gray-900">Rp {{ number_format($transaction->total, 0, ',', '.') }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,41 @@
@extends('layouts.guest')
@section('title', 'Lupa Password')
@section('content')
<div class="max-w-md mx-auto py-12">
<x-card class="shadow-md">
<h1 class="text-2xl font-bold text-gray-900 tracking-tight">Lupa password</h1>
<p class="mt-1 text-sm text-gray-500">Masukkan email akun Anda, kami akan kirim kode verifikasi.</p>
@if (session('status'))
<div class="mt-4">
<x-alert variant="success">
{{ session('status') }}
</x-alert>
</div>
@endif
<form method="POST" action="{{ route('password.email') }}" class="mt-6 space-y-6">
@csrf
<x-input
label="Email"
name="email"
type="email"
value="{{ old('email') }}"
placeholder="nama@email.com"
required
autofocus
autocomplete="email"
:error="$errors->first('email')"
/>
<x-button type="submit" variant="primary" size="lg" class="w-full">Kirim kode verifikasi</x-button>
</form>
<p class="mt-6 text-center text-sm text-gray-500">
Ingat password? <a href="{{ route('login') }}" class="font-semibold text-primary-600 hover:text-primary-700">Kembali ke login</a>
</p>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,37 @@
@extends('layouts.guest')
@section('title', 'Masuk')
@section('content')
<div class="max-w-md mx-auto py-12">
<x-card class="shadow-md">
<h1 class="text-2xl font-bold text-gray-900 tracking-tight">Masuk ke akun</h1>
<p class="mt-1 text-sm text-gray-500">Gunakan email dan password Anda.</p>
@if (session('success'))
<div class="mt-4">
<x-alert variant="success">
{{ session('success') }}
</x-alert>
</div>
@endif
<form method="POST" action="{{ route('login') }}" class="mt-6 space-y-6">
@csrf
<x-input label="Email" name="email" type="email" value="{{ old('email') }}" placeholder="nama@email.com" required autofocus autocomplete="email" />
<x-input label="Password" name="password" type="password" required placeholder="••••••••" autocomplete="current-password" />
<div class="text-right -mt-2">
<a href="{{ route('password.request') }}" class="text-sm font-medium text-primary-600 hover:text-primary-700">
Lupa password?
</a>
</div>
<div class="flex items-center">
<input type="checkbox" name="remember" id="remember" class="rounded border-gray-300 text-primary-500 focus:ring-primary-500/20">
<label for="remember" class="ml-2 text-sm text-gray-600">Ingat saya</label>
</div>
<x-button type="submit" variant="primary" size="lg" class="w-full">Masuk</x-button>
</form>
<p class="mt-6 text-center text-sm text-gray-500">
Belum punya akun? <a href="{{ route('register') }}" class="font-semibold text-primary-600 hover:text-primary-700">Daftar</a>
</p>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,23 @@
@extends('layouts.guest')
@section('title', 'Daftar')
@section('content')
<div class="max-w-md mx-auto py-12">
<x-card class="shadow-md">
<h1 class="text-2xl font-bold text-gray-900 tracking-tight">Daftar akun baru</h1>
<p class="mt-1 text-sm text-gray-500">Isi data berikut untuk mulai.</p>
<form method="POST" action="{{ route('register') }}" class="mt-6 space-y-6">
@csrf
<x-input label="Nama" name="name" type="text" value="{{ old('name') }}" placeholder="Nama lengkap" required autocomplete="name" />
<x-input label="Email" name="email" type="email" value="{{ old('email') }}" placeholder="nama@email.com" required autocomplete="email" />
<x-input label="Password" name="password" type="password" required placeholder="Min. 8 karakter" autocomplete="new-password" />
<x-input label="Konfirmasi password" name="password_confirmation" type="password" required placeholder="Ulangi password" autocomplete="new-password" />
<x-button type="submit" variant="primary" size="lg" class="w-full">Daftar</x-button>
</form>
<p class="mt-6 text-center text-sm text-gray-500">
Sudah punya akun? <a href="{{ route('login') }}" class="font-semibold text-primary-600 hover:text-primary-700">Masuk</a>
</p>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,68 @@
@extends('layouts.guest')
@section('title', 'Verifikasi Reset Password')
@section('content')
<div class="max-w-md mx-auto py-12">
<x-card class="shadow-md">
<h1 class="text-2xl font-bold text-gray-900 tracking-tight">Verifikasi email</h1>
<p class="mt-1 text-sm text-gray-500">Masukkan kode 6 digit yang dikirim ke email Anda.</p>
@if (session('status'))
<div class="mt-4">
<x-alert variant="success">
{{ session('status') }}
</x-alert>
</div>
@endif
<form method="POST" action="{{ route('password.update') }}" class="mt-6 space-y-6">
@csrf
<x-input
label="Email"
name="email"
type="email"
value="{{ old('email', $email) }}"
placeholder="nama@email.com"
required
autocomplete="email"
:error="$errors->first('email')"
/>
<x-input
label="Kode Verifikasi"
name="code"
type="text"
value="{{ old('code') }}"
placeholder="123456"
required
maxlength="6"
inputmode="numeric"
:error="$errors->first('code')"
/>
<x-input
label="Password Baru"
name="password"
type="password"
placeholder="Min. 8 karakter"
required
autocomplete="new-password"
:error="$errors->first('password')"
/>
<x-input
label="Konfirmasi Password Baru"
name="password_confirmation"
type="password"
placeholder="Ulangi password baru"
required
autocomplete="new-password"
/>
<x-button type="submit" variant="primary" size="lg" class="w-full">Simpan password baru</x-button>
</form>
</x-card>
</div>
@endsection

View File

@ -0,0 +1,17 @@
@props([
'variant' => 'info',
])
@php
$variants = [
'success' => 'bg-secondary-50 border-secondary-200 text-secondary-800',
'error' => 'bg-red-50 border-red-200 text-red-800',
'warning' => 'bg-amber-50 border-amber-200 text-amber-800',
'info' => 'bg-primary-50 border-primary-200 text-primary-800',
];
$classes = 'rounded-2xl border px-5 py-4 ' . ($variants[$variant] ?? $variants['info']);
@endphp
<div {{ $attributes->merge(['class' => $classes, 'role' => 'alert']) }}>
{{ $slot }}
</div>

View File

@ -0,0 +1,17 @@
@props([
'variant' => 'default',
])
@php
$variants = [
'default' => 'bg-gray-100 text-gray-700',
'primary' => 'bg-primary-100 text-primary-700',
'secondary' => 'bg-secondary-100 text-secondary-700',
'success' => 'bg-secondary-100 text-secondary-700',
'warning' => 'bg-amber-100 text-amber-700',
'danger' => 'bg-red-100 text-red-700',
];
$classes = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ' . ($variants[$variant] ?? $variants['default']);
@endphp
<span {{ $attributes->merge(['class' => $classes]) }}>{{ $slot }}</span>

View File

@ -0,0 +1,29 @@
@props([
'tag' => 'button',
'variant' => 'primary',
'size' => 'md',
'href' => null,
])
@php
$tag = $href ? 'a' : $tag;
$base = 'inline-flex items-center justify-center gap-2 font-semibold rounded-2xl transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-60 disabled:pointer-events-none';
$variants = [
'primary' => 'bg-primary-500 text-white shadow-md hover:bg-primary-600 hover:shadow-lg hover:-translate-y-0.5 focus:ring-primary-500',
'outline' => 'border-2 border-gray-200 text-gray-700 bg-white hover:border-gray-300 hover:bg-gray-50 focus:ring-gray-400',
'secondary' => 'bg-secondary-500 text-white shadow-md hover:bg-secondary-600 hover:shadow-lg hover:-translate-y-0.5 focus:ring-secondary-500',
'ghost' => 'text-gray-600 hover:bg-gray-100 focus:ring-gray-300',
];
$sizes = [
'sm' => 'px-4 py-2 text-sm',
'md' => 'px-6 py-2.5 text-base',
'lg' => 'px-8 py-3.5 text-base',
];
$classes = $base . ' ' . ($variants[$variant] ?? $variants['primary']) . ' ' . ($sizes[$size] ?? $sizes['md']);
@endphp
@if($tag === 'a')
<a href="{{ $href }}" {{ $attributes->merge(['class' => $classes]) }}>{{ $slot }}</a>
@else
<button type="{{ $attributes->get('type', 'submit') }}" {{ $attributes->merge(['class' => $classes]) }}>{{ $slot }}</button>
@endif

View File

@ -0,0 +1,27 @@
@props([
'padding' => true,
'hover' => false,
])
@php
$classes = 'bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden transition-all duration-300';
if ($hover) {
$classes .= ' hover:shadow-md hover:-translate-y-0.5';
}
@endphp
<div {{ $attributes->merge(['class' => $classes]) }}>
@if(isset($header))
<div class="px-6 py-4 border-b border-gray-100">
{{ $header }}
</div>
@endif
<div class="{{ $padding ? 'p-6' : '' }}">
{{ $slot }}
</div>
@if(isset($footer))
<div class="px-6 py-4 border-t border-gray-100 bg-gray-50/50">
{{ $footer }}
</div>
@endif
</div>

Some files were not shown because too many files have changed in this diff Show More