Upload project Mylaundry1
This commit is contained in:
commit
507e31d7f9
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Redberry](https://redberry.international/laravel-development)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReportExport implements FromQuery, WithHeadings, WithMapping, ShouldAutoSize, WithStyles, WithCustomStartCell, WithEvents
|
||||
{
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
protected $deliveryType;
|
||||
protected $paymentMethod;
|
||||
protected $ids;
|
||||
|
||||
// Variabel untuk perhitungan di PHP
|
||||
protected $totalCash = 0;
|
||||
protected $totalQRIS = 0;
|
||||
protected $totalDeliveryFee = 0;
|
||||
protected $grandTotalHarga = 0;
|
||||
protected $totalUangMasuk = 0;
|
||||
protected $totalKembalian = 0;
|
||||
protected $rowCount = 0;
|
||||
|
||||
public function __construct($startDate, $endDate, $deliveryType = 'all', $paymentMethod = 'all', $ids = null)
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
$this->deliveryType = $deliveryType;
|
||||
$this->paymentMethod = $paymentMethod;
|
||||
$this->ids = $ids;
|
||||
}
|
||||
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A8';
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
$query = \App\Models\Order::query()->whereIn('status', ['DIAMBIL', 'DITERIMA']);
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$query->whereIn('id', $this->ids);
|
||||
} else {
|
||||
$query->whereBetween('updated_at', [$this->startDate . ' 00:00:00', $this->endDate . ' 23:59:59']);
|
||||
|
||||
if ($this->deliveryType !== 'all') {
|
||||
if ($this->deliveryType === 'none') {
|
||||
$query->where(function($q) {
|
||||
$q->where('delivery_type', 'none')->orWhereNull('delivery_type');
|
||||
});
|
||||
} else {
|
||||
$query->where('delivery_type', $this->deliveryType);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->paymentMethod !== 'all') {
|
||||
$query->where('payment_method', $this->paymentMethod);
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
public function headings(): array
|
||||
{
|
||||
$headers = [
|
||||
'No. Order', 'Tanggal Selesai', 'Nama Pelanggan',
|
||||
'Layanan', 'Jumlah', 'Harga Layanan',
|
||||
'Metode', 'Layanan Driver'
|
||||
];
|
||||
|
||||
if (strtoupper($this->paymentMethod) !== 'QRIS') {
|
||||
$headers[] = 'Uang Masuk';
|
||||
$headers[] = 'Kembalian';
|
||||
}
|
||||
|
||||
$headers[] = 'Ongkir';
|
||||
$headers[] = 'Total Harga';
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function map($order): array
|
||||
{
|
||||
$this->rowCount++;
|
||||
|
||||
// 1. Ambil Data Layanan dari Order Items
|
||||
$layananArr = [];
|
||||
$jumlahArr = [];
|
||||
$hargaLayananArr = [];
|
||||
|
||||
if ($order->items) {
|
||||
foreach ($order->items as $item) {
|
||||
$layananArr[] = $item->service_name;
|
||||
|
||||
// Format jumlah agar tidak ada 0 berlebih di belakang koma (misal 2.000 -> 2)
|
||||
$qty = floatval($item->qty_or_weight);
|
||||
$qtyStr = rtrim(rtrim(number_format($qty, 3, '.', ''), '0'), '.');
|
||||
$jumlahArr[] = $qtyStr . ' ' . $item->unit;
|
||||
|
||||
$hargaLayananArr[] = $item->price;
|
||||
}
|
||||
}
|
||||
|
||||
$layananStr = implode(",\n", $layananArr);
|
||||
$jumlahStr = implode(",\n", $jumlahArr);
|
||||
$hargaLayananStr = implode(",\n", $hargaLayananArr);
|
||||
|
||||
// 2. Bersihkan Angka
|
||||
$valTotal = (int) preg_replace('/[^0-9]/', '', $order->total_price);
|
||||
$valReceived = (int) preg_replace('/[^0-9]/', '', $order->cash_received ?? $order->total_price);
|
||||
$valChange = (int) preg_replace('/[^0-9]/', '', $order->cash_change ?? 0);
|
||||
$valOngkir = (int) ($order->delivery_fee ?? 0);
|
||||
|
||||
$method = strtoupper($order->payment_method);
|
||||
|
||||
// 3. Klasifikasi Pendapatan
|
||||
if ($method == 'CASH') {
|
||||
$this->totalCash += $valTotal;
|
||||
$uangMasuk = $valReceived;
|
||||
$kembalian = $valChange;
|
||||
} else {
|
||||
$this->totalQRIS += $valTotal;
|
||||
$uangMasuk = $valTotal;
|
||||
$kembalian = 0;
|
||||
}
|
||||
|
||||
$this->totalDeliveryFee += $valOngkir;
|
||||
$this->grandTotalHarga += $valTotal;
|
||||
$this->totalUangMasuk += $uangMasuk;
|
||||
$this->totalKembalian += $kembalian;
|
||||
|
||||
$typeLabel = "Ambil Sendiri";
|
||||
if ($order->delivery_type === 'pickup') $typeLabel = "Pick-up";
|
||||
else if ($order->delivery_type === 'delivery') $typeLabel = "Delivery";
|
||||
else if ($order->delivery_type === 'both') $typeLabel = "Delivery & Pick-up";
|
||||
|
||||
// Return data dengan kolom baru
|
||||
$row = [
|
||||
'#' . ($order->order_number ?? $order->invoice_number),
|
||||
$order->updated_at->format('d/m/Y H:i'),
|
||||
$order->customer_name,
|
||||
$layananStr,
|
||||
$jumlahStr,
|
||||
$hargaLayananStr,
|
||||
$method == 'CASH' ? 'TUNAI' : $method,
|
||||
$typeLabel,
|
||||
];
|
||||
|
||||
if (strtoupper($this->paymentMethod) !== 'QRIS') {
|
||||
$row[] = $uangMasuk;
|
||||
$row[] = $kembalian;
|
||||
}
|
||||
|
||||
$row[] = $valOngkir;
|
||||
$row[] = $valTotal;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$lastDataRow = $this->rowCount + 8;
|
||||
$summaryBottomRow = $lastDataRow + 1;
|
||||
|
||||
$isQris = strtoupper($this->paymentMethod) === 'QRIS';
|
||||
$lastCol = $isQris ? 'J' : 'L';
|
||||
|
||||
// --- BAGIAN ATAS: JUDUL (Disesuaikan ke kolom L atau J) ---
|
||||
$title = 'LAPORAN PENDAPATAN LAUNDRY';
|
||||
$filters = [];
|
||||
|
||||
if ($this->deliveryType !== 'all') {
|
||||
$deliveryLabel = '';
|
||||
if ($this->deliveryType === 'none') $deliveryLabel = 'Ambil Sendiri';
|
||||
else if ($this->deliveryType === 'pickup') $deliveryLabel = 'Pick-up';
|
||||
else if ($this->deliveryType === 'delivery') $deliveryLabel = 'Delivery';
|
||||
else if ($this->deliveryType === 'both') $deliveryLabel = 'Delivery & Pick-up';
|
||||
|
||||
if ($deliveryLabel) $filters[] = $deliveryLabel;
|
||||
}
|
||||
|
||||
if ($this->paymentMethod !== 'all') {
|
||||
$paymentLabel = strtoupper($this->paymentMethod);
|
||||
if ($paymentLabel === 'CASH') $paymentLabel = 'TUNAI';
|
||||
$filters[] = $paymentLabel;
|
||||
}
|
||||
|
||||
if (!empty($filters)) {
|
||||
$title .= ' (' . implode(' - ', $filters) . ')';
|
||||
}
|
||||
|
||||
$event->sheet->mergeCells("A1:{$lastCol}1");
|
||||
$event->sheet->setCellValue('A1', $title);
|
||||
|
||||
$periode = Carbon::parse($this->startDate)->format('d M Y') . ' - ' . Carbon::parse($this->endDate)->format('d M Y');
|
||||
$event->sheet->mergeCells("A2:{$lastCol}2");
|
||||
$event->sheet->setCellValue('A2', 'Periode: ' . $periode);
|
||||
|
||||
// Ringkasan Pendapatan di Atas (Baris 4-6)
|
||||
$event->sheet->setCellValue('A4', 'TOTAL KESELURUHAN');
|
||||
$event->sheet->setCellValue('B4', ': Rp ' . number_format($this->grandTotalHarga, 0, ',', '.'));
|
||||
|
||||
$event->sheet->setCellValue('A5', 'TOTAL JASA LAUNDRY');
|
||||
$event->sheet->setCellValue('B5', ': Rp ' . number_format($this->grandTotalHarga - $this->totalDeliveryFee, 0, ',', '.'));
|
||||
|
||||
$event->sheet->setCellValue('A6', 'TOTAL ONGKIR (DRIVER)');
|
||||
$event->sheet->setCellValue('B6', ': Rp ' . number_format($this->totalDeliveryFee, 0, ',', '.'));
|
||||
|
||||
$currentRow = 4;
|
||||
if ($this->paymentMethod === 'all' || strtoupper($this->paymentMethod) === 'CASH') {
|
||||
$event->sheet->setCellValue('D' . $currentRow, 'TOTAL TUNAI (Fisik)');
|
||||
$event->sheet->setCellValue('E' . $currentRow, ': Rp ' . number_format($this->totalCash, 0, ',', '.'));
|
||||
$currentRow++;
|
||||
}
|
||||
|
||||
if ($this->paymentMethod === 'all' || strtoupper($this->paymentMethod) === 'QRIS') {
|
||||
$event->sheet->setCellValue('D' . $currentRow, 'TOTAL QRIS (Digital)');
|
||||
$event->sheet->setCellValue('E' . $currentRow, ': Rp ' . number_format($this->totalQRIS, 0, ',', '.'));
|
||||
$currentRow++;
|
||||
}
|
||||
|
||||
// --- BAGIAN BAWAH: TOTAL KESELURUHAN KOLOM ---
|
||||
$event->sheet->mergeCells("A{$summaryBottomRow}:H{$summaryBottomRow}");
|
||||
$event->sheet->setCellValue("A{$summaryBottomRow}", "TOTAL KESELURUHAN");
|
||||
if ($isQris) {
|
||||
$event->sheet->setCellValue("I{$summaryBottomRow}", $this->totalDeliveryFee);
|
||||
$event->sheet->setCellValue("J{$summaryBottomRow}", $this->grandTotalHarga);
|
||||
} else {
|
||||
$event->sheet->setCellValue("I{$summaryBottomRow}", "");
|
||||
$event->sheet->setCellValue("J{$summaryBottomRow}", "");
|
||||
$event->sheet->setCellValue("K{$summaryBottomRow}", $this->totalDeliveryFee);
|
||||
$event->sheet->setCellValue("L{$summaryBottomRow}", $this->grandTotalHarga);
|
||||
}
|
||||
|
||||
// --- STYLING ---
|
||||
$event->sheet->getStyle('A1:A2')->getFont()->setBold(true)->setSize(14);
|
||||
$event->sheet->getStyle('A1:A2')->getAlignment()->setHorizontal('center');
|
||||
|
||||
$event->sheet->getStyle('A4:A6')->getFont()->setBold(true);
|
||||
$lastRowStyle = $currentRow - 1;
|
||||
if ($lastRowStyle >= 4) {
|
||||
$event->sheet->getStyle('D4:D' . $lastRowStyle)->getFont()->setBold(true);
|
||||
$event->sheet->getStyle('E4:E' . $lastRowStyle)->getFont()->getColor()->setRGB('1D6F42');
|
||||
}
|
||||
$event->sheet->getStyle('B4:B6')->getFont()->getColor()->setRGB('1D6F42');
|
||||
|
||||
// Styling Baris Total Bawah
|
||||
$event->sheet->getStyle("A{$summaryBottomRow}:{$lastCol}{$summaryBottomRow}")->applyFromArray([
|
||||
'font' => ['bold' => true],
|
||||
'fill' => ['fillType' => 'solid', 'startColor' => ['rgb' => 'E2EFDA']], // Warna hijau muda yang lebih rapi
|
||||
'borders' => ['allBorders' => ['borderStyle' => Border::BORDER_THIN]]
|
||||
]);
|
||||
$event->sheet->getStyle("A{$summaryBottomRow}")->getAlignment()->setHorizontal('left');
|
||||
if ($isQris) {
|
||||
$event->sheet->getStyle("I{$summaryBottomRow}:J{$summaryBottomRow}")->getNumberFormat()->setFormatCode('#,##0');
|
||||
} else {
|
||||
$event->sheet->getStyle("I{$summaryBottomRow}:L{$summaryBottomRow}")->getNumberFormat()->setFormatCode('#,##0');
|
||||
}
|
||||
|
||||
// Set wrap text agar comma-separated dengan \n tampil rapi
|
||||
$event->sheet->getStyle("D8:F{$lastDataRow}")->getAlignment()->setWrapText(true);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
public function styles(Worksheet $sheet)
|
||||
{
|
||||
$highestRow = $sheet->getHighestRow();
|
||||
$isQris = strtoupper($this->paymentMethod) === 'QRIS';
|
||||
$lastCol = $isQris ? 'J' : 'L';
|
||||
|
||||
// Header Tabel (Baris 8, disesuaikan sampai kolom L atau J)
|
||||
$sheet->getStyle("A8:{$lastCol}8")->applyFromArray([
|
||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
||||
'fill' => ['fillType' => 'solid', 'startColor' => ['rgb' => '1D6F42']],
|
||||
'alignment' => ['horizontal' => 'center'],
|
||||
]);
|
||||
|
||||
// Border Tabel
|
||||
$sheet->getStyle("A8:{$lastCol}" . $highestRow)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
|
||||
|
||||
// Format Ribuan Kolom Keuangan
|
||||
$sheet->getStyle('F9:F' . $highestRow)->getNumberFormat()->setFormatCode('#,##0');
|
||||
if ($isQris) {
|
||||
$sheet->getStyle('I9:J' . $highestRow)->getNumberFormat()->setFormatCode('#,##0');
|
||||
} else {
|
||||
$sheet->getStyle('I9:L' . $highestRow)->getNumberFormat()->setFormatCode('#,##0');
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
return response()->json(['message' => 'Email atau password salah.'], 401);
|
||||
}
|
||||
|
||||
// --- PROTEKSI API ---
|
||||
if (!in_array($user->role, ['staf', 'driver'])) {
|
||||
return response()->json([
|
||||
'message' => 'Akses ditolak. Aplikasi ini hanya untuk staf dan driver.'
|
||||
], 403); // 403 Forbidden
|
||||
}
|
||||
|
||||
// --- PERBAIKAN 1: Hapus token lama sebelum membuat yang baru ---
|
||||
// Ini akan mencegah tabel personal_access_tokens menjadi penuh/numpuk
|
||||
$user->tokens()->delete();
|
||||
|
||||
$token = $user->createToken('auth_token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'access_token' => $token,
|
||||
'token_type' => 'Bearer',
|
||||
'user' => $user,
|
||||
'shop' => $user->getOwnerShop(),
|
||||
]);
|
||||
}
|
||||
|
||||
// --- PERBAIKAN 2: Tambahkan fungsi Logout ---
|
||||
public function logout(Request $request)
|
||||
{
|
||||
// Menghapus token yang sedang dipakai oleh staf saat ini
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Berhasil logout dan token telah dihapus.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Exception;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function getStats()
|
||||
{
|
||||
try {
|
||||
$stats = [
|
||||
'antrian' => (int) Order::where('status', 'ANTRIAN')->count(),
|
||||
'proses' => (int) Order::where('status', 'PROSES')->count(),
|
||||
'selesai' => (int) Order::where('status', 'SELESAI')->count(),
|
||||
];
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $stats
|
||||
], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil stats: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getActivities()
|
||||
{
|
||||
try {
|
||||
// PERBAIKAN: Tambahkan estimation_time, created_at di dalam select
|
||||
$activities = Order::with('items')->select('id', 'order_number', 'customer_name', 'phone', 'status', 'updated_at', 'delivery_fee', 'total_price', 'delivery_type', 'payment_method', 'cash_received', 'estimation_time', 'created_at')
|
||||
->orderBy('updated_at', 'desc')
|
||||
->limit(50)
|
||||
->get()
|
||||
->map(function ($order) {
|
||||
$services = $order->items->map(function ($item) {
|
||||
$qty = fmod($item->qty_or_weight, 1) == 0 ? (int)$item->qty_or_weight : $item->qty_or_weight;
|
||||
return $item->service_name . ' (' . $qty . ' ' . $item->unit . ')';
|
||||
})->implode(' + ');
|
||||
|
||||
$subtitle = $services;
|
||||
if ($order->delivery_fee > 0) {
|
||||
$ongkir = number_format($order->delivery_fee, 0, ',', '.');
|
||||
$subtitle .= ($subtitle ? " + " : "") . "Ongkir: Rp $ongkir";
|
||||
}
|
||||
$isPaid = strtoupper($order->payment_method) !== 'BAYAR NANTI' || $order->cash_received > 0;
|
||||
// Calculate estimation type
|
||||
$tipeEstimasi = "Reguler";
|
||||
if ($order->estimation_time && $order->created_at) {
|
||||
$diffInHours = $order->created_at->diffInHours($order->estimation_time);
|
||||
if ($diffInHours <= 6) {
|
||||
$tipeEstimasi = "Kilat";
|
||||
} elseif ($diffInHours <= 24) {
|
||||
$tipeEstimasi = "Ekspres";
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'order_number' => $order->order_number,
|
||||
'title' => (string) $order->customer_name,
|
||||
'subtitle' => $subtitle,
|
||||
'phone' => $order->phone ?? "-",
|
||||
'time' => $order->updated_at ? $order->updated_at->diffForHumans() : '-',
|
||||
'status' => (string) $order->status,
|
||||
'total' => $order->total_price,
|
||||
'delivery_type' => $order->delivery_type ?? 'none',
|
||||
'payment_status' => $isPaid ? 'PAID' : 'UNPAID',
|
||||
'payment_method' => $order->payment_method,
|
||||
'cash_received' => $order->cash_received,
|
||||
'estimation_time'=> $order->estimation_time ? $order->estimation_time->toDateTimeString() : '',
|
||||
'estimation_type'=> $tipeEstimasi,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $activities
|
||||
], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil aktivitas: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrdersByStatus($status)
|
||||
{
|
||||
try {
|
||||
$orders = Order::with('items')->where('status', strtoupper($status))
|
||||
->latest()
|
||||
->get()
|
||||
->map(function ($order) {
|
||||
$rawService = $order->items->map(function ($item) {
|
||||
return trim($item->service_name);
|
||||
})->implode(', ');
|
||||
|
||||
$berat = $order->total_weight ?? '0';
|
||||
$jasa = $rawService;
|
||||
|
||||
// --- PERBAIKAN DI SINI ---
|
||||
// Ambil data langsung dari kolom estimation_time di database
|
||||
// Jika null, kirim string kosong agar ditangani Flutter sebagai "Belum diatur"
|
||||
$estimationTime = $order->estimation_time ? $order->estimation_time->toDateTimeString() : '';
|
||||
|
||||
$tipeEstimasi = "Reguler";
|
||||
|
||||
// 1. Deteksi Tipe Estimasi berdasarkan selisih waktu
|
||||
if ($order->estimation_time && $order->created_at) {
|
||||
$diffInHours = $order->created_at->diffInHours($order->estimation_time);
|
||||
if ($diffInHours <= 6) {
|
||||
$tipeEstimasi = "Kilat";
|
||||
} elseif ($diffInHours <= 24) {
|
||||
$tipeEstimasi = "Ekspres";
|
||||
}
|
||||
}
|
||||
|
||||
$isPaid = strtoupper($order->payment_method) !== 'BAYAR NANTI' || $order->cash_received > 0;
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'order_number' => $order->order_number,
|
||||
'customer_name' => $order->customer_name,
|
||||
'phone' => $order->phone ?? "-",
|
||||
'status' => $order->status,
|
||||
'weight' => $berat,
|
||||
'service_name' => $jasa,
|
||||
'estimation_type' => $tipeEstimasi,
|
||||
'estimation_time' => $estimationTime,
|
||||
'total_price' => number_format($order->total_price ?? 0, 0, ',', '.'),
|
||||
'delivery_fee' => $order->delivery_fee ?? 0,
|
||||
'delivery_type' => $order->delivery_type ?? 'none',
|
||||
'payment_status' => $isPaid ? 'PAID' : 'UNPAID',
|
||||
'payment_method' => $order->payment_method,
|
||||
'cash_received' => $order->cash_received,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['success' => true, 'data' => $orders->values()->all()], 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
// Berkat Global Scope di Model, ini otomatis hanya mengambil
|
||||
// jasa aktif MILIK owner yang sedang login (via token API)
|
||||
$services = Service::where('is_active', 1)->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Daftar Jasa Aktif Berhasil Dimuat',
|
||||
'data' => $services
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal memuat data',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Shop;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ShopSettingsController extends Controller
|
||||
{
|
||||
public function getSettings(Request $request)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$shop = $user->getOwnerShop();
|
||||
|
||||
if (!$shop) {
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'shop_name' => null,
|
||||
'device_id' => null,
|
||||
'shop_latitude' => null,
|
||||
'shop_longitude' => null,
|
||||
'delivery_fee_per_km' => 0,
|
||||
'free_delivery_km' => 0,
|
||||
'is_delivery_active' => false,
|
||||
'is_estimation_active'=> false,
|
||||
'express_extra_price' => 0,
|
||||
'kilat_extra_price' => 0,
|
||||
'qris_image_url' => null,
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'shop_name' => $shop->shop_name,
|
||||
'device_id' => $shop->device_id,
|
||||
'shop_latitude' => $shop->latitude,
|
||||
'shop_longitude' => $shop->longitude,
|
||||
'delivery_fee_per_km' => $shop->delivery_fee_per_km,
|
||||
'free_delivery_km' => $shop->free_delivery_km ?? 0,
|
||||
'is_delivery_active' => $shop->is_delivery_active,
|
||||
'is_estimation_active'=> $shop->is_estimation_active ?? false,
|
||||
'express_extra_price' => $shop->express_extra_price ?? 0,
|
||||
'kilat_extra_price' => $shop->kilat_extra_price ?? 0,
|
||||
'qris_image_url' => $shop->qris_image ? asset('storage/' . $shop->qris_image) : null,
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function updateSettings(Request $request)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
|
||||
$validated = $request->validate([
|
||||
'shop_name' => 'nullable|string|max:100',
|
||||
'device_id' => 'nullable|string|max:50',
|
||||
'shop_latitude' => 'nullable|numeric',
|
||||
'shop_longitude' => 'nullable|numeric',
|
||||
'delivery_fee_per_km' => 'required|integer|min:0',
|
||||
'free_delivery_km' => 'required|integer|min:0',
|
||||
'is_delivery_active' => 'required|boolean',
|
||||
'is_estimation_active'=> 'required|boolean',
|
||||
'express_extra_price' => 'required|integer|min:0',
|
||||
'kilat_extra_price' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
Shop::updateOrCreate(
|
||||
['user_id' => $ownerId],
|
||||
[
|
||||
'shop_name' => $validated['shop_name'] ?? null,
|
||||
'device_id' => $validated['device_id'] ?? null,
|
||||
'latitude' => $validated['shop_latitude'] ?? null,
|
||||
'longitude' => $validated['shop_longitude'] ?? null,
|
||||
'delivery_fee_per_km' => $validated['delivery_fee_per_km'],
|
||||
'free_delivery_km' => $validated['free_delivery_km'],
|
||||
'is_delivery_active' => $validated['is_delivery_active'],
|
||||
'is_estimation_active'=> $validated['is_estimation_active'],
|
||||
'express_extra_price' => $validated['express_extra_price'],
|
||||
'kilat_extra_price' => $validated['kilat_extra_price'],
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Pengaturan toko berhasil disimpan.',
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,694 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order;
|
||||
use App\Models\Shop;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
// 0. GET /transactions - Ambil semua transaksi
|
||||
public function index()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
|
||||
$orders = Order::with('items')
|
||||
->where('user_id', $ownerId)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get()
|
||||
->map(function ($order) {
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'order_number' => $order->order_number,
|
||||
'customer_name' => $order->customer_name,
|
||||
'phone' => $order->phone,
|
||||
'total_price' => $order->total_price,
|
||||
'status' => $order->status,
|
||||
'created_at' => $order->created_at,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $orders
|
||||
], 200);
|
||||
}
|
||||
|
||||
// 1. Endpoint untuk Staf: Membuat Jadwal Jemput (Order Awal)
|
||||
public function requestPickup(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_name' => 'required|string',
|
||||
'phone' => 'required|string',
|
||||
'address' => 'nullable|string',
|
||||
'latitude' => 'nullable',
|
||||
'longitude' => 'nullable',
|
||||
]);
|
||||
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
|
||||
$today = Carbon::today();
|
||||
$prefix = 'ORD-' . $today->format('Ymd') . '-' . $ownerId . '-';
|
||||
$lastOrder = Order::withoutGlobalScopes()
|
||||
->where('user_id', $ownerId)
|
||||
->where('order_number', 'LIKE', $prefix . '%')
|
||||
->orderBy('order_number', 'desc')
|
||||
->first();
|
||||
|
||||
$nextNum = 1;
|
||||
if ($lastOrder) {
|
||||
$lastNum = (int) substr($lastOrder->order_number, -3);
|
||||
$nextNum = $lastNum + 1;
|
||||
}
|
||||
$orderNumber = $prefix . str_pad($nextNum, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$order = Order::create([
|
||||
'order_number' => $orderNumber,
|
||||
'user_id' => $ownerId,
|
||||
'customer_name' => $validated['customer_name'],
|
||||
'phone' => $validated['phone'],
|
||||
'address' => $validated['address'],
|
||||
'latitude' => $validated['latitude'],
|
||||
'longitude' => $validated['longitude'],
|
||||
'status' => 'PICKUP', // Status awal
|
||||
'total_price' => 0,
|
||||
'total_weight' => 0,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Jadwal jemput berhasil dibuat',
|
||||
'data' => $order
|
||||
], 201);
|
||||
}
|
||||
|
||||
// 2. Endpoint untuk Driver: Mengambil daftar tugas (Jemput & Antar)
|
||||
public function getDriverTasks()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
|
||||
$tasks = Order::with('items')->where('user_id', $ownerId)
|
||||
->where(function($query) {
|
||||
$query->whereIn('status', ['PICKUP', 'MENUNGGU JEMPUT', 'DI DRIVER', 'DELIVERY'])
|
||||
->orWhere(function($q) {
|
||||
// Untuk kompatibilitas mundur jika ada pesanan lama
|
||||
$q->where('status', 'SELESAI')
|
||||
->whereIn('delivery_type', ['delivery', 'both']);
|
||||
});
|
||||
})
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->map(function($order) {
|
||||
$tipeEstimasi = "Reguler";
|
||||
if ($order->estimation_time && $order->created_at) {
|
||||
$diffInHours = $order->created_at->diffInHours($order->estimation_time);
|
||||
if ($diffInHours <= 6) $tipeEstimasi = "Kilat";
|
||||
elseif ($diffInHours <= 24) $tipeEstimasi = "Ekspres";
|
||||
} else {
|
||||
$tipeEstimasi = "-";
|
||||
}
|
||||
|
||||
$serviceNameStr = $order->items->map(function($item) {
|
||||
$qtyStr = $item->unit === 'PCS' ? round($item->qty_or_weight) . ' PCS' : number_format($item->qty_or_weight, 3, '.', '') . ' KG';
|
||||
return "{$item->service_name} ({$qtyStr})||" . $item->subtotal;
|
||||
})->implode("\n");
|
||||
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'order_number' => $order->order_number,
|
||||
'type_id' => (in_array($order->status, ['PICKUP', 'MENUNGGU JEMPUT']) ? 'P' : 'O') . $order->id,
|
||||
'task_type' => (in_array($order->status, ['PICKUP', 'MENUNGGU JEMPUT']) ? 'jemput' : 'antar'),
|
||||
'customer_name' => $order->customer_name,
|
||||
'phone' => $order->phone,
|
||||
'address' => $order->address,
|
||||
'latitude' => $order->latitude,
|
||||
'longitude' => $order->longitude,
|
||||
'status' => $order->status,
|
||||
'service_name' => $serviceNameStr,
|
||||
'weight' => $order->total_weight,
|
||||
'delivery_type' => $order->delivery_type,
|
||||
'delivery_fee' => $order->delivery_fee,
|
||||
'total_price' => $order->total_price,
|
||||
'payment_method'=> $order->payment_method,
|
||||
'cash_received' => $order->cash_received,
|
||||
'estimation_type'=> $tipeEstimasi,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $tasks
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
if (!$request->expectsJson()) {
|
||||
return response()->json(['message' => 'Harus menggunakan header Accept application/json'], 406);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'customer_name' => 'required|string',
|
||||
'phone' => 'required|string',
|
||||
'items' => 'required|array',
|
||||
'items.*.service_id' => 'nullable',
|
||||
'items.*.service_name' => 'required|string',
|
||||
'items.*.price' => 'required|numeric',
|
||||
'items.*.qty_or_weight' => 'required|numeric',
|
||||
'items.*.unit' => 'required|string',
|
||||
'items.*.subtotal' => 'required|numeric',
|
||||
'total_price' => 'required',
|
||||
'total_weight' => 'required',
|
||||
'payment_method' => 'nullable|string',
|
||||
'cash_received' => 'nullable',
|
||||
'address' => 'nullable|string',
|
||||
'latitude' => 'nullable',
|
||||
'longitude' => 'nullable',
|
||||
'delivery_type' => 'nullable|string',
|
||||
]);
|
||||
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
$shop = $user->getOwnerShop();
|
||||
|
||||
if (!$shop) {
|
||||
// Jika shop belum ada, buat default (agar tidak error)
|
||||
$shop = Shop::create(['user_id' => $ownerId]);
|
||||
}
|
||||
|
||||
$deliveryFee = 0;
|
||||
$deliveryDistance = 0;
|
||||
$deliveryType = $request->delivery_type ?? 'none';
|
||||
|
||||
$shop_lat = $shop->latitude;
|
||||
$shop_lng = $shop->longitude;
|
||||
|
||||
if ($deliveryType !== 'none' && $shop->is_delivery_active &&
|
||||
$request->latitude && $request->longitude) {
|
||||
|
||||
try {
|
||||
$url = "http://router.project-osrm.org/route/v1/driving/{$shop_lng},{$shop_lat};{$request->longitude},{$request->latitude}?overview=false";
|
||||
$osrmResponse = Http::timeout(5)->get($url);
|
||||
|
||||
if ($osrmResponse->successful()) {
|
||||
$osrmData = $osrmResponse->json();
|
||||
if (isset($osrmData['routes'][0]['distance'])) {
|
||||
$deliveryDistance = round($osrmData['routes'][0]['distance'] / 1000, 2);
|
||||
|
||||
// Logika Gratis KM dinamis dari shop setting
|
||||
$freeDeliveryKm = $shop->free_delivery_km ?? 0;
|
||||
if ($deliveryDistance <= $freeDeliveryKm) {
|
||||
$deliveryFee = 0;
|
||||
} else {
|
||||
$chargeableDistance = $deliveryDistance - $freeDeliveryKm;
|
||||
$baseFee = $chargeableDistance * $shop->delivery_fee_per_km;
|
||||
$multiplier = ($deliveryType === 'both') ? 2 : 1;
|
||||
$rawFee = $baseFee * $multiplier;
|
||||
$deliveryFee = (int) (ceil($rawFee / 500) * 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("OSRM Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$today = Carbon::today();
|
||||
$isUpdate = ($request->has('order_id') && !empty($request->order_id));
|
||||
$orderNumber = "";
|
||||
|
||||
// Fungsi untuk generate nomor urut berikutnya yang aman per owner
|
||||
$getNextOrderNumber = function() use ($today, $ownerId) {
|
||||
$prefix = 'ORD-' . $today->format('Ymd') . '-' . $ownerId . '-';
|
||||
$lastOrder = Order::withoutGlobalScopes()
|
||||
->where('user_id', $ownerId)
|
||||
->where('order_number', 'LIKE', $prefix . '%')
|
||||
->orderBy('order_number', 'desc')
|
||||
->first();
|
||||
|
||||
$nextNum = 1;
|
||||
if ($lastOrder) {
|
||||
$lastNum = (int) substr($lastOrder->order_number, -3);
|
||||
$nextNum = $lastNum + 1;
|
||||
}
|
||||
return $prefix . str_pad($nextNum, 3, '0', STR_PAD_LEFT);
|
||||
};
|
||||
|
||||
if (!$isUpdate) {
|
||||
$orderNumber = $getNextOrderNumber();
|
||||
}
|
||||
|
||||
$estType = strtolower($request->estimation_type ?? '');
|
||||
if (str_contains($estType, 'none')) {
|
||||
$estimationTime = Carbon::now()->addDays(3);
|
||||
} elseif (str_contains($estType, 'kilat')) {
|
||||
$estimationTime = Carbon::now()->addHours(6);
|
||||
} elseif (str_contains($estType, 'ekspres') || str_contains($estType, 'express')) {
|
||||
$estimationTime = Carbon::now()->addDays(1);
|
||||
} else {
|
||||
$estimationTime = Carbon::now()->addDays(3);
|
||||
}
|
||||
|
||||
$cashReceived = intval($request->cash_received ?? 0);
|
||||
$totalPrice = intval($validated['total_price']) + $deliveryFee;
|
||||
$totalPrice = (int) (ceil($totalPrice / 500) * 500); // Bulatkan ke atas kelipatan 500
|
||||
$cashChange = $cashReceived - $totalPrice;
|
||||
|
||||
try {
|
||||
if ($isUpdate) {
|
||||
$order = Order::find($request->order_id);
|
||||
if ($order) {
|
||||
$updateData = [
|
||||
'total_price' => $totalPrice,
|
||||
'total_weight' => $validated['total_weight'],
|
||||
'status' => 'ANTRIAN',
|
||||
'estimation_time' => $estimationTime,
|
||||
'payment_method' => strtoupper($request->payment_method ?? 'CASH'),
|
||||
'cash_received' => $cashReceived,
|
||||
'cash_change' => $cashChange < 0 ? 0 : $cashChange,
|
||||
'delivery_type' => $deliveryType,
|
||||
'delivery_fee' => $deliveryFee,
|
||||
'delivery_distance' => $deliveryDistance,
|
||||
];
|
||||
|
||||
// Jika sebelumnya masih format PCK, ubah ke ORD
|
||||
if (str_starts_with($order->order_number, 'PCK')) {
|
||||
$updateData['order_number'] = $getNextOrderNumber();
|
||||
}
|
||||
|
||||
$order->update($updateData);
|
||||
|
||||
// Recreate items
|
||||
$order->items()->delete();
|
||||
foreach ($validated['items'] as $item) {
|
||||
$order->items()->create([
|
||||
'service_id' => $item['service_id'] ?? null,
|
||||
'service_name' => $item['service_name'],
|
||||
'price' => $item['price'],
|
||||
'qty_or_weight' => $item['qty_or_weight'],
|
||||
'unit' => $item['unit'],
|
||||
'subtotal' => $item['subtotal'],
|
||||
'estimation_name' => $item['estimation_name'] ?? null,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return response()->json(['message' => 'Pesanan tidak ditemukan.'], 404);
|
||||
}
|
||||
} else {
|
||||
$order = Order::create([
|
||||
'order_number' => $orderNumber,
|
||||
'user_id' => $ownerId,
|
||||
'customer_name' => $validated['customer_name'],
|
||||
'phone' => $validated['phone'],
|
||||
'total_price' => $totalPrice,
|
||||
'total_weight' => $validated['total_weight'],
|
||||
'status' => 'ANTRIAN',
|
||||
'estimation_time' => $estimationTime,
|
||||
'payment_method' => strtoupper($request->payment_method ?? 'CASH'),
|
||||
'cash_received' => $cashReceived,
|
||||
'cash_change' => $cashChange < 0 ? 0 : $cashChange,
|
||||
'address' => $request->address,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'delivery_type' => $deliveryType,
|
||||
'delivery_fee' => $deliveryFee,
|
||||
'delivery_distance' => $deliveryDistance,
|
||||
]);
|
||||
|
||||
foreach ($validated['items'] as $item) {
|
||||
$order->items()->create([
|
||||
'service_id' => $item['service_id'] ?? null,
|
||||
'service_name' => $item['service_name'],
|
||||
'price' => $item['price'],
|
||||
'qty_or_weight' => $item['qty_or_weight'],
|
||||
'unit' => $item['unit'],
|
||||
'subtotal' => $item['subtotal'],
|
||||
'estimation_name' => $item['estimation_name'] ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Save Order Error: " . $e->getMessage());
|
||||
return response()->json(['message' => 'Gagal menyimpan ke database: ' . $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
try {
|
||||
$shopName = $shop->shop_name ?? 'My Laundry';
|
||||
$estimasiStr = $order->estimation_time ? $order->estimation_time->format('d/m/Y H:i') : '';
|
||||
|
||||
$tipeEstimasiLabel = "Reguler";
|
||||
if ($order->estimation_time && $order->created_at) {
|
||||
$diffInHours = $order->created_at->diffInHours($order->estimation_time);
|
||||
if ($diffInHours <= 6) $tipeEstimasiLabel = "Kilat";
|
||||
elseif ($diffInHours <= 24) $tipeEstimasiLabel = "Ekspres";
|
||||
}
|
||||
|
||||
$metodeBayar = $order->payment_method;
|
||||
$hargaStr = number_format($order->total_price, 0, ',', '.');
|
||||
$ongkirStr = number_format($order->delivery_fee, 0, ',', '.');
|
||||
$uangMasukStr = number_format($order->cash_received, 0, ',', '.');
|
||||
$kembalianStr = number_format($order->cash_change, 0, ',', '.');
|
||||
|
||||
// Format berat menjadi 1 angka di belakang koma (misal 3.12 -> 3.1)
|
||||
$weightFormatted = number_format((float)$order->total_weight, 1, '.', '');
|
||||
|
||||
// Format Layanan secara dinamis (Selalu Baris Baru & Rata Kiri)
|
||||
$serviceInfo = "👕 *Layanan:*\n";
|
||||
|
||||
$i = 1;
|
||||
foreach ($order->items as $item) {
|
||||
$qtyStr = $item->unit === 'PCS' ? round($item->qty_or_weight) . ' PCS' : number_format($item->qty_or_weight, 3, '.', '') . ' KG';
|
||||
$priceStr = number_format($item->price, 0, ',', '.');
|
||||
$serviceInfo .= $i . ". {$item->service_name} ({$qtyStr}) - Rp $priceStr\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
$pesanBaru = "*NOTA $shopName*\n"
|
||||
. "--------------------------------------\n"
|
||||
. "Halo, ini konfirmasi atas pesanan bernama *{$order->customer_name}*.\n"
|
||||
. "Pesanan laundry Anda telah kami terima! 🙏\n\n"
|
||||
. "🧾 *No Order:* {$order->order_number}\n"
|
||||
. $serviceInfo;
|
||||
|
||||
if ($order->estimation_time) {
|
||||
if (strtolower($request->estimation_type ?? '') === 'none') {
|
||||
$pesanBaru .= "⏱️ *Estimasi Selesai:* $estimasiStr\n";
|
||||
} else {
|
||||
$pesanBaru .= "⏱️ *Estimasi Selesai:* $tipeEstimasiLabel ($estimasiStr)\n";
|
||||
}
|
||||
}
|
||||
$pesanBaru .= "--------------------------------------\n";
|
||||
|
||||
// DETAIL PENGIRIMAN (Jika menggunakan jasa Driver)
|
||||
if ($order->delivery_type !== 'none') {
|
||||
$typeLabel = $this->getDeliveryTypeLabel($order->delivery_type);
|
||||
|
||||
$pesanBaru .= "*DETAIL PENGIRIMAN*\n"
|
||||
. "🛵 *Layanan:* $typeLabel\n";
|
||||
|
||||
if ($shop && $shop->is_delivery_active) {
|
||||
$pesanBaru .= "📍 *Jarak:* {$order->delivery_distance} Km\n";
|
||||
}
|
||||
|
||||
if ($order->delivery_fee > 0) {
|
||||
$pesanBaru .= "🚚 *Ongkos Kirim:* Rp $ongkirStr\n";
|
||||
} else {
|
||||
$pesanBaru .= "🚚 *Ongkos Kirim:* Gratis\n";
|
||||
}
|
||||
$pesanBaru .= "--------------------------------------\n";
|
||||
}
|
||||
|
||||
$pesanBaru .= "*RINCIAN PEMBAYARAN*\n"
|
||||
. "💳 *Metode:* $metodeBayar\n"
|
||||
. "💰 *Total Tagihan:* *Rp $hargaStr*\n";
|
||||
|
||||
// Hanya paparkan Uang Masuk & Kembalian jika pelanggan membayar secara Tunai (CASH)
|
||||
if ($metodeBayar === 'CASH') {
|
||||
$pesanBaru .= "💵 *Uang Tunai:* Rp $uangMasukStr\n"
|
||||
. "🔄 *Kembalian:* Rp $kembalianStr\n";
|
||||
}
|
||||
|
||||
$pesanBaru .= "--------------------------------------\n";
|
||||
if ($metodeBayar === 'BAYAR NANTI') {
|
||||
$pesanBaru .= "Status Pembayaran: *BELUM LUNAS*\n";
|
||||
if (in_array(strtolower($order->delivery_type), ['delivery', 'both'])) {
|
||||
$pesanBaru .= "Silakan melakukan pelunasan kepada Driver kami saat pesanan diantarkan.\n";
|
||||
} else {
|
||||
$pesanBaru .= "Silakan melakukan pelunasan saat cucian diambil.\n";
|
||||
}
|
||||
} else {
|
||||
$pesanBaru .= "Status Pembayaran: *LUNAS*\n";
|
||||
}
|
||||
|
||||
$pesanBaru .= "--------------------------------------\n"
|
||||
. "Status saat ini: *DALAM ANTRIAN*\n"
|
||||
. "Kami akan menginfokan kembali jika pesanan sudah diproses. Terima kasih!";
|
||||
|
||||
$this->sendWhatsAppMessage($order->phone, $pesanBaru);
|
||||
} catch (\Exception $e) {}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Pesanan berhasil masuk',
|
||||
'data' => $order
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, $id)
|
||||
{
|
||||
$order = Order::find($id);
|
||||
if (!$order) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
$currentStatus = strtoupper($order->status);
|
||||
$nextStatus = $currentStatus;
|
||||
|
||||
if ($currentStatus === 'PICKUP' || $currentStatus === 'MENUNGGU JEMPUT') $nextStatus = 'TIBA DI TOKO';
|
||||
elseif ($currentStatus === 'TIBA DI TOKO') $nextStatus = 'ANTRIAN';
|
||||
elseif ($currentStatus === 'ANTRIAN') $nextStatus = 'PROSES';
|
||||
elseif ($currentStatus === 'PROSES') $nextStatus = 'SELESAI';
|
||||
elseif ($currentStatus === 'SELESAI') {
|
||||
if (in_array(strtolower($order->delivery_type), ['delivery', 'both'])) {
|
||||
$nextStatus = 'DELIVERY';
|
||||
} else {
|
||||
$nextStatus = 'DIAMBIL';
|
||||
}
|
||||
}
|
||||
elseif ($currentStatus === 'DELIVERY' || $currentStatus === 'DI DRIVER') $nextStatus = 'DITERIMA';
|
||||
|
||||
$order->status = $nextStatus;
|
||||
|
||||
// Cek jika ada data pembayaran tambahan (saat pelunasan)
|
||||
if ($request->has('payment_method')) {
|
||||
$order->payment_method = $request->payment_method;
|
||||
$order->cash_received = $request->cash_received;
|
||||
$order->cash_change = ($request->cash_received - $order->total_price);
|
||||
}
|
||||
|
||||
$order->save();
|
||||
|
||||
// --- KIRIM WA OTOMATIS SAAT STATUS BERUBAH ---
|
||||
try {
|
||||
/** @var User $shopUser */
|
||||
$shopUser = Auth::user();
|
||||
$shop = $shopUser->getOwnerShop();
|
||||
$shopName = $shop->shop_name ?? 'My Laundry';
|
||||
$namaPelanggan = $order->customer_name;
|
||||
$pesanUpdate = "*UPDATE $shopName*\n\nHalo, ini update atas pesanan bernama *{$namaPelanggan}*.\n";
|
||||
|
||||
if ($nextStatus === 'PROSES') {
|
||||
$pesanUpdate .= "Pesanan (No: *{$order->order_number}*) saat ini sedang *DIPROSES/DICUCI* 🫧\nKami akan infokan kembali jika sudah selesai.";
|
||||
} elseif ($nextStatus === 'SELESAI') {
|
||||
$pesanUpdate .= "Pesanan (No: *{$order->order_number}*) sudah *SELESAI* dikerjakan! 🎉\n\n";
|
||||
|
||||
$isDelivery = in_array(strtolower($order->delivery_type), ['delivery', 'both']);
|
||||
|
||||
// Jika belum dibayar lunas
|
||||
if (strtoupper($order->payment_method) === 'BAYAR NANTI' && $order->cash_received == 0) {
|
||||
$hargaStr = number_format($order->total_price, 0, ',', '.');
|
||||
if ($isDelivery) {
|
||||
$pesanUpdate .= "Tagihan sebesar *Rp $hargaStr* dapat dilunasi kepada Driver kami saat pesanan tiba nanti.\n\n";
|
||||
} else {
|
||||
$pesanUpdate .= "Tagihan sebesar *Rp $hargaStr* dapat dilunasi saat pengambilan ya.\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($isDelivery) {
|
||||
$pesanUpdate .= "Kami akan segera tugaskan driver untuk mengantar pesanan Anda. Mohon ditunggu ya!";
|
||||
} else {
|
||||
$pesanUpdate .= "Silakan ambil cucian Anda di toko kami. Ditunggu kedatangannya!";
|
||||
}
|
||||
} elseif ($nextStatus === 'DI DRIVER' || $nextStatus === 'DELIVERY') {
|
||||
$pesanUpdate .= "Kami sudah menugaskan driver untuk mengantarkan Pesanan (No: *{$order->order_number}*) ke lokasi Anda! 🛵💨\n\n";
|
||||
if (strtoupper($order->payment_method) === 'BAYAR NANTI' && $order->cash_received == 0) {
|
||||
$hargaStr = number_format($order->total_price, 0, ',', '.');
|
||||
$pesanUpdate .= "Jangan lupa siapkan pembayaran sebesar *Rp $hargaStr* untuk diberikan kepada Driver kami ya.\n\n";
|
||||
}
|
||||
$pesanUpdate .= "Mohon ditunggu. Terima kasih! 🙏";
|
||||
} elseif ($nextStatus === 'TIBA DI TOKO') {
|
||||
$pesanUpdate = "Halo *$namaPelanggan*,\n\n"
|
||||
. "Pesanan Anda (No: *{$order->order_number}*) sudah sampai di toko kami dan akan segera kami input. ✅\n\n"
|
||||
. "Terima kasih! 🙏";
|
||||
} elseif ($nextStatus === 'DIAMBIL' || $nextStatus === 'DITERIMA') {
|
||||
if ($nextStatus === 'DITERIMA') {
|
||||
$pesanUpdate .= "Pesanan (No: *{$order->order_number}*) telah *DITERIMA* oleh Anda.\n";
|
||||
} else {
|
||||
$pesanUpdate .= "Pesanan (No: *{$order->order_number}*) telah *DIAMBIL*. ✅\n";
|
||||
}
|
||||
$pesanUpdate .= "Terima kasih telah mempercayakan cucian Anda di $shopName! 🙏";
|
||||
}
|
||||
|
||||
if ($nextStatus !== $currentStatus) {
|
||||
$this->sendWhatsAppMessage($order->phone, $pesanUpdate);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error("WhatsApp Update Error: " . $e->getMessage());
|
||||
}
|
||||
// ---------------------------------------------
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => 'Status diperbarui']);
|
||||
}
|
||||
|
||||
public function getOrdersByStatus($status)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
|
||||
$orders = Order::with('items')->where('user_id', $ownerId)
|
||||
->where('status', strtoupper($status))
|
||||
->get()
|
||||
->map(function ($order) {
|
||||
$tipeEstimasi = "Reguler";
|
||||
if ($order->estimation_time && $order->created_at) {
|
||||
$diffInHours = $order->created_at->diffInHours($order->estimation_time);
|
||||
if ($diffInHours <= 6) $tipeEstimasi = "Kilat";
|
||||
elseif ($diffInHours <= 24) $tipeEstimasi = "Ekspres";
|
||||
} else {
|
||||
$tipeEstimasi = "-";
|
||||
}
|
||||
|
||||
$order->estimation_type = $tipeEstimasi;
|
||||
$order->weight = $order->total_weight;
|
||||
$order->service_name = $order->items->map(function($item) {
|
||||
$qtyStr = $item->unit === 'PCS' ? round($item->qty_or_weight) . ' PCS' : number_format($item->qty_or_weight, 3, '.', '') . ' KG';
|
||||
return "{$item->service_name} ({$qtyStr}) - Rp " . number_format($item->price, 0, ',', '.');
|
||||
})->implode("\n");
|
||||
|
||||
return $order;
|
||||
});
|
||||
|
||||
return response()->json(['status' => 'success', 'data' => $orders], 200);
|
||||
}
|
||||
|
||||
public function checkDeliveryFee(Request $request)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
$shop = $user->getOwnerShop();
|
||||
|
||||
if (!$shop || !$shop->is_delivery_active) {
|
||||
return response()->json(['delivery_fee' => 0, 'distance' => 0]);
|
||||
}
|
||||
|
||||
$lat = $request->latitude;
|
||||
$lng = $request->longitude;
|
||||
$deliveryType = $request->delivery_type; // 'pickup', 'delivery', 'both'
|
||||
|
||||
$shop_lat = $shop->latitude;
|
||||
$shop_lng = $shop->longitude;
|
||||
|
||||
if (!$lat || !$lng) {
|
||||
return response()->json(['delivery_fee' => 0, 'distance' => 0]);
|
||||
}
|
||||
|
||||
try {
|
||||
$url = "http://router.project-osrm.org/route/v1/driving/{$shop_lng},{$shop_lat};{$lng},{$lat}?overview=false";
|
||||
$response = Http::timeout(5)->get($url);
|
||||
|
||||
if ($response->successful()) {
|
||||
$data = $response->json();
|
||||
if (isset($data['routes'][0]['distance'])) {
|
||||
$distance = round($data['routes'][0]['distance'] / 1000, 2);
|
||||
|
||||
// Logika Gratis KM dinamis dari shop setting
|
||||
$freeDeliveryKm = $shop->free_delivery_km ?? 0;
|
||||
if ($distance <= $freeDeliveryKm) {
|
||||
$finalFee = 0;
|
||||
} else {
|
||||
$chargeableDistance = $distance - $freeDeliveryKm;
|
||||
$baseFee = $chargeableDistance * $shop->delivery_fee_per_km;
|
||||
|
||||
$multiplier = ($deliveryType === 'both') ? 2 : 1;
|
||||
$rawFee = $baseFee * $multiplier;
|
||||
|
||||
// Pembulatan kelipatan 500 ke atas
|
||||
$finalFee = (int) (ceil($rawFee / 500) * 500);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'delivery_fee' => $finalFee,
|
||||
'distance' => $distance
|
||||
]);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['delivery_fee' => 0, 'distance' => 0, 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
return response()->json(['delivery_fee' => 0, 'distance' => 0]);
|
||||
}
|
||||
|
||||
public function sendManualWhatsApp(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'phone' => 'required',
|
||||
'task_type' => 'required',
|
||||
'customer_name' => 'required'
|
||||
]);
|
||||
|
||||
$customerName = $request->customer_name;
|
||||
/** @var User $shopUser */
|
||||
$shopUser = Auth::user();
|
||||
$shop = $shopUser->getOwnerShop();
|
||||
$shopName = $shop->shop_name ?? 'My Laundry';
|
||||
$message = "";
|
||||
|
||||
if ($request->task_type == 'jemput') {
|
||||
$message = "Halo *$customerName* \nDriver dari *$shopName* saat ini sedang dalam perjalanan menuju lokasi Anda untuk *MENJEMPUT* cucian. 🛵💨\n\nMohon dibantu untuk menyiapkan cuciannya ya. Terima kasih! 🙏";
|
||||
} else {
|
||||
$message = "Halo *$customerName* \nDriver dari *$shopName* saat ini sedang dalam perjalanan menuju lokasi Anda untuk *MENGANTARKAN* pesanan cucian yang sudah selesai. 🛵💨\n\nMohon ditunggu kedatangannya di lokasi ya. Terima kasih! 🙏";
|
||||
}
|
||||
|
||||
$success = $this->sendWhatsAppMessage($request->phone, $message);
|
||||
|
||||
return response()->json(['status' => $success ? 'success' : 'error']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper: Konversi delivery_type ke label Indonesia
|
||||
*/
|
||||
private function getDeliveryTypeLabel(string $type): string
|
||||
{
|
||||
return match($type) {
|
||||
'pickup' => 'Pick-up',
|
||||
'delivery' => 'Delivery',
|
||||
'both' => 'Pick-up & Delivery',
|
||||
default => 'Takeaway',
|
||||
};
|
||||
}
|
||||
|
||||
private function sendWhatsAppMessage($phoneTarget, $messageText)
|
||||
{
|
||||
if (empty($phoneTarget)) return false;
|
||||
|
||||
$token = "2HP5kgnwLfpvShg6eBgw"; // GANTI DENGAN TOKEN FONNTE ANDA
|
||||
|
||||
if (empty($token)) return false;
|
||||
|
||||
try {
|
||||
$response = Http::withHeaders(['Authorization' => $token])->post('https://api.fonnte.com/send', [
|
||||
'target' => $phoneTarget,
|
||||
'message' => $messageText,
|
||||
'countryCode' => '62',
|
||||
]);
|
||||
return $response->successful();
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the login view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming authentication request.
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ConfirmablePasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirm password view.
|
||||
*/
|
||||
public function show(): View
|
||||
{
|
||||
return view('auth.confirm-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (! Auth::guard('web')->validate([
|
||||
'email' => $request->user()->email,
|
||||
'password' => $request->password,
|
||||
])) {
|
||||
throw ValidationException::withMessages([
|
||||
'password' => __('auth.password'),
|
||||
]);
|
||||
}
|
||||
|
||||
$request->session()->put('auth.password_confirmed_at', time());
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EmailVerificationNotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send a new email verification notification.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EmailVerificationPromptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the email verification prompt.
|
||||
*/
|
||||
public function __invoke(Request $request): RedirectResponse|View
|
||||
{
|
||||
return $request->user()->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard', absolute: false))
|
||||
: view('auth.verify-email');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class NewPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset view.
|
||||
*/
|
||||
public function create(Request $request): View
|
||||
{
|
||||
return view('auth.reset-password', ['request' => $request]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming new password request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'token' => ['required'],
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function (User $user) use ($request) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($request->password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
);
|
||||
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
return $status == Password::PASSWORD_RESET
|
||||
? redirect()->route('login')->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validateWithBag('updatePassword', [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
|
||||
return back()->with('status', 'password-updated');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PasswordResetLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset link request view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming password reset link request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
]);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
return $status == Password::RESET_LINK_SENT
|
||||
? back()->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the registration view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming registration request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'role' => 'owner', // PAKSA JADI OWNER DI SINI
|
||||
]);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class VerifyEmailController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*/
|
||||
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
|
||||
if ($request->user()->markEmailAsVerified()) {
|
||||
event(new Verified($request->user()));
|
||||
}
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// Mengambil data 7 hari terakhir
|
||||
$chartData = [];
|
||||
$days = [];
|
||||
|
||||
for ($i = 6; $i >= 0; $i--) {
|
||||
$date = now()->subDays($i);
|
||||
$days[] = $date->translatedFormat('D d M'); // Contoh: Sen 12 Mei
|
||||
|
||||
// Hitung jumlah order pada tanggal tersebut
|
||||
$chartData[] = \App\Models\Order::whereDate('created_at', $date->toDateString())->count();
|
||||
}
|
||||
|
||||
// Mencari nilai tertinggi untuk skala grafik (minimal 10 agar tidak mentok ke atas)
|
||||
$maxVal = max($chartData) > 0 ? max($chartData) : 10;
|
||||
|
||||
// Konversi nilai data ke koordinat SVG (Tinggi SVG kita 200)
|
||||
// Rumus: 200 - (nilai / maxVal * 150) -> 150 agar ada sisa ruang di atas
|
||||
$points = "";
|
||||
foreach ($chartData as $index => $value) {
|
||||
$x = $index * 166.6;
|
||||
$y = 200 - ($value / $maxVal * 150);
|
||||
$points .= "$x,$y ";
|
||||
}
|
||||
|
||||
return view('dashboard', [
|
||||
'total' => \App\Models\Order::whereNotIn('status', ['DIAMBIL', 'DITERIMA'])->count(),
|
||||
'antrian' => \App\Models\Order::where('status', 'ANTRIAN')->count(),
|
||||
'proses' => \App\Models\Order::where('status', 'PROSES')->count(),
|
||||
'selesai' => \App\Models\Order::where('status', 'SELESAI')->count(),
|
||||
'latest' => \App\Models\Order::latest()->take(5)->get(),
|
||||
'chartPoints' => trim($points),
|
||||
'days' => $days,
|
||||
'chartData' => $chartData
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Service;
|
||||
|
||||
class LaundryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Menampilkan daftar layanan (Halaman Utama)
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$services = Service::all();
|
||||
return view('laundry', compact('services'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Menampilkan halaman form tambah layanan baru
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('laundry.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Menyimpan layanan baru ke database
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'price' => 'required|numeric',
|
||||
'unit' => 'required|string',
|
||||
]);
|
||||
|
||||
Service::create([
|
||||
'name' => $request->name,
|
||||
'price' => $request->price,
|
||||
'unit' => $request->unit,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return redirect()->route('laundry')->with('success', 'Layanan berhasil ditambahkan!');
|
||||
}
|
||||
|
||||
/**
|
||||
* --- FUNGSI EDIT (YANG TADI HILANG) ---
|
||||
* Menampilkan halaman form edit layanan
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$service = Service::findOrFail($id);
|
||||
return view('laundry.edit', compact('service'));
|
||||
}
|
||||
|
||||
/**
|
||||
* --- FUNGSI UPDATE (UNTUK MENYIMPAN PERUBAHAN) ---
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'price' => 'required|numeric',
|
||||
'unit' => 'required|string',
|
||||
]);
|
||||
|
||||
$service = Service::findOrFail($id);
|
||||
$service->update([
|
||||
'name' => $request->name,
|
||||
'price' => $request->price,
|
||||
'unit' => $request->unit,
|
||||
]);
|
||||
|
||||
return redirect()->route('laundry')->with('success', 'Layanan berhasil diperbarui!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Mengubah status aktif/non-aktif (Toggle)
|
||||
*/
|
||||
public function updateStatus($id)
|
||||
{
|
||||
$service = Service::findOrFail($id);
|
||||
$service->is_active = !$service->is_active;
|
||||
$service->save();
|
||||
|
||||
return back()->with('success', 'Status layanan berhasil diperbarui!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Menghapus layanan
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$service = Service::findOrFail($id);
|
||||
$service->delete();
|
||||
|
||||
return back()->with('success', 'Layanan berhasil dihapus!');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrderListController extends Controller
|
||||
{
|
||||
public function showByStatus(Request $request, $status) // Tambahkan Request $request
|
||||
{
|
||||
// 1. Validasi & Normalisasi Status
|
||||
$statusUpper = strtoupper($status);
|
||||
$validStatuses = ['ANTRIAN', 'PROSES', 'SELESAI'];
|
||||
|
||||
if (!in_array($statusUpper, $validStatuses)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// 2. Mulai Query data dari tabel 'orders' berdasarkan status
|
||||
$query = Order::with('items')->where('status', $statusUpper);
|
||||
|
||||
// 3. Logika Pencarian (Jika ada input 'search')
|
||||
if ($request->has('search') && $request->search != '') {
|
||||
$searchTerm = $request->search;
|
||||
$query->where(function($q) use ($searchTerm) {
|
||||
$q->where('customer_name', 'like', '%' . $searchTerm . '%')
|
||||
->orWhere('order_number', 'like', '%' . $searchTerm . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Ambil data dengan Pagination & urutan terbaru
|
||||
// appends() digunakan agar saat pindah halaman, hasil search tidak hilang
|
||||
$orders = $query->latest()
|
||||
->paginate(10)
|
||||
->appends(['search' => $request->search]);
|
||||
|
||||
// 5. Kirim ke view
|
||||
return view('orders.status_list', compact('orders', 'statusUpper'));
|
||||
}
|
||||
|
||||
public function bulkDelete(Request $request)
|
||||
{
|
||||
$ids = is_array($request->selected_ids) ? array_unique($request->selected_ids) : [];
|
||||
|
||||
if (empty($ids)) {
|
||||
return redirect()->back()->with('error', 'Pilih minimal satu pesanan untuk dihapus.');
|
||||
}
|
||||
|
||||
try {
|
||||
Order::whereIn('id', $ids)->delete();
|
||||
return redirect()->back()->with('success', count($ids) . ' pesanan berhasil dihapus.');
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->with('error', 'Terjadi kesalahan saat menghapus data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileUpdateRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the user's profile form.
|
||||
*/
|
||||
public function edit(Request $request): View
|
||||
{
|
||||
return view('profile.edit', [
|
||||
'user' => $request->user(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*/
|
||||
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$request->user()->fill($request->validated());
|
||||
|
||||
if ($request->user()->isDirty('email')) {
|
||||
$request->user()->email_verified_at = null;
|
||||
}
|
||||
|
||||
$request->user()->save();
|
||||
|
||||
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the user's account.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validateWithBag('userDeletion', [
|
||||
'password' => ['required', 'current_password'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
Auth::logout();
|
||||
|
||||
$user->delete();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Order; // Sesuaikan dengan model yang Anda gunakan di API
|
||||
use Carbon\Carbon;
|
||||
use App\Exports\ReportExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
// Default tanggal: awal bulan ini sampai hari ini
|
||||
$startDate = $request->get('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
|
||||
$endDate = $request->get('end_date', Carbon::now()->format('Y-m-d'));
|
||||
$deliveryType = $request->get('delivery_type', 'all');
|
||||
$paymentMethod = $request->get('payment_method', 'all');
|
||||
|
||||
// Filter data yang statusnya selesai ('DIAMBIL' atau 'DITERIMA')
|
||||
$query = Order::with('items')
|
||||
->whereIn('status', ['DIAMBIL', 'DITERIMA'])
|
||||
->whereBetween('updated_at', [$startDate . ' 00:00:00', $endDate . ' 23:59:59']);
|
||||
|
||||
if ($deliveryType !== 'all') {
|
||||
if ($deliveryType === 'none') {
|
||||
$query->where(function($q) {
|
||||
$q->where('delivery_type', 'none')->orWhereNull('delivery_type');
|
||||
});
|
||||
} else {
|
||||
$query->where('delivery_type', $deliveryType);
|
||||
}
|
||||
}
|
||||
|
||||
if ($paymentMethod !== 'all') {
|
||||
$query->where('payment_method', $paymentMethod);
|
||||
}
|
||||
|
||||
$reports = $query->orderBy('updated_at', 'desc')->get();
|
||||
$totalRevenue = $query->sum('total_price');
|
||||
$totalDeliveryFee = $query->sum('delivery_fee');
|
||||
$totalLaundryRevenue = $totalRevenue - $totalDeliveryFee;
|
||||
$totalOrders = $query->count();
|
||||
|
||||
return view('reports', compact('reports', 'totalRevenue', 'totalDeliveryFee', 'totalLaundryRevenue', 'totalOrders', 'startDate', 'endDate', 'deliveryType', 'paymentMethod'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'customer_name' => 'required',
|
||||
'phone' => 'required',
|
||||
'service_name' => 'required',
|
||||
'total_price' => 'required|integer',
|
||||
'payment_method' => 'nullable|string', // Pastikan App mengirim ini
|
||||
'cash_received' => 'nullable|integer', // Pastikan App mengirim ini
|
||||
]);
|
||||
|
||||
// Hitung kembalian
|
||||
$total = $validated['total_price'];
|
||||
$bayar = $request->cash_received ?? 0;
|
||||
$kembali = ($bayar > $total) ? ($bayar - $total) : 0;
|
||||
|
||||
$ownerId = auth()->check() ? (auth()->user()->getOwnerId() ?? auth()->id()) : null;
|
||||
$orderCount = $ownerId ? Order::where('user_id', $ownerId)->count() : Order::count();
|
||||
$prefix = $ownerId ? 'ORD-' . date('Ymd') . '-' . $ownerId . '-' : 'ORD-' . date('Ymd') . '-';
|
||||
|
||||
$order = Order::create([
|
||||
'order_number' => $prefix . str_pad($orderCount + 1, 3, '0', STR_PAD_LEFT),
|
||||
'user_id' => $ownerId,
|
||||
'customer_name' => $validated['customer_name'],
|
||||
'phone' => $validated['phone'],
|
||||
'service_name' => $validated['service_name'],
|
||||
'total_price' => $total,
|
||||
'status' => 'ANTRIAN',
|
||||
'payment_method' => strtoupper($request->payment_method ?? 'CASH'),
|
||||
'cash_received' => $bayar,
|
||||
'cash_change' => $kembali,
|
||||
]);
|
||||
|
||||
|
||||
return response()->json(['status' => 'success', 'data' => $order]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->get('start_date', now()->startOfMonth()->format('Y-m-d'));
|
||||
$endDate = $request->get('end_date', now()->format('Y-m-d'));
|
||||
$deliveryType = $request->get('delivery_type', 'all');
|
||||
$paymentMethod = $request->get('payment_method', 'all');
|
||||
|
||||
$paymentLabel = $paymentMethod !== 'all' ? '-' . strtoupper($paymentMethod) : '';
|
||||
if ($paymentLabel === '-CASH') $paymentLabel = '-TUNAI';
|
||||
|
||||
return Excel::download(new ReportExport($startDate, $endDate, $deliveryType, $paymentMethod), "laporan-laundry{$paymentLabel}-{$startDate}-to-{$endDate}.xlsx");
|
||||
}
|
||||
|
||||
public function exportBulk(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'ids' => 'required|array',
|
||||
'ids.*' => 'exists:orders,id'
|
||||
]);
|
||||
|
||||
$startDate = $request->get('start_date', now()->startOfMonth()->format('Y-m-d'));
|
||||
$endDate = $request->get('end_date', now()->format('Y-m-d'));
|
||||
$deliveryType = $request->get('delivery_type', 'all');
|
||||
$paymentMethod = $request->get('payment_method', 'all');
|
||||
|
||||
$paymentLabel = $paymentMethod !== 'all' ? '-' . strtoupper($paymentMethod) : '';
|
||||
if ($paymentLabel === '-CASH') $paymentLabel = '-TUNAI';
|
||||
|
||||
return Excel::download(new ReportExport($startDate, $endDate, $deliveryType, $paymentMethod, $request->ids), "laporan-laundry-terpilih{$paymentLabel}.xlsx");
|
||||
}
|
||||
|
||||
// --- FUNGSI BARU UNTUK HAPUS BANYAK DATA SEKALIGUS ---
|
||||
public function bulkDelete(Request $request)
|
||||
{
|
||||
// 1. Validasi apakah ada array 'ids' yang dikirim dari checkbox
|
||||
$request->validate([
|
||||
'ids' => 'required|array',
|
||||
'ids.*' => 'exists:orders,id'
|
||||
]);
|
||||
|
||||
try {
|
||||
// Ambil ID unik karena tampilan mobile & desktop mengirimkan ID ganda
|
||||
$uniqueIds = is_array($request->ids) ? array_unique($request->ids) : [];
|
||||
|
||||
// 2. Eksekusi penghapusan data
|
||||
Order::whereIn('id', $uniqueIds)->delete();
|
||||
|
||||
// 3. Kembalikan ke halaman sebelumnya dengan pesan sukses
|
||||
return redirect()->back()->with('success', count($uniqueIds) . ' data laporan berhasil dihapus.');
|
||||
} catch (\Exception $e) {
|
||||
// Jika terjadi error (misalnya masalah database)
|
||||
return redirect()->back()->with('error', 'Gagal menghapus data: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StaffController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('staff.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// 1. Validasi data
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|min:8',
|
||||
'role' => 'required|in:staf,driver',
|
||||
]);
|
||||
|
||||
// 2. Simpan ke database
|
||||
\App\Models\User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => \Illuminate\Support\Facades\Hash::make($request->password),
|
||||
'role' => $request->role,
|
||||
// TAMBAHKAN BARIS DI BAWAH INI:
|
||||
'owner_id' => Auth::id(),
|
||||
]);
|
||||
|
||||
// 3. Arahkan kembali
|
||||
return redirect()->route('settings')->with('success', 'Akun ' . $request->role . ' berhasil ditambahkan!');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$staff = \App\Models\User::where('owner_id', Auth::id())->findOrFail($id);
|
||||
return view('staff.edit', compact('staff'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$staff = \App\Models\User::where('owner_id', Auth::id())->findOrFail($id);
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users,email,' . $staff->id,
|
||||
'password' => 'nullable|min:8',
|
||||
'role' => 'required|in:staf,driver',
|
||||
]);
|
||||
|
||||
$staff->name = $request->name;
|
||||
$staff->email = $request->email;
|
||||
$staff->role = $request->role;
|
||||
|
||||
if ($request->filled('password')) {
|
||||
$staff->password = \Illuminate\Support\Facades\Hash::make($request->password);
|
||||
}
|
||||
|
||||
$staff->save();
|
||||
|
||||
return redirect()->route('settings')->with('success', 'Akun berhasil diperbarui!');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
// Tambahkan filter owner_id agar Owner A tidak bisa menghapus staf Owner B lewat URL
|
||||
$staff = \App\Models\User::where('owner_id', Auth::id())->findOrFail($id);
|
||||
|
||||
if ($staff->id === Auth::id()) {
|
||||
return redirect()->back()->with('error', 'Anda tidak bisa menghapus akun sendiri!');
|
||||
}
|
||||
|
||||
$staff->delete();
|
||||
|
||||
return redirect()->route('settings')->with('success', 'Akun berhasil dihapus.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\Shop;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function settings()
|
||||
{
|
||||
$ownerId = Auth::id();
|
||||
|
||||
// Ambil data toko milik Owner (buat baru jika belum ada, meski seeder sudah handle)
|
||||
$shop = Shop::firstOrCreate(
|
||||
['user_id' => $ownerId],
|
||||
[
|
||||
'shop_name' => '',
|
||||
'delivery_fee_per_km' => 0,
|
||||
'free_delivery_km' => 0,
|
||||
'is_delivery_active' => false,
|
||||
'is_estimation_active' => false,
|
||||
'express_extra_price' => 0,
|
||||
'kilat_extra_price' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
$staffs = User::where('owner_id', $ownerId)->get();
|
||||
|
||||
return view('settings', compact('staffs', 'shop'));
|
||||
}
|
||||
|
||||
public function updateShopSettings(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'shop_name' => 'nullable|string|max:255',
|
||||
'delivery_fee_per_km' => 'required_if:is_delivery_active,1|numeric|min:1',
|
||||
'free_delivery_km' => 'nullable|numeric|min:0',
|
||||
'is_delivery_active' => 'nullable',
|
||||
'is_estimation_active' => 'nullable',
|
||||
'express_extra_price' => 'required_if:is_estimation_active,1|numeric|min:1',
|
||||
'kilat_extra_price' => 'required_if:is_estimation_active,1|numeric|min:1',
|
||||
'latitude' => 'nullable|numeric',
|
||||
'longitude' => 'nullable|numeric',
|
||||
], [
|
||||
'delivery_fee_per_km.required_if' => 'Tarif per KM harus diisi jika Ongkos Kirim diaktifkan.',
|
||||
'delivery_fee_per_km.min' => 'Tarif per KM harus lebih dari 0.',
|
||||
'express_extra_price.required_if' => 'Harga Express harus diisi jika Estimasi diaktifkan.',
|
||||
'express_extra_price.min' => 'Harga Express harus lebih dari 0.',
|
||||
'kilat_extra_price.required_if' => 'Harga Kilat harus diisi jika Estimasi diaktifkan.',
|
||||
'kilat_extra_price.min' => 'Harga Kilat harus lebih dari 0.',
|
||||
]);
|
||||
|
||||
$shop = Shop::where('user_id', Auth::id())->first();
|
||||
if ($shop) {
|
||||
$dataToUpdate = [
|
||||
'shop_name' => $request->shop_name,
|
||||
'delivery_fee_per_km' => $request->delivery_fee_per_km ?? 0,
|
||||
'free_delivery_km' => $request->free_delivery_km ?? 0,
|
||||
'is_delivery_active' => $request->has('is_delivery_active'),
|
||||
'is_estimation_active' => $request->has('is_estimation_active'),
|
||||
'express_extra_price' => $request->express_extra_price ?? 0,
|
||||
'kilat_extra_price' => $request->kilat_extra_price ?? 0,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
];
|
||||
|
||||
$shop->update($dataToUpdate);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', 'Pengaturan Toko berhasil diperbarui!');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth; // TAMBAHKAN INI
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class OnlyOwner
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
// Gunakan Auth:: daripada fungsi global auth()
|
||||
if (Auth::check() && Auth::user()->role !== 'owner') {
|
||||
Auth::logout();
|
||||
|
||||
// Hancurkan session agar benar-benar bersih
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/login')->with('error', 'Akses Ditolak! Hanya Owner yang boleh masuk.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class PreventBackHistory
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
// Tambahkan header anti-cache agar browser tidak menyimpan halaman dalam cache
|
||||
$response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0');
|
||||
$response->headers->set('Pragma', 'no-cache');
|
||||
$response->headers->set('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the request's credentials.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
// app/Http/Requests/Auth/LoginRequest.php
|
||||
|
||||
public function authenticate(): void
|
||||
{
|
||||
$this->ensureIsNotRateLimited();
|
||||
|
||||
// Baris ini yang bertugas mengecek checkbox 'remember'
|
||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||
RateLimiter::hit($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the login request is not rate limited.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function ensureIsNotRateLimited(): void
|
||||
{
|
||||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event(new Lockout($this));
|
||||
|
||||
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.throttle', [
|
||||
'seconds' => $seconds,
|
||||
'minutes' => ceil($seconds / 60),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limiting throttle key for the request.
|
||||
*/
|
||||
public function throttleKey(): string
|
||||
{
|
||||
return Str::transliterate(Str::lower($this->string('email')) . '|' . $this->ip());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'lowercase',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class)->ignore($this->user()->id),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use App\Models\Order;
|
||||
|
||||
class ActiveOrders extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.active-orders', [
|
||||
'latest' => Order::with('items')
|
||||
->whereNotIn('status', ['DIAMBIL', 'DITERIMA'])
|
||||
->latest()
|
||||
->paginate(10),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\Order;
|
||||
|
||||
class DashboardStats extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.dashboard-stats', [
|
||||
'total' => Order::whereNotIn('status', ['DIAMBIL', 'DITERIMA'])->count(),
|
||||
'antrian' => Order::where('status', 'ANTRIAN')->count(),
|
||||
'proses' => Order::where('status', 'PROSES')->count(),
|
||||
'selesai' => Order::where('status', 'SELESAI')->count(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'order_number',
|
||||
'customer_name',
|
||||
'phone',
|
||||
'total_price',
|
||||
'status',
|
||||
'total_weight',
|
||||
'estimation_time',
|
||||
'payment_method',
|
||||
'cash_received',
|
||||
'cash_change',
|
||||
'address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'delivery_type',
|
||||
'delivery_fee',
|
||||
'delivery_distance',
|
||||
];
|
||||
|
||||
/**
|
||||
* Casting format kolom agar dibaca sebagai objek tanggal oleh Laravel
|
||||
*/
|
||||
protected $casts = [
|
||||
'estimation_time' => 'datetime',
|
||||
'total_price' => 'integer',
|
||||
'total_weight' => 'float',
|
||||
];
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(OrderItem::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor untuk mendapatkan service_name dari items
|
||||
* Menghindari error di view karena kolom service_name dihapus dari tabel orders
|
||||
*/
|
||||
public function getServiceNameAttribute()
|
||||
{
|
||||
if ($this->items->isEmpty()) {
|
||||
return 'Layanan Umum';
|
||||
}
|
||||
|
||||
return $this->items->map(function ($item) {
|
||||
$qty = $item->unit === 'PCS' ? round($item->qty_or_weight) . ' PCS' : number_format($item->qty_or_weight, 3, '.', '') . ' KG';
|
||||
return $item->service_name . ' (' . $qty . ')||' . $item->subtotal;
|
||||
})->implode("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic Booted untuk Multi-Tenancy
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('owner', function (Builder $builder) {
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
$builder->where('user_id', $ownerId);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($order) {
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
$order->user_id = $user->getOwnerId();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrderItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'order_id',
|
||||
'service_id',
|
||||
'service_name',
|
||||
'price',
|
||||
'qty_or_weight',
|
||||
'unit',
|
||||
'subtotal',
|
||||
'estimation_name'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'integer',
|
||||
'qty_or_weight' => 'float',
|
||||
'subtotal' => 'integer'
|
||||
];
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'price',
|
||||
'unit',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relasi: Service punya banyak Order
|
||||
*/
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic Booted untuk Multi-Tenancy
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('owner', function (Builder $builder) {
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
$ownerId = $user->getOwnerId();
|
||||
$builder->where('user_id', $ownerId);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($service) {
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
$service->user_id = $user->getOwnerId();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Shop extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'shop_name',
|
||||
'device_id',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'delivery_fee_per_km',
|
||||
'free_delivery_km',
|
||||
'is_delivery_active',
|
||||
'is_estimation_active',
|
||||
'express_extra_price',
|
||||
'kilat_extra_price',
|
||||
'fonnte_token',
|
||||
'qris_image',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_delivery_active' => 'boolean',
|
||||
'is_estimation_active' => 'boolean',
|
||||
'free_delivery_km' => 'integer',
|
||||
'express_extra_price' => 'integer',
|
||||
'kilat_extra_price' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relasi: Shop milik seorang Owner
|
||||
*/
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
'owner_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi: Seorang Owner punya banyak Staff/Driver
|
||||
*/
|
||||
public function staffs(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi: Seorang Staff/Driver punya satu Owner (Bos)
|
||||
*/
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi: Seorang Owner punya satu Toko
|
||||
*/
|
||||
public function shop(): HasOne
|
||||
{
|
||||
return $this->hasOne(Shop::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper: Dapatkan Owner ID (baik user ini owner atau staf/driver)
|
||||
*/
|
||||
public function getOwnerId(): int
|
||||
{
|
||||
return ($this->role === 'staf' || $this->role === 'driver') ? $this->owner_id : $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper: Dapatkan data Shop milik Owner
|
||||
*/
|
||||
public function getOwnerShop(): ?Shop
|
||||
{
|
||||
$ownerId = $this->getOwnerId();
|
||||
return Shop::where('user_id', $ownerId)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new \App\Notifications\CustomResetPassword($token));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CustomResetPassword extends ResetPasswordNotification
|
||||
{
|
||||
/**
|
||||
* Override via() agar tidak menggunakan mail channel ketika
|
||||
* Brevo API key tersedia (mencegah blokir SMTP di Railway).
|
||||
*/
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$apiKey = config('services.brevo.api_key');
|
||||
|
||||
if ($apiKey) {
|
||||
// Kirim langsung via Brevo HTTP API di sini
|
||||
$this->sendViaBrevoApi($notifiable, $apiKey);
|
||||
// Kembalikan array kosong agar Laravel tidak memproses channel mail
|
||||
return [];
|
||||
}
|
||||
|
||||
// Fallback: gunakan mail channel SMTP biasa (untuk lokal)
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Kirim email reset sandi menggunakan Brevo HTTP API.
|
||||
* Menggunakan HTTP (bukan SMTP) sehingga tidak terblokir di Railway.
|
||||
*/
|
||||
protected function sendViaBrevoApi($notifiable, string $apiKey): void
|
||||
{
|
||||
$url = $this->resetUrl($notifiable);
|
||||
$expire = config('auth.passwords.' . config('auth.defaults.passwords') . '.expire', 60);
|
||||
|
||||
$htmlContent = "
|
||||
<div style='font-family:sans-serif;max-width:600px;margin:0 auto;'>
|
||||
<h2 style='color:#0058BE;'>Permintaan Reset Kata Sandi</h2>
|
||||
<p>Halo, <strong>" . ($notifiable->name ?? '') . "</strong>!</p>
|
||||
<p>Anda menerima email ini karena kami menerima permintaan untuk menyetel ulang kata sandi akun Anda di <strong>mylaundry</strong>.</p>
|
||||
<p style='margin:24px 0;'>
|
||||
<a href='{$url}'
|
||||
style='background-color:#0058BE;color:#fff;padding:14px 28px;border-radius:8px;text-decoration:none;font-weight:bold;font-size:15px;'>
|
||||
Reset Kata Sandi
|
||||
</a>
|
||||
</p>
|
||||
<p style='color:#666;font-size:14px;'>Tautan ini akan kedaluwarsa dalam <strong>{$expire} menit</strong>.</p>
|
||||
<p style='color:#666;font-size:14px;'>Jika Anda tidak meminta reset kata sandi, abaikan email ini.</p>
|
||||
<hr style='border:none;border-top:1px solid #eee;margin:24px 0;'>
|
||||
<p style='color:#999;font-size:13px;'>Salam hangat, <strong>mylaundry</strong></p>
|
||||
</div>
|
||||
";
|
||||
|
||||
try {
|
||||
$response = Http::timeout(10)->withHeaders([
|
||||
'api-key' => $apiKey,
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
])->post('https://api.brevo.com/v3/smtp/email', [
|
||||
'sender' => [
|
||||
'name' => config('mail.from.name', 'mylaundry'),
|
||||
'email' => config('mail.from.address'),
|
||||
],
|
||||
'to' => [
|
||||
['email' => $notifiable->email, 'name' => $notifiable->name ?? ''],
|
||||
],
|
||||
'subject' => 'Permintaan Reset Kata Sandi - mylaundry',
|
||||
'htmlContent' => $htmlContent,
|
||||
]);
|
||||
|
||||
if ($response->successful()) {
|
||||
Log::info('Brevo API: Email reset sandi berhasil dikirim ke ' . $notifiable->email);
|
||||
} else {
|
||||
Log::error('Brevo API Error [' . $response->status() . ']: ' . $response->body());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Brevo API Exception: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the mail representation (digunakan sebagai fallback SMTP lokal).
|
||||
*/
|
||||
public function toMail($notifiable): MailMessage
|
||||
{
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
$url = $this->resetUrl($notifiable);
|
||||
$expire = config('auth.passwords.' . config('auth.defaults.passwords') . '.expire', 60);
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Permintaan Reset Kata Sandi - mylaundry')
|
||||
->greeting('Halo!')
|
||||
->line('Anda menerima email ini karena kami menerima permintaan untuk menyetel ulang kata sandi akun Anda.')
|
||||
->action('Reset Kata Sandi', $url)
|
||||
->line("Tautan reset kata sandi ini akan kedaluwarsa dalam waktu {$expire} menit.")
|
||||
->line('Jika Anda tidak meminta reset kata sandi, abaikan email ini.')
|
||||
->salutation('Salam hangat, mylaundry');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
if (
|
||||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ||
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ||
|
||||
str_starts_with(config('app.url'), 'https://') ||
|
||||
config('app.env') === 'production'
|
||||
) {
|
||||
\Illuminate\Support\Facades\URL::forceScheme('https');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AppLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.app');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class GuestLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.guest');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?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',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
// Trust all proxies when behind load balancers like Railway
|
||||
$middleware->trustProxies(at: '*');
|
||||
|
||||
// Daftarkan alias middleware Anda di sini
|
||||
$middleware->alias([
|
||||
'owner' => \App\Http\Middleware\OnlyOwner::class,
|
||||
'prevent-back-history' => \App\Http\Middleware\PreventBackHistory::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
//
|
||||
})->create();
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
];
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"$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",
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-iconv": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/socialite": "^5.24",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"livewire/livewire": "^4.2",
|
||||
"maatwebsite/excel": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/breeze": "^2.3",
|
||||
"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
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -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'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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),
|
||||
|
||||
];
|
||||
|
|
@ -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-'),
|
||||
|
||||
];
|
||||
|
|
@ -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),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort(),
|
||||
// Sanctum::currentRequestHost(),
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?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'),
|
||||
],
|
||||
],
|
||||
'google' => [
|
||||
'client_id' => env('GOOGLE_CLIENT_ID'),
|
||||
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
|
||||
'redirect' => env('GOOGLE_REDIRECT_URL'),
|
||||
],
|
||||
|
||||
'brevo' => [
|
||||
'api_key' => env('BREVO_API_KEY'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?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->string('password');
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
|
||||
// Role: owner, staf, driver
|
||||
$table->enum('role', ['owner', 'staf', 'driver'])->default('staf');
|
||||
|
||||
// Relasi hierarki: Staf/Driver terhubung ke Owner
|
||||
// Jika user adalah 'owner', maka kolom ini NULL.
|
||||
// Jika user adalah 'staf' atau 'driver', kolom ini berisi ID Owner mereka.
|
||||
$table->unsignedBigInteger('owner_id')->nullable();
|
||||
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
||||
// Relasi ke tabel itu sendiri
|
||||
$table->foreign('owner_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->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');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Tabel shops menyimpan pengaturan toko milik Owner.
|
||||
* Setiap Owner punya 1 record shop (one-to-one).
|
||||
* Data ini sebelumnya ada di tabel users, dipindahkan agar lebih rapi.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shops', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade'); // Owner ID
|
||||
$table->string('shop_name')->nullable();
|
||||
$table->decimal('latitude', 10, 8)->nullable();
|
||||
$table->decimal('longitude', 11, 8)->nullable();
|
||||
$table->unsignedInteger('delivery_fee_per_km')->default(0);
|
||||
$table->integer('free_delivery_km')->default(0);
|
||||
$table->boolean('is_delivery_active')->default(false);
|
||||
$table->boolean('is_estimation_active')->default(false);
|
||||
$table->integer('express_extra_price')->default(0);
|
||||
$table->integer('kilat_extra_price')->default(0);
|
||||
$table->string('device_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Satu owner hanya punya satu toko
|
||||
$table->unique('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shops');
|
||||
}
|
||||
};
|
||||
|
|
@ -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()
|
||||
{
|
||||
Schema::create('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
// Menghubungkan jasa ke Owner (User)
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('price');
|
||||
$table->string('unit');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?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('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// FK ke tabel users (Owner pemilik order ini)
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
|
||||
$table->string('order_number')->unique();
|
||||
$table->string('customer_name');
|
||||
$table->string('phone')->nullable();
|
||||
|
||||
// Layanan sekarang dipindah ke tabel order_items (1-to-many)
|
||||
// Hanya menyimpan total harga dan total berat
|
||||
$table->timestamp('estimation_time')->nullable();
|
||||
$table->decimal('total_weight', 8, 3)->default(0);
|
||||
|
||||
// Harga & Pembayaran (unsigned karena tidak pernah negatif)
|
||||
$table->unsignedInteger('delivery_fee')->default(0);
|
||||
$table->unsignedInteger('total_price')->default(0);
|
||||
$table->string('status')->default('ANTRIAN')->index();
|
||||
$table->string('payment_method')->default('CASH');
|
||||
$table->unsignedInteger('cash_received')->default(0);
|
||||
$table->unsignedInteger('cash_change')->default(0);
|
||||
|
||||
// Tipe Pengantaran (satu kolom saja, label Indonesia ditampilkan di UI)
|
||||
// Values: none, pickup, delivery, both
|
||||
$table->string('delivery_type')->default('none')->index();
|
||||
|
||||
// Kolom Lokasi untuk Fitur Map & Tracking Driver
|
||||
$table->text('address')->nullable();
|
||||
$table->decimal('latitude', 10, 8)->nullable();
|
||||
$table->decimal('longitude', 11, 8)->nullable();
|
||||
$table->decimal('delivery_distance', 8, 2)->nullable(); // Jarak toko-pelanggan (km)
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Index untuk performa query laporan
|
||||
$table->index('payment_method');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('orders');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?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('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('order_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Relasi ke order
|
||||
$table->foreignId('order_id')->constrained()->onDelete('cascade');
|
||||
|
||||
// Relasi opsional ke services
|
||||
$table->foreignId('service_id')->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
// Snapshot data untuk histori jika suatu saat service diubah/dihapus
|
||||
$table->string('service_name');
|
||||
$table->unsignedInteger('price');
|
||||
$table->decimal('qty_or_weight', 8, 3);
|
||||
$table->string('unit'); // 'PCS' atau 'KG'
|
||||
$table->unsignedInteger('subtotal');
|
||||
$table->string('estimation_name')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('order_items');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shops', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'device_id',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shops', function (Blueprint $table) {
|
||||
$table->string('device_id')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Shop;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Seeder dikosongkan agar tidak menambah data dummy ke database
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
.env.example
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used during authentication for various
|
||||
| messages that we need to display to the user. You are free to modify
|
||||
| these language lines according to your application's requirements.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => 'These credentials do not match our records.',
|
||||
'password' => 'The provided password is incorrect.',
|
||||
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pagination Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used by the paginator library to build
|
||||
| the simple pagination links. You are free to change them to anything
|
||||
| you want to customize your views to better match your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'previous' => '« Previous',
|
||||
'next' => 'Next »',
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are the default lines which match reasons
|
||||
| that are given by the password broker for a password update attempt
|
||||
| outcome such as failure due to an invalid password / reset token.
|
||||
|
|
||||
*/
|
||||
|
||||
'reset' => 'Kata sandi Anda telah berhasil diatur ulang.',
|
||||
'sent' => 'Kami telah mengirimkan tautan pengaturan ulang kata sandi ke email Anda.',
|
||||
'throttled' => 'Silakan tunggu sebelum mencoba lagi.',
|
||||
'token' => 'Token pengaturan ulang kata sandi ini tidak valid.',
|
||||
'user' => 'Kami tidak dapat menemukan pengguna dengan alamat email tersebut.',
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute field must be accepted.',
|
||||
'accepted_if' => 'The :attribute field must be accepted when :other is :value.',
|
||||
'active_url' => 'The :attribute field must be a valid URL.',
|
||||
'after' => 'The :attribute field must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute field must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute field must only contain letters.',
|
||||
'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.',
|
||||
'alpha_num' => 'The :attribute field must only contain letters and numbers.',
|
||||
'any_of' => 'The :attribute field is invalid.',
|
||||
'array' => 'The :attribute field must be an array.',
|
||||
'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.',
|
||||
'before' => 'The :attribute field must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute field must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'array' => 'The :attribute field must have between :min and :max items.',
|
||||
'file' => 'The :attribute field must be between :min and :max kilobytes.',
|
||||
'numeric' => 'The :attribute field must be between :min and :max.',
|
||||
'string' => 'The :attribute field must be between :min and :max characters.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'can' => 'The :attribute field contains an unauthorized value.',
|
||||
'confirmed' => 'The :attribute field confirmation does not match.',
|
||||
'contains' => 'The :attribute field is missing a required value.',
|
||||
'current_password' => 'The password is incorrect.',
|
||||
'date' => 'The :attribute field must be a valid date.',
|
||||
'date_equals' => 'The :attribute field must be a date equal to :date.',
|
||||
'date_format' => 'The :attribute field must match the format :format.',
|
||||
'decimal' => 'The :attribute field must have :decimal decimal places.',
|
||||
'declined' => 'The :attribute field must be declined.',
|
||||
'declined_if' => 'The :attribute field must be declined when :other is :value.',
|
||||
'different' => 'The :attribute field and :other must be different.',
|
||||
'digits' => 'The :attribute field must be :digits digits.',
|
||||
'digits_between' => 'The :attribute field must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute field has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'doesnt_contain' => 'The :attribute field must not contain any of the following: :values.',
|
||||
'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.',
|
||||
'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.',
|
||||
'email' => 'The :attribute field must be a valid email address.',
|
||||
'encoding' => 'The :attribute field must be encoded in :encoding.',
|
||||
'ends_with' => 'The :attribute field must end with one of the following: :values.',
|
||||
'enum' => 'The selected :attribute is invalid.',
|
||||
'exists' => 'The selected :attribute is invalid.',
|
||||
'extensions' => 'The :attribute field must have one of the following extensions: :values.',
|
||||
'file' => 'The :attribute field must be a file.',
|
||||
'filled' => 'The :attribute field must have a value.',
|
||||
'gt' => [
|
||||
'array' => 'The :attribute field must have more than :value items.',
|
||||
'file' => 'The :attribute field must be greater than :value kilobytes.',
|
||||
'numeric' => 'The :attribute field must be greater than :value.',
|
||||
'string' => 'The :attribute field must be greater than :value characters.',
|
||||
],
|
||||
'gte' => [
|
||||
'array' => 'The :attribute field must have :value items or more.',
|
||||
'file' => 'The :attribute field must be greater than or equal to :value kilobytes.',
|
||||
'numeric' => 'The :attribute field must be greater than or equal to :value.',
|
||||
'string' => 'The :attribute field must be greater than or equal to :value characters.',
|
||||
],
|
||||
'hex_color' => 'The :attribute field must be a valid hexadecimal color.',
|
||||
'image' => 'The :attribute field must be an image.',
|
||||
'in' => 'The selected :attribute is invalid.',
|
||||
'in_array' => 'The :attribute field must exist in :other.',
|
||||
'in_array_keys' => 'The :attribute field must contain at least one of the following keys: :values.',
|
||||
'integer' => 'The :attribute field must be an integer.',
|
||||
'ip' => 'The :attribute field must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute field must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute field must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute field must be a valid JSON string.',
|
||||
'list' => 'The :attribute field must be a list.',
|
||||
'lowercase' => 'The :attribute field must be lowercase.',
|
||||
'lt' => [
|
||||
'array' => 'The :attribute field must have less than :value items.',
|
||||
'file' => 'The :attribute field must be less than :value kilobytes.',
|
||||
'numeric' => 'The :attribute field must be less than :value.',
|
||||
'string' => 'The :attribute field must be less than :value characters.',
|
||||
],
|
||||
'lte' => [
|
||||
'array' => 'The :attribute field must not have more than :value items.',
|
||||
'file' => 'The :attribute field must be less than or equal to :value kilobytes.',
|
||||
'numeric' => 'The :attribute field must be less than or equal to :value.',
|
||||
'string' => 'The :attribute field must be less than or equal to :value characters.',
|
||||
],
|
||||
'mac_address' => 'The :attribute field must be a valid MAC address.',
|
||||
'max' => [
|
||||
'array' => 'The :attribute field must not have more than :max items.',
|
||||
'file' => 'The :attribute field must not be greater than :max kilobytes.',
|
||||
'numeric' => 'The :attribute field must not be greater than :max.',
|
||||
'string' => 'The :attribute field must not be greater than :max characters.',
|
||||
],
|
||||
'max_digits' => 'The :attribute field must not have more than :max digits.',
|
||||
'mimes' => 'The :attribute field must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute field must be a file of type: :values.',
|
||||
'min' => [
|
||||
'array' => 'The :attribute field must have at least :min items.',
|
||||
'file' => 'The :attribute field must be at least :min kilobytes.',
|
||||
'numeric' => 'The :attribute field must be at least :min.',
|
||||
'string' => 'The :attribute field must be at least :min characters.',
|
||||
],
|
||||
'min_digits' => 'The :attribute field must have at least :min digits.',
|
||||
'missing' => 'The :attribute field must be missing.',
|
||||
'missing_if' => 'The :attribute field must be missing when :other is :value.',
|
||||
'missing_unless' => 'The :attribute field must be missing unless :other is :value.',
|
||||
'missing_with' => 'The :attribute field must be missing when :values is present.',
|
||||
'missing_with_all' => 'The :attribute field must be missing when :values are present.',
|
||||
'multiple_of' => 'The :attribute field must be a multiple of :value.',
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'not_regex' => 'The :attribute field format is invalid.',
|
||||
'numeric' => 'The :attribute field must be a number.',
|
||||
'password' => [
|
||||
'letters' => 'The :attribute field must contain at least one letter.',
|
||||
'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.',
|
||||
'numbers' => 'The :attribute field must contain at least one number.',
|
||||
'symbols' => 'The :attribute field must contain at least one symbol.',
|
||||
'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.',
|
||||
],
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'present_if' => 'The :attribute field must be present when :other is :value.',
|
||||
'present_unless' => 'The :attribute field must be present unless :other is :value.',
|
||||
'present_with' => 'The :attribute field must be present when :values is present.',
|
||||
'present_with_all' => 'The :attribute field must be present when :values are present.',
|
||||
'prohibited' => 'The :attribute field is prohibited.',
|
||||
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
|
||||
'prohibited_if_accepted' => 'The :attribute field is prohibited when :other is accepted.',
|
||||
'prohibited_if_declined' => 'The :attribute field is prohibited when :other is declined.',
|
||||
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
|
||||
'prohibits' => 'The :attribute field prohibits :other from being present.',
|
||||
'regex' => 'The :attribute field format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_array_keys' => 'The :attribute field must contain entries for: :values.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_if_accepted' => 'The :attribute field is required when :other is accepted.',
|
||||
'required_if_declined' => 'The :attribute field is required when :other is declined.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values are present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'same' => 'The :attribute field must match :other.',
|
||||
'size' => [
|
||||
'array' => 'The :attribute field must contain :size items.',
|
||||
'file' => 'The :attribute field must be :size kilobytes.',
|
||||
'numeric' => 'The :attribute field must be :size.',
|
||||
'string' => 'The :attribute field must be :size characters.',
|
||||
],
|
||||
'starts_with' => 'The :attribute field must start with one of the following: :values.',
|
||||
'string' => 'The :attribute field must be a string.',
|
||||
'timezone' => 'The :attribute field must be a valid timezone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'uppercase' => 'The :attribute field must be uppercase.',
|
||||
'url' => 'The :attribute field must be a valid URL.',
|
||||
'ulid' => 'The :attribute field must be a valid ULID.',
|
||||
'uuid' => 'The :attribute field must be a valid UUID.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap our attribute placeholder
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". This simply helps us make our message more expressive.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
|
||||
];
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"$schema": "https://www.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/forms": "^0.5.2",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"alpinejs": "^3.4.2",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"axios": "^1.11.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"postcss": "^8.4.31",
|
||||
"tailwindcss": "^3.1.0",
|
||||
"vite": "^7.0.7"
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
|
@ -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>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
|
|
@ -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());
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow:
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import './bootstrap';
|
||||
|
||||
import Alpine from 'alpinejs';
|
||||
|
||||
window.Alpine = Alpine;
|
||||
|
||||
Alpine.start();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import axios from 'axios';
|
||||
window.axios = axios;
|
||||
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<x-guest-layout>
|
||||
<div class="mb-4 text-sm text-gray-600">
|
||||
{{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('password.confirm') }}">
|
||||
@csrf
|
||||
|
||||
<!-- Password -->
|
||||
<div>
|
||||
<x-input-label for="password" :value="__('Password')" />
|
||||
|
||||
<x-text-input id="password" class="block mt-1 w-full"
|
||||
type="password"
|
||||
name="password"
|
||||
required autocomplete="current-password" />
|
||||
|
||||
<x-input-error :messages="$errors->get('password')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end mt-4">
|
||||
<x-primary-button>
|
||||
{{ __('Confirm') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-guest-layout>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="light" lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||
<title>Lupa Kata Sandi - Laundry System</title>
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"/>
|
||||
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: "class",
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
"primary": "#13a4ec",
|
||||
"background-light": "#f6f7f8",
|
||||
"background-dark": "#101c22",
|
||||
},
|
||||
fontFamily: { "display": ["Inter", "sans-serif"] }
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="bg-background-light dark:bg-background-dark min-h-screen flex flex-col font-display">
|
||||
|
||||
<main class="flex-1 flex flex-col items-center justify-center p-6 sm:p-12 relative overflow-hidden">
|
||||
<div class="absolute inset-0 z-0 opacity-10 pointer-events-none overflow-hidden">
|
||||
<div class="absolute -top-24 -left-24 w-96 h-96 bg-primary rounded-full blur-3xl"></div>
|
||||
</div>
|
||||
|
||||
<div class="z-10 w-full max-w-[480px] bg-white dark:bg-[#1a262e] rounded-xl shadow-xl border border-gray-100 dark:border-gray-800 p-8 sm:p-10">
|
||||
<div class="mb-6 text-center">
|
||||
<div class="inline-flex items-center justify-center w-16 h-16 bg-blue-50 dark:bg-blue-900/20 rounded-full mb-4">
|
||||
<span class="text-3xl text-primary">🔑</span>
|
||||
</div>
|
||||
<h1 class="text-[#111618] dark:text-white tracking-tight text-2xl font-bold leading-tight pb-2">Lupa Kata Sandi?</h1>
|
||||
<p class="text-[#617c89] dark:text-gray-400 text-sm font-normal">
|
||||
Masukkan email Anda dan kami akan mengirimkan tautan untuk mengatur ulang kata sandi Anda.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@if (session('status'))
|
||||
<div class="mb-6 p-4 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 text-green-600 dark:text-green-400 text-sm font-medium text-center">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('password.email') }}" class="space-y-5" autocomplete="off">
|
||||
@csrf
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-base font-medium leading-normal">Alamat Email</label>
|
||||
<input name="email" value="{{ old('email') }}" required autofocus
|
||||
class="w-full rounded-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-14 placeholder:text-[#617c89] p-[15px] text-base font-normal leading-normal"
|
||||
placeholder="Masukkan email terdaftar" type="email"/>
|
||||
@error('email')
|
||||
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<button type="submit" class="w-full flex items-center justify-center rounded-lg h-14 bg-primary text-white text-base font-bold hover:bg-primary/90 transition-all shadow-md active:scale-[0.98]">
|
||||
Kirim Tautan Atur Ulang
|
||||
</button>
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<a href="{{ route('login') }}" class="text-sm text-[#617c89] hover:text-primary transition-colors flex items-center justify-center gap-2">
|
||||
<span>←</span> Kembali ke Halaman Login
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="light" lang="id">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<title>Login - Laundry System</title>
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
||||
<link href="https://fonts.material.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet" />
|
||||
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: "class",
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
"primary": "#13a4ec",
|
||||
"background-light": "#f6f7f8",
|
||||
"background-dark": "#101c22",
|
||||
},
|
||||
fontFamily: {
|
||||
"display": ["Inter", "sans-serif"]
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.material-symbols-outlined {
|
||||
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="bg-background-light dark:bg-background-dark min-h-screen flex flex-col font-display">
|
||||
|
||||
<main class="flex-1 flex flex-col items-center justify-center p-2 sm:p-12 relative h-screen overflow-hidden">
|
||||
<div class="absolute inset-0 z-0 opacity-10 pointer-events-none overflow-hidden">
|
||||
<div class="absolute -top-24 -left-24 w-96 h-96 bg-primary rounded-full blur-3xl"></div>
|
||||
<div class="absolute -bottom-24 -right-24 w-96 h-96 bg-primary rounded-full blur-3xl"></div>
|
||||
</div>
|
||||
|
||||
<div class="z-10 w-full max-w-[400px] sm:max-w-[480px] bg-white dark:bg-[#1a262e] rounded-xl shadow-xl border border-gray-100 dark:border-gray-800 p-3 sm:p-8">
|
||||
<div class="mb-2 sm:mb-6">
|
||||
<h1 class="text-[#111618] dark:text-white tracking-tight text-lg sm:text-[32px] font-bold leading-tight text-center pb-0 sm:pb-1">Login</h1>
|
||||
<p class="text-[#617c89] dark:text-gray-400 text-[9px] sm:text-sm font-normal leading-tight text-center mt-0.5 sm:mt-0">Kelola pesanan, layanan, dan laporan Anda dengan efisien.</p>
|
||||
</div>
|
||||
|
||||
@if (session('status'))
|
||||
<div class="mb-4 font-medium text-sm text-green-600 dark:text-green-400 text-center">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('login') }}" class="flex flex-col gap-1.5 sm:gap-4">
|
||||
@csrf
|
||||
|
||||
<div class="flex flex-col gap-0.5 sm:gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-[10px] sm:text-sm font-medium leading-none">Alamat Email</label>
|
||||
<input name="email" value="{{ old('email') }}" required autofocus
|
||||
class="w-full rounded-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-8 sm:h-12 placeholder:text-[#617c89] px-2 py-1 text-[10px] sm:text-sm font-normal leading-normal"
|
||||
placeholder="email@gmail.com" type="email" />
|
||||
@error('email')
|
||||
<p class="text-red-500 text-[9px] sm:text-xs mt-0.5">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-0.5 sm:gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-[10px] sm:text-sm font-medium leading-none">Kata Sandi</label>
|
||||
<div class="flex w-full items-stretch rounded-lg group">
|
||||
<input name="password" id="password" required
|
||||
class="w-full rounded-l-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-8 sm:h-12 placeholder:text-[#617c89] px-2 py-1 border-r-0 pr-2 text-[10px] sm:text-sm font-normal leading-normal"
|
||||
placeholder="Kata sandi" type="password" />
|
||||
|
||||
<div id="togglePassword" class="text-[#617c89] flex border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark items-center justify-center pr-2 rounded-r-lg border-l-0 cursor-pointer hover:text-primary transition-colors">
|
||||
<span class="material-symbols-outlined text-[14px] sm:text-lg" id="eyeIcon">visibility</span>
|
||||
</div>
|
||||
</div>
|
||||
@error('password')
|
||||
<p class="text-red-500 text-[9px] sm:text-xs mt-0.5">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between py-0">
|
||||
<label class="flex items-center gap-1 sm:gap-2 cursor-pointer">
|
||||
<input name="remember" id="remember_me" type="checkbox"
|
||||
class="rounded text-primary focus:ring-primary border-gray-300 dark:border-gray-700 bg-white dark:bg-background-dark w-2.5 h-2.5 sm:w-4 sm:h-4" />
|
||||
<span class="text-[9px] sm:text-sm text-[#617c89] dark:text-gray-400 font-normal">Ingat Saya</span>
|
||||
</label>
|
||||
|
||||
@if (Route::has('password.request'))
|
||||
<a class="text-[9px] sm:text-sm text-primary font-semibold hover:underline" href="{{ route('password.request') }}">Lupa Kata Sandi?</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<button type="submit" class="w-full flex items-center justify-center rounded-lg h-8 sm:h-12 bg-primary text-white text-[11px] sm:text-base font-bold leading-normal tracking-[0.015em] hover:bg-primary/90 transition-all shadow-md active:scale-[0.98]">
|
||||
Masuk
|
||||
</button>
|
||||
|
||||
<div class="mt-0.5 sm:mt-2 text-center border-t border-gray-100 dark:border-gray-800 pt-1.5 sm:pt-4">
|
||||
<p class="text-[9px] sm:text-sm text-[#617c89] dark:text-gray-400">
|
||||
Belum punya akun?
|
||||
<a href="{{ route('register') }}" class="text-primary font-bold hover:underline italic">
|
||||
Daftar Sekarang
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
const togglePassword = document.querySelector('#togglePassword');
|
||||
const password = document.querySelector('#password');
|
||||
const eyeIcon = document.querySelector('#eyeIcon');
|
||||
|
||||
togglePassword.addEventListener('click', function(e) {
|
||||
// Toggle tipe input
|
||||
const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
|
||||
password.setAttribute('type', type);
|
||||
|
||||
// Toggle ikon (visibility vs visibility_off)
|
||||
eyeIcon.textContent = type === 'password' ? 'visibility' : 'visibility_off';
|
||||
});
|
||||
|
||||
// Mencegah akses kembali ke halaman login dari cache saat pengguna sudah login
|
||||
window.addEventListener('pageshow', function(event) {
|
||||
if (event.persisted || (window.performance && window.performance.navigation.type === 2)) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="light" lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||
<title>Daftar Akun - Laundry System</title>
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap" rel="stylesheet"/>
|
||||
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: "class",
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
"primary": "#13a4ec",
|
||||
"background-light": "#f6f7f8",
|
||||
"background-dark": "#101c22",
|
||||
},
|
||||
fontFamily: { "display": ["Inter", "sans-serif"] }
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-background-light dark:bg-background-dark min-h-screen flex flex-col font-display">
|
||||
|
||||
<main class="flex-1 flex flex-col items-center justify-center p-6 sm:p-12 relative overflow-hidden">
|
||||
<div class="absolute inset-0 z-0 opacity-10 pointer-events-none overflow-hidden">
|
||||
<div class="absolute -top-24 -right-24 w-96 h-96 bg-primary rounded-full blur-3xl"></div>
|
||||
<div class="absolute -bottom-24 -left-24 w-96 h-96 bg-primary rounded-full blur-3xl"></div>
|
||||
</div>
|
||||
|
||||
<div class="z-10 w-full max-w-[550px] bg-white dark:bg-[#1a262e] rounded-xl shadow-xl border border-gray-100 dark:border-gray-800 p-8 sm:p-10">
|
||||
<div class="mb-8 text-center">
|
||||
<h1 class="text-[#111618] dark:text-white tracking-tight text-[32px] font-bold leading-tight pb-2">Daftar Akun</h1>
|
||||
<p class="text-[#617c89] dark:text-gray-400 text-sm font-normal">Buat akun untuk mulai mengelola sistem laundry Anda.</p>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('register') }}" class="space-y-5" autocomplete="off">
|
||||
@csrf
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-base font-medium leading-normal">Nama Lengkap</label>
|
||||
<input name="name" value="{{ old('name') }}" required autofocus autocomplete="name"
|
||||
class="w-full rounded-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-14 placeholder:text-[#617c89] p-[15px] text-base font-normal leading-normal"
|
||||
placeholder="Masukkan nama lengkap Anda" type="text"/>
|
||||
@error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-base font-medium leading-normal">Alamat Email</label>
|
||||
<input name="email" value="{{ old('email') }}" required autocomplete="username"
|
||||
class="w-full rounded-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-14 placeholder:text-[#617c89] p-[15px] text-base font-normal leading-normal"
|
||||
placeholder="email@email.com" type="email"/>
|
||||
@error('email') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-base font-medium leading-normal">Kata Sandi</label>
|
||||
<div class="flex w-full items-stretch rounded-lg group">
|
||||
<input name="password" id="password" required autocomplete="new-password"
|
||||
class="w-full rounded-l-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-14 placeholder:text-[#617c89] p-[15px] border-r-0 pr-2 text-base font-normal leading-normal"
|
||||
placeholder="Minimal 8 karakter" type="password"/>
|
||||
<div onclick="togglePass('password', 'eyeIcon1')" class="text-[#617c89] flex border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark items-center justify-center pr-[15px] rounded-r-lg border-l-0 cursor-pointer hover:text-primary transition-colors">
|
||||
<span class="material-symbols-outlined" id="eyeIcon1">visibility</span>
|
||||
</div>
|
||||
</div>
|
||||
@error('password') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label class="text-[#111618] dark:text-gray-200 text-base font-medium leading-normal">Konfirmasi Kata Sandi</label>
|
||||
<div class="flex w-full items-stretch rounded-lg group">
|
||||
<input name="password_confirmation" id="password_confirmation" required autocomplete="new-password"
|
||||
class="w-full rounded-l-lg text-[#111618] dark:text-white focus:outline-0 focus:ring-2 focus:ring-primary/20 border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark focus:border-primary h-14 placeholder:text-[#617c89] p-[15px] border-r-0 pr-2 text-base font-normal leading-normal"
|
||||
placeholder="Ulangi kata sandi" type="password"/>
|
||||
<div onclick="togglePass('password_confirmation', 'eyeIcon2')" class="text-[#617c89] flex border border-[#dbe2e6] dark:border-gray-700 bg-white dark:bg-background-dark items-center justify-center pr-[15px] rounded-r-lg border-l-0 cursor-pointer hover:text-primary transition-colors">
|
||||
<span class="material-symbols-outlined" id="eyeIcon2">visibility</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="w-full flex items-center justify-center rounded-lg h-14 bg-primary text-white text-base font-bold leading-normal tracking-[0.015em] hover:bg-primary/90 transition-all shadow-md active:scale-[0.98] mt-4">
|
||||
Daftar Sekarang
|
||||
</button>
|
||||
|
||||
<div class="mt-6 text-center border-t border-gray-100 dark:border-gray-800 pt-6">
|
||||
<p class="text-sm text-[#617c89] dark:text-gray-400">
|
||||
Sudah memiliki akun?
|
||||
<a href="{{ route('login') }}" class="text-primary font-bold hover:underline italic">
|
||||
Masuk di sini
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
function togglePass(inputId, iconId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const icon = document.getElementById(iconId);
|
||||
if (input.type === "password") {
|
||||
input.type = "text";
|
||||
icon.textContent = "visibility_off";
|
||||
} else {
|
||||
input.type = "password";
|
||||
icon.textContent = "visibility";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<x-guest-layout>
|
||||
<form method="POST" action="{{ route('password.store') }}" autocomplete="off">
|
||||
@csrf
|
||||
|
||||
<!-- Password Reset Token -->
|
||||
<input type="hidden" name="token" value="{{ $request->route('token') }}">
|
||||
|
||||
<!-- Email Address -->
|
||||
<div>
|
||||
<x-input-label for="email" :value="__('Email')" />
|
||||
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus autocomplete="username" />
|
||||
<x-input-error :messages="$errors->get('email')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password" :value="__('Password')" />
|
||||
<x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
|
||||
<x-input-error :messages="$errors->get('password')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password_confirmation" :value="__('Confirm Password')" />
|
||||
|
||||
<x-text-input id="password_confirmation" class="block mt-1 w-full"
|
||||
type="password"
|
||||
name="password_confirmation" required autocomplete="new-password" />
|
||||
|
||||
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<x-primary-button>
|
||||
{{ __('Reset Password') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-guest-layout>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<x-guest-layout>
|
||||
<div class="mb-4 text-sm text-gray-600">
|
||||
{{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }}
|
||||
</div>
|
||||
|
||||
@if (session('status') == 'verification-link-sent')
|
||||
<div class="mb-4 font-medium text-sm text-green-600">
|
||||
{{ __('A new verification link has been sent to the email address you provided during registration.') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mt-4 flex items-center justify-between">
|
||||
<form method="POST" action="{{ route('verification.send') }}">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<x-primary-button>
|
||||
{{ __('Resend Verification Email') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
|
||||
<button type="submit" class="underline text-sm text-gray-600 hover:text-gray-900 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
||||
{{ __('Log Out') }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</x-guest-layout>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<img src="/app_icon.png" {{ $attributes }} alt="Logo" />
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
@props(['status'])
|
||||
|
||||
@if ($status)
|
||||
<div {{ $attributes->merge(['class' => 'font-medium text-sm text-green-600']) }}>
|
||||
{{ $status }}
|
||||
</div>
|
||||
@endif
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<button {{ $attributes->merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-red-500 active:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition ease-in-out duration-150']) }}>
|
||||
{{ $slot }}
|
||||
</button>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a {{ $attributes->merge(['class' => 'block w-full px-4 py-2 text-start text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out']) }}>{{ $slot }}</a>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white'])
|
||||
|
||||
@php
|
||||
$alignmentClasses = match ($align) {
|
||||
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0',
|
||||
'top' => 'origin-top',
|
||||
default => 'ltr:origin-top-right rtl:origin-top-left end-0',
|
||||
};
|
||||
|
||||
$width = match ($width) {
|
||||
'48' => 'w-48',
|
||||
default => $width,
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @close.stop="open = false">
|
||||
<div @click="open = ! open">
|
||||
{{ $trigger }}
|
||||
</div>
|
||||
|
||||
<div x-show="open"
|
||||
x-transition:enter="transition ease-out duration-200"
|
||||
x-transition:enter-start="opacity-0 scale-95"
|
||||
x-transition:enter-end="opacity-100 scale-100"
|
||||
x-transition:leave="transition ease-in duration-75"
|
||||
x-transition:leave-start="opacity-100 scale-100"
|
||||
x-transition:leave-end="opacity-0 scale-95"
|
||||
class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-lg {{ $alignmentClasses }}"
|
||||
style="display: none;"
|
||||
@click="open = false">
|
||||
<div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}">
|
||||
{{ $content }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
@props(['messages'])
|
||||
|
||||
@if ($messages)
|
||||
<ul {{ $attributes->merge(['class' => 'text-sm text-red-600 space-y-1']) }}>
|
||||
@foreach ((array) $messages as $message)
|
||||
<li>{{ $message }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue