Jaga Jalan
This commit is contained in:
commit
b641245f3e
|
@ -0,0 +1,18 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
|
@ -0,0 +1,64 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_TIMEZONE=UTC
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
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_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=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,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,20 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
|
@ -0,0 +1,66 @@
|
|||
<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 may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||
|
||||
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)**
|
||||
- **[WebReinvent](https://webreinvent.com/)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Jump24](https://jump24.co.uk)**
|
||||
- **[Redberry](https://redberry.international/laravel/)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
- **[byte5](https://byte5.de)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
|
||||
## 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,103 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class SetupBroadcasting extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'setup:broadcasting';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Setup broadcasting configuration for real-time notifications';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Setting up broadcasting for real-time notifications...');
|
||||
|
||||
// 1. Update .env file
|
||||
$this->updateEnvFile();
|
||||
|
||||
// 2. Clear configuration cache
|
||||
$this->call('config:clear');
|
||||
|
||||
// 3. Clear application cache
|
||||
$this->call('cache:clear');
|
||||
|
||||
// 4. Publish vendor files if needed
|
||||
if ($this->confirm('Do you want to publish vendor files for Laravel Echo and Pusher?', true)) {
|
||||
$this->call('vendor:publish', ['--provider' => 'Laravel\Ui\UiServiceProvider']);
|
||||
}
|
||||
|
||||
$this->info('Broadcasting setup completed successfully!');
|
||||
$this->info('Remember to set your PUSHER_APP_ID, PUSHER_APP_SECRET in your .env file');
|
||||
$this->info('PUSHER_APP_KEY is already set as d82783da6b2fe32e1dec');
|
||||
$this->info('PUSHER_APP_CLUSTER is already set as ap1');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the .env file with broadcasting configuration
|
||||
*/
|
||||
protected function updateEnvFile()
|
||||
{
|
||||
$envPath = base_path('.env');
|
||||
|
||||
if (File::exists($envPath)) {
|
||||
$envContent = File::get($envPath);
|
||||
|
||||
// Check if broadcasting driver is already set
|
||||
if (strpos($envContent, 'BROADCAST_DRIVER=') === false) {
|
||||
$this->info('Adding BROADCAST_DRIVER to .env file');
|
||||
$envContent .= "\nBROADCAST_DRIVER=pusher\n";
|
||||
} else {
|
||||
$this->info('Updating BROADCAST_DRIVER in .env file');
|
||||
$envContent = preg_replace('/BROADCAST_DRIVER=(.*)/i', 'BROADCAST_DRIVER=pusher', $envContent);
|
||||
}
|
||||
|
||||
// Check if Pusher credentials are already set
|
||||
if (strpos($envContent, 'PUSHER_APP_KEY=') === false) {
|
||||
$this->info('Adding Pusher configuration to .env file');
|
||||
$envContent .= "PUSHER_APP_ID=\n";
|
||||
$envContent .= "PUSHER_APP_KEY=d82783da6b2fe32e1dec\n";
|
||||
$envContent .= "PUSHER_APP_SECRET=\n";
|
||||
$envContent .= "PUSHER_APP_CLUSTER=ap1\n";
|
||||
} else {
|
||||
$this->info('Updating Pusher configuration in .env file');
|
||||
$envContent = preg_replace('/PUSHER_APP_KEY=(.*)/i', 'PUSHER_APP_KEY=d82783da6b2fe32e1dec', $envContent);
|
||||
$envContent = preg_replace('/PUSHER_APP_CLUSTER=(.*)/i', 'PUSHER_APP_CLUSTER=ap1', $envContent);
|
||||
}
|
||||
|
||||
File::put($envPath, $envContent);
|
||||
$this->info('.env file has been updated.');
|
||||
} else {
|
||||
$this->error('.env file does not exist!');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Models\User;
|
||||
|
||||
class LaporanDibuat implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $laporan;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($laporan)
|
||||
{
|
||||
$this->laporan = $laporan;
|
||||
|
||||
// Send notification to all admins immediately
|
||||
$admins = \App\Models\User::where('tipe_pengguna', 'admin')
|
||||
->orWhere('tipe_pengguna', 'super admin')
|
||||
->get();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
// Trigger NewNotification event for each admin
|
||||
event(new NewNotification([
|
||||
'id' => uniqid(),
|
||||
'data' => [
|
||||
'message' => 'Laporan baru telah dibuat: ' . ($laporan->jenis_bencana ?? $laporan->jenis_rusak),
|
||||
'type' => isset($laporan->jenis_bencana) ? 'bencana' : 'jalan',
|
||||
'created_at' => now()->toIso8601String()
|
||||
],
|
||||
'notifiable_id' => $admin->id,
|
||||
'created_at' => now()
|
||||
], $admin->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
// Broadcast to public channel
|
||||
return new Channel('laporan-channel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data to broadcast.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastWith()
|
||||
{
|
||||
return [
|
||||
'laporan' => $this->laporan
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NewNotification implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $notification;
|
||||
public $userId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($notification, $userId)
|
||||
{
|
||||
$this->notification = $notification;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('notifications.' . $this->userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The event's broadcast name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function broadcastAs()
|
||||
{
|
||||
return 'notification.received';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class BencanaExport implements FromCollection, WithHeadings, WithMapping
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Pelapor',
|
||||
'Jenis Bencana',
|
||||
'Lokasi',
|
||||
'Status',
|
||||
'Tanggal',
|
||||
'Deskripsi'
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
static $index = 0;
|
||||
$index++;
|
||||
|
||||
return [
|
||||
$index,
|
||||
$row->pelapor,
|
||||
ucfirst($row->jenis_bencana),
|
||||
$row->lokasi,
|
||||
str_replace('_', ' ', ucfirst($row->status)),
|
||||
\Carbon\Carbon::parse($row->created_at)->format('d M Y H:i'),
|
||||
$row->deskripsi
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class JalanExport implements FromCollection, WithHeadings, WithMapping
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No',
|
||||
'Pelapor',
|
||||
'Jenis Kerusakan',
|
||||
'Lokasi',
|
||||
'Status',
|
||||
'Tanggal',
|
||||
'Deskripsi'
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
static $index = 0;
|
||||
$index++;
|
||||
|
||||
return [
|
||||
$index,
|
||||
$row->pelapor,
|
||||
ucfirst($row->jenis_rusak),
|
||||
$row->lokasi,
|
||||
str_replace('_', ' ', ucfirst($row->status)),
|
||||
\Carbon\Carbon::parse($row->created_at)->format('d M Y H:i'),
|
||||
$row->deskripsi
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
// use App\Models\Admin;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\User;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$currentAdmin = Auth::guard('admin')->user();
|
||||
// Ambil semua pengguna dengan tipe 'admin' dan 'super admin' dari tabel users
|
||||
$admins = User::whereIn('tipe_pengguna', ['admin', 'super admin'])->get();
|
||||
|
||||
// Tambahkan data untuk dropdown
|
||||
$instansiOptions = User::getInstansiOptions();
|
||||
$jabatanOptions = User::getJabatanOptions();
|
||||
|
||||
return view('admins.index', compact('admins', 'currentAdmin', 'instansiOptions', 'jabatanOptions'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('admins.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
// Cek apakah user adalah super admin
|
||||
if (Auth::guard('admin')->user()->tipe_pengguna !== 'super admin') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized. Hanya Super Admin yang dapat menambahkan admin baru.'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users,email',
|
||||
'password' => 'required|string|min:8',
|
||||
'alamat' => 'required|string',
|
||||
'tipe_pengguna' => 'required|in:admin,super admin',
|
||||
'instansi' => 'required|in:BPBD,PUPR',
|
||||
'jabatan' => 'required|string',
|
||||
], [
|
||||
'name.required' => 'Nama harus diisi',
|
||||
'email.required' => 'Email harus diisi',
|
||||
'email.email' => 'Format email tidak valid',
|
||||
'email.unique' => 'Email sudah digunakan',
|
||||
'password.required' => 'Password harus diisi',
|
||||
'password.min' => 'Password minimal 8 karakter',
|
||||
'alamat.required' => 'Alamat harus diisi',
|
||||
'tipe_pengguna.required' => 'Tipe pengguna harus diisi',
|
||||
'tipe_pengguna.in' => 'Tipe pengguna tidak valid',
|
||||
'instansi.required' => 'Instansi harus diisi',
|
||||
'instansi.in' => 'Instansi tidak valid',
|
||||
'jabatan.required' => 'Jabatan harus diisi',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Validasi jabatan sesuai dengan instansi
|
||||
$jabatanOptions = User::getJabatanOptions($request->instansi);
|
||||
if (!array_key_exists($request->jabatan, $jabatanOptions)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'errors' => ['jabatan' => ['Jabatan tidak valid untuk instansi yang dipilih']]
|
||||
], 422);
|
||||
}
|
||||
|
||||
$admin = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'alamat' => $request->alamat,
|
||||
'tipe_pengguna' => $request->tipe_pengguna,
|
||||
'instansi' => $request->instansi,
|
||||
'jabatan' => $request->jabatan,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Admin berhasil ditambahkan',
|
||||
'data' => $admin
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error saat menambah admin: ' . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(User $admin)
|
||||
{
|
||||
$currentAdmin = Auth::user();
|
||||
if ($admin->id === $currentAdmin->id) {
|
||||
return redirect()->route('admins.index')
|
||||
->with('error', 'Anda tidak dapat mengedit akun Anda sendiri di sini. Gunakan halaman profile.');
|
||||
}
|
||||
return view('admins.edit', compact('admin'));
|
||||
}
|
||||
|
||||
public function update(Request $request, User $admin)
|
||||
{
|
||||
$currentAdmin = Auth::user();
|
||||
if ($admin->id === $currentAdmin->id) {
|
||||
return redirect()->route('admins.index')
|
||||
->with('error', 'Anda tidak dapat mengedit akun Anda sendiri di sini. Gunakan halaman profile.');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:admins,email,' . $admin->id,
|
||||
'alamat' => 'required|string',
|
||||
]);
|
||||
|
||||
User::where('id', $admin->id)->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'alamat' => $request->alamat,
|
||||
]);
|
||||
|
||||
return redirect()->route('admins.index')
|
||||
->with('success', 'Admin berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
// Cek apakah user adalah super admin
|
||||
if (Auth::guard('admin')->user()->tipe_pengguna !== 'super admin') {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized. Hanya Super Admin yang dapat menghapus admin.'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$admin = User::findOrFail($id);
|
||||
|
||||
// Prevent deleting self
|
||||
if ($admin->id === Auth::guard('admin')->id()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Tidak dapat menghapus akun sendiri'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$admin->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Admin berhasil dihapus'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error saat menghapus admin: ' . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
// Tambahkan method untuk mendapatkan jabatan berdasarkan instansi (untuk AJAX)
|
||||
public function getJabatan(Request $request)
|
||||
{
|
||||
$instansi = $request->instansi;
|
||||
$jabatanOptions = User::getJabatanOptions($instansi);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $jabatanOptions
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\EmailVerification;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function register(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6',
|
||||
'alamat' => 'required|string'
|
||||
// 'telepon' => 'required|string'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Validation error',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
// Generate token dan log
|
||||
$verificationToken = Str::random(64);
|
||||
\Illuminate\Support\Facades\Log::info('Generated token: ' . $verificationToken);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'alamat' => $request->alamat,
|
||||
// 'telepon' => $request->telepon,
|
||||
'verification_token' => $verificationToken,
|
||||
'is_verified' => false,
|
||||
'tipe_pengguna' => 'user'
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('User created with email: ' . $user->email);
|
||||
\Illuminate\Support\Facades\Log::info('Stored token: ' . $user->verification_token);
|
||||
|
||||
// Generate URL verifikasi
|
||||
$verificationUrl = url("/api/verify-email/{$verificationToken}");
|
||||
$verificationUrl = str_replace('localhost', '10.10.178.83', $verificationUrl);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Generated verification URL: ' . $verificationUrl);
|
||||
|
||||
// Kirim email
|
||||
Mail::to($user->email)->send(new EmailVerification($user, $verificationUrl));
|
||||
\Illuminate\Support\Facades\Log::info('Verification email sent to: ' . $user->email);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Registrasi berhasil. Silakan cek email Anda untuk verifikasi.',
|
||||
], 201);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Registration error: ' . $e->getMessage());
|
||||
\Illuminate\Support\Facades\Log::error('Stack trace: ' . $e->getTraceAsString());
|
||||
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Gagal mengirim email verifikasi: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|string|min:6',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Validation error',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
$credentials = $request->only('email', 'password');
|
||||
|
||||
// Cek apakah email sudah diverifikasi
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if ($user && !$user->is_verified) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Email belum diverifikasi. Silakan cek email Anda untuk verifikasi.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
if (!$token = Auth::guard('api')->attempt($credentials)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Email atau password salah',
|
||||
], 401);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'user' => Auth::guard('api')->user(),
|
||||
'token' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
try {
|
||||
// Ambil token saat ini
|
||||
$token = JWTAuth::getToken();
|
||||
|
||||
// Invalidasi token saat ini
|
||||
JWTAuth::invalidate($token);
|
||||
|
||||
// Jika Anda menggunakan blacklist, Anda bisa menambahkan logika untuk menghapus semua token
|
||||
// Misalnya, jika Anda menyimpan token di database, Anda bisa menghapusnya di sini
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Successfully logged out',
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Logout failed: ' . $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function refresh()
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'user' => Auth::guard('api')->user(),
|
||||
'token' => JWTAuth::refresh()
|
||||
]);
|
||||
}
|
||||
|
||||
public function loginWithGoogle(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email',
|
||||
'name' => 'required|string',
|
||||
'google_id' => 'required|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Validation error',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
// Cek apakah user sudah ada
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user) {
|
||||
// Jika user belum ada, buat user baru
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make(Str::random(16)), // Password acak
|
||||
'google_id' => $request->google_id,
|
||||
'alamat' => 'Lumajang',
|
||||
'is_verified' => true, // Auto verifikasi untuk login Google
|
||||
'tipe_pengguna' => 'user'
|
||||
]);
|
||||
} else {
|
||||
// Jika user sudah ada, update google_id
|
||||
$user->update([
|
||||
'google_id' => $request->google_id,
|
||||
'is_verified' => true
|
||||
]);
|
||||
}
|
||||
|
||||
// Generate token JWT
|
||||
$token = JWTAuth::fromUser($user);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'user' => $user,
|
||||
'token' => $token,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Login with Google failed: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ResetPassword;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
public function sendResetLink(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|email|exists:users,email',
|
||||
], [
|
||||
'email.exists' => 'Email tidak terdaftar dalam sistem kami.'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Validation error',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
// Generate token
|
||||
$resetToken = Str::random(64);
|
||||
\Illuminate\Support\Facades\Log::info('Generated reset token: ' . $resetToken);
|
||||
|
||||
// Simpan token ke database
|
||||
$user = User::where('email', $request->email)->first();
|
||||
$user->reset_password_token = $resetToken;
|
||||
$user->reset_password_expires_at = now()->addHours(24); // Token berlaku 24 jam
|
||||
$user->save();
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Reset token stored for user: ' . $user->email);
|
||||
|
||||
// Buat URL web yang akan redirect ke aplikasi
|
||||
$resetUrl = route('password.reset.redirect', ['token' => $resetToken, 'email' => $user->email]);
|
||||
|
||||
// Log URL untuk debugging
|
||||
\Illuminate\Support\Facades\Log::info('Reset URL: ' . $resetUrl);
|
||||
|
||||
// Kirim email
|
||||
Mail::to($user->email)->send(new ResetPassword($user, $resetUrl));
|
||||
\Illuminate\Support\Facades\Log::info('Reset password email sent to: ' . $user->email);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Link reset password telah dikirim ke email Anda.',
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Reset password error: ' . $e->getMessage());
|
||||
\Illuminate\Support\Facades\Log::error('Stack trace: ' . $e->getTraceAsString());
|
||||
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Gagal mengirim email reset password: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'token' => 'required|string',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Validation error',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
// Cari user berdasarkan token
|
||||
$user = User::where('reset_password_token', $request->token)
|
||||
->where('reset_password_expires_at', '>', now())
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Token tidak valid atau sudah kadaluarsa.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Update password
|
||||
$user->password = Hash::make($request->password);
|
||||
$user->reset_password_token = null;
|
||||
$user->reset_password_expires_at = null;
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Password berhasil diperbarui. Silakan login dengan password baru Anda.'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Reset password error: ' . $e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Gagal memperbarui password: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use App\Models\User;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function showLoginForm()
|
||||
{
|
||||
if (Auth::check()) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'username_or_email' => 'required',
|
||||
'password' => 'required|string|min:8',
|
||||
]);
|
||||
|
||||
$loginField = filter_var($request->username_or_email, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
|
||||
|
||||
if (Auth::attempt([$loginField => $request->username_or_email, 'password' => $request->password])) {
|
||||
return redirect()->intended(route('dashboard'))
|
||||
->with('success', 'Selamat datang, ' . Auth::user()->name);
|
||||
}
|
||||
|
||||
return back()
|
||||
->withInput()
|
||||
->withErrors([
|
||||
'username_or_email' => 'Username/email atau password salah.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('login')
|
||||
->with('success', 'Anda telah berhasil logout.');
|
||||
}
|
||||
|
||||
public function showRegisterForm()
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'alamat' => 'required|string',
|
||||
'telepon' => 'required|string',
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'alamat' => $request->alamat,
|
||||
'telepon' => $request->telepon,
|
||||
'tipe_pengguna' => 'user',
|
||||
]);
|
||||
|
||||
return redirect()->route('login')
|
||||
->with('success', 'Registrasi berhasil. Silakan login.');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\LaporanJalan;
|
||||
use App\Models\LaporanBencana;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
// Data untuk KPI Cards
|
||||
$totalLaporanJalan = LaporanJalan::count();
|
||||
$totalLaporanBencana = LaporanBencana::count();
|
||||
$totalLaporan = $totalLaporanJalan + $totalLaporanBencana;
|
||||
|
||||
$menungguJalan = LaporanJalan::where('status', 'menunggu')->count();
|
||||
$menungguBencana = LaporanBencana::where('status', 'menunggu')->count();
|
||||
$menunggu = $menungguJalan + $menungguBencana;
|
||||
|
||||
$dalamProsesJalan = LaporanJalan::where('status', 'dalam_proses')->count();
|
||||
$dalamProsesBencana = LaporanBencana::where('status', 'dalam_proses')->count();
|
||||
$dalamProses = $dalamProsesJalan + $dalamProsesBencana;
|
||||
|
||||
$selesaiJalan = LaporanJalan::where('status', 'selesai')->count();
|
||||
$selesaiBencana = LaporanBencana::where('status', 'selesai')->count();
|
||||
$selesai = $selesaiJalan + $selesaiBencana;
|
||||
|
||||
// Persentase perubahan dari bulan lalu
|
||||
$laporanJalanBulanLalu = LaporanJalan::whereMonth('created_at', Carbon::now()->subMonth()->month)->count();
|
||||
$laporanBencanaBulanLalu = LaporanBencana::whereMonth('created_at', Carbon::now()->subMonth()->month)->count();
|
||||
|
||||
$persentaseKenaikanJalan = $laporanJalanBulanLalu > 0
|
||||
? round((($totalLaporanJalan - $laporanJalanBulanLalu) / $laporanJalanBulanLalu) * 100, 1)
|
||||
: 100;
|
||||
|
||||
$persentasePenurunanBencana = $laporanBencanaBulanLalu > 0
|
||||
? round((($totalLaporanBencana - $laporanBencanaBulanLalu) / $laporanBencanaBulanLalu) * 100, 1)
|
||||
: 0;
|
||||
|
||||
// Data untuk grafik statistik bulanan
|
||||
$monthlyData = [];
|
||||
for ($i = 5; $i >= 0; $i--) {
|
||||
$date = now()->subMonths($i);
|
||||
$month = $date->format('M Y');
|
||||
|
||||
$jalanCount = LaporanJalan::whereYear('created_at', $date->year)
|
||||
->whereMonth('created_at', $date->month)
|
||||
->count();
|
||||
|
||||
$bencanaCount = LaporanBencana::whereYear('created_at', $date->year)
|
||||
->whereMonth('created_at', $date->month)
|
||||
->count();
|
||||
|
||||
$monthlyData[] = [
|
||||
'bulan' => $month,
|
||||
'jalan' => $jalanCount,
|
||||
'bencana' => $bencanaCount
|
||||
];
|
||||
}
|
||||
|
||||
// Data untuk grafik distribusi jenis kerusakan
|
||||
$distribusiJalan = DB::table('laporan_jalan')
|
||||
->select('jenis_rusak', DB::raw('count(*) as total'))
|
||||
->groupBy('jenis_rusak')
|
||||
->get();
|
||||
|
||||
$distribusiBencana = DB::table('laporan_bencana')
|
||||
->select('jenis_bencana', DB::raw('count(*) as total'))
|
||||
->groupBy('jenis_bencana')
|
||||
->get();
|
||||
|
||||
return view('dashboard', compact(
|
||||
'totalLaporan',
|
||||
'totalLaporanJalan',
|
||||
'totalLaporanBencana',
|
||||
'menunggu',
|
||||
'menungguJalan',
|
||||
'menungguBencana',
|
||||
'dalamProses',
|
||||
'dalamProsesJalan',
|
||||
'dalamProsesBencana',
|
||||
'selesai',
|
||||
'selesaiJalan',
|
||||
'selesaiBencana',
|
||||
'persentaseKenaikanJalan',
|
||||
'persentasePenurunanBencana',
|
||||
'monthlyData',
|
||||
'distribusiJalan',
|
||||
'distribusiBencana'
|
||||
));
|
||||
} catch (\Exception $e) {
|
||||
return back()->with('error', 'Terjadi kesalahan saat memuat dashboard: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getLaporanJalan()
|
||||
{
|
||||
try {
|
||||
$laporanJalan = DB::table('laporan_jalan')
|
||||
->select('id', 'lokasi', 'latitude', 'longitude', 'jenis_rusak', 'deskripsi', 'foto', 'status')
|
||||
->where('status', 'dalam_proses')
|
||||
->get();
|
||||
|
||||
// Transform foto path menjadi URL lengkap
|
||||
$laporanJalan = $laporanJalan->map(function($item) {
|
||||
$item->foto_url = $item->foto ? asset('storage/' . $item->foto) : null;
|
||||
return $item;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $laporanJalan
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil data laporan jalan',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getLaporanBencana()
|
||||
{
|
||||
try {
|
||||
$laporanBencana = DB::table('laporan_bencana')
|
||||
->select('id', 'lokasi', 'latitude', 'longitude', 'jenis_bencana', 'deskripsi', 'foto', 'status')
|
||||
->where('status', 'dalam_proses')
|
||||
->get();
|
||||
|
||||
// Transform foto path menjadi URL lengkap
|
||||
$laporanBencana = $laporanBencana->map(function($item) {
|
||||
$item->foto_url = $item->foto ? asset('storage/' . $item->foto) : null;
|
||||
return $item;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $laporanBencana
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil data laporan bencana',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRiwayatLaporan()
|
||||
{
|
||||
try {
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get laporan bencana yang dilaporkan oleh pengguna
|
||||
$bencana = DB::table('laporan_bencana')
|
||||
->where('user_id', $user_id)
|
||||
->select('id', 'lokasi', 'latitude', 'longitude', 'jenis_bencana', 'deskripsi', 'foto', 'status', 'created_at')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get()
|
||||
->map(function($item) {
|
||||
$item->foto_url = $item->foto ? asset('storage/' . $item->foto) : null;
|
||||
return $item;
|
||||
});
|
||||
|
||||
// Get laporan jalan yang dilaporkan oleh pengguna
|
||||
$jalan = DB::table('laporan_jalan')
|
||||
->where('user_id', $user_id)
|
||||
->select('id', 'lokasi', 'latitude', 'longitude', 'jenis_rusak', 'deskripsi', 'foto', 'status', 'created_at')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get()
|
||||
->map(function($item) {
|
||||
$item->foto_url = $item->foto ? asset('storage/' . $item->foto) : null;
|
||||
return $item;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'bencana' => $bencana,
|
||||
'jalan' => $jalan
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil riwayat laporan',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\NewNotification;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ExampleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contoh cara membuat notifikasi baru yang akan dikirim secara real-time
|
||||
*/
|
||||
public function createSampleNotification()
|
||||
{
|
||||
$userId = Auth::id();
|
||||
|
||||
// Membuat notifikasi baru di database
|
||||
$notificationId = Str::uuid()->toString();
|
||||
DB::table('notifications')->insert([
|
||||
'id' => $notificationId,
|
||||
'type' => 'App\\Notifications\\SampleNotification',
|
||||
'notifiable_type' => 'App\\Models\\User',
|
||||
'notifiable_id' => $userId,
|
||||
'data' => json_encode([
|
||||
'message' => 'Ini adalah contoh notifikasi real-time',
|
||||
'type' => 'jalan',
|
||||
'created_at' => Carbon::now()->toIso8601String()
|
||||
]),
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
// Ambil notifikasi yang baru dibuat
|
||||
$notification = DB::table('notifications')->where('id', $notificationId)->first();
|
||||
|
||||
// Kirim event ke Pusher untuk pembaruan real-time
|
||||
event(new NewNotification($notification, $userId));
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Notifikasi berhasil dibuat']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\LaporanBencana;
|
||||
use App\Events\LaporanDibuat;
|
||||
use PDF;
|
||||
use App\Exports\BencanaExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class LaporanBencanaController extends Controller
|
||||
{
|
||||
public function pemetaan()
|
||||
{
|
||||
return view('laporanbencana');
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$laporanBencana = DB::table('laporan_bencana')
|
||||
->join('users', 'laporan_bencana.user_id', '=', 'users.id')
|
||||
->select('laporan_bencana.*', 'users.name as pelapor')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
return view('bencana.index', compact('laporanBencana'));
|
||||
}
|
||||
|
||||
public function getLaporanBencana()
|
||||
{
|
||||
$laporanBencana = DB::table('laporan_bencana')
|
||||
->select('latitude', 'longitude', 'status', 'jenis_bencana')
|
||||
->whereIn('status', ['menunggu', 'dalam_proses'])
|
||||
->get();
|
||||
|
||||
return response()->json($laporanBencana);
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, $id)
|
||||
{
|
||||
$status = $request->status;
|
||||
$allowed_status = ['menunggu', 'dalam_proses', 'selesai'];
|
||||
|
||||
if (!in_array($status, $allowed_status)) {
|
||||
return response()->json(['success' => false, 'message' => 'Status tidak valid']);
|
||||
}
|
||||
|
||||
try {
|
||||
DB::table('laporan_bencana')
|
||||
->where('id', $id)
|
||||
->update(['status' => $status]);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Gagal mengupdate status']);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$laporan = DB::table('laporan_bencana')->where('id', $id)->first();
|
||||
if ($laporan) {
|
||||
// Hapus file foto jika ada
|
||||
if ($laporan->foto) {
|
||||
$path = public_path('storage/' . $laporan->foto);
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
DB::table('laporan_bencana')->where('id', $id)->delete();
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
return response()->json(['success' => false]);
|
||||
}
|
||||
|
||||
private function checkLaporanLimit($userId)
|
||||
{
|
||||
// Jika user ID adalah 60, 61, atau 62, tidak ada batasan
|
||||
if (in_array($userId, [60, 61, 62])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hitung jumlah laporan hari ini
|
||||
$today = now()->startOfDay();
|
||||
$count = DB::table('laporan_bencana')
|
||||
->where('user_id', $userId)
|
||||
->where('created_at', '>=', $today)
|
||||
->count();
|
||||
|
||||
// Batasi 10 laporan per hari
|
||||
return $count < 10;
|
||||
}
|
||||
|
||||
private function isWithinLumajang($latitude, $longitude)
|
||||
{
|
||||
// Koordinat batas wilayah Lumajang
|
||||
$minLat = -8.5; // Batas selatan
|
||||
$maxLat = -7.8; // Batas utara
|
||||
$minLng = 112.8; // Batas barat
|
||||
$maxLng = 113.4; // Batas timur
|
||||
|
||||
return ($latitude >= $minLat && $latitude <= $maxLat) &&
|
||||
($longitude >= $minLng && $longitude <= $maxLng);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
// Validasi koordinat
|
||||
if (!$this->isWithinLumajang($request->latitude, $request->longitude)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Lokasi yang dipilih berada di luar wilayah Lumajang'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Cek batasan laporan
|
||||
if (!$this->checkLaporanLimit(Auth::id())) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Anda telah mencapai batas maksimal laporan hari ini (10 laporan)'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
'lokasi' => 'required|string',
|
||||
'latitude' => 'required|numeric',
|
||||
'longitude' => 'required|numeric',
|
||||
'jenis_bencana' => 'required|in:Banjir,Longsor,Erupsi,Lahar Panas,Lahar Dingin,Gempa,Angin Topan',
|
||||
'deskripsi' => 'nullable|string',
|
||||
'foto' => 'nullable|image|max:5120', // maksimal 5MB
|
||||
]);
|
||||
|
||||
// Upload foto
|
||||
$fotoPath = null;
|
||||
if ($request->hasFile('foto')) {
|
||||
$foto = $request->file('foto');
|
||||
$fileName = time() . '_' . $foto->getClientOriginalName();
|
||||
$fotoPath = $foto->storeAs('laporan-bencana', $fileName, 'public');
|
||||
}
|
||||
|
||||
// Simpan data ke database
|
||||
$laporan = LaporanBencana::create([
|
||||
'user_id' => Auth::id(), // Simpan ID pengguna yang sedang login
|
||||
'lokasi' => $request->lokasi,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'jenis_bencana' => $request->jenis_bencana,
|
||||
'deskripsi' => $request->deskripsi,
|
||||
'foto' => $fotoPath,
|
||||
'status' => 'menunggu',
|
||||
]);
|
||||
|
||||
// Kirim notifikasi ke semua admin
|
||||
$admins = \App\Models\User::where('tipe_pengguna', 'admin')->orWhere('tipe_pengguna', 'super admin')->get();
|
||||
foreach ($admins as $admin) {
|
||||
$admin->notify(new \App\Notifications\NewLaporanBencanaNotification($laporan));
|
||||
}
|
||||
|
||||
broadcast(new LaporanDibuat($laporan));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Laporan berhasil dikirim',
|
||||
'data' => [
|
||||
'id' => $laporan->id,
|
||||
'foto_url' => $fotoPath ? asset('storage/' . $fotoPath) : null
|
||||
]
|
||||
], 201);
|
||||
} catch (\Exception $e) {
|
||||
// Hapus foto jika upload gagal
|
||||
if (isset($fotoPath)) {
|
||||
Storage::disk('public')->delete($fotoPath);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengirim laporan',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function rekap($format)
|
||||
{
|
||||
$tahun = request('tahun');
|
||||
$bulan = request('bulan');
|
||||
|
||||
$query = DB::table('laporan_bencana')
|
||||
->join('users', 'laporan_bencana.user_id', '=', 'users.id')
|
||||
->select('laporan_bencana.*', 'users.name as pelapor');
|
||||
|
||||
if ($bulan) {
|
||||
$query->whereYear('laporan_bencana.created_at', $tahun)
|
||||
->whereMonth('laporan_bencana.created_at', $bulan);
|
||||
} else {
|
||||
$query->whereYear('laporan_bencana.created_at', $tahun);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
|
||||
if ($format === 'pdf') {
|
||||
$pdf = PDF::loadView('bencana.rekap', [
|
||||
'data' => $data,
|
||||
'tahun' => $tahun,
|
||||
'bulan' => $bulan
|
||||
]);
|
||||
|
||||
return $pdf->download('rekap-bencana-' . ($bulan ? $tahun . '-' . $bulan : $tahun) . '.pdf');
|
||||
} else {
|
||||
return Excel::download(new BencanaExport($data), 'rekap-bencana-' . ($bulan ? $tahun . '-' . $bulan : $tahun) . '.xlsx');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\LaporanJalan;
|
||||
use App\Events\LaporanDibuat;
|
||||
use PDF;
|
||||
use App\Exports\JalanExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class LaporanJalanController extends Controller
|
||||
{
|
||||
public function pemetaan()
|
||||
{
|
||||
return view('laporanjalan');
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$laporanJalan = DB::table('laporan_jalan')
|
||||
->join('users', 'laporan_jalan.user_id', '=', 'users.id')
|
||||
->select('laporan_jalan.*', 'users.name as pelapor')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
return view('jalan.index', compact('laporanJalan'));
|
||||
}
|
||||
|
||||
public function getLaporanJalan()
|
||||
{
|
||||
$laporanJalan = DB::table('laporan_jalan')
|
||||
->select('latitude', 'longitude', 'status', 'jenis_rusak')
|
||||
->whereIn('status', ['menunggu', 'dalam_proses'])
|
||||
->get();
|
||||
|
||||
return response()->json($laporanJalan);
|
||||
}
|
||||
|
||||
public function updateStatus(Request $request, $id)
|
||||
{
|
||||
$status = $request->status;
|
||||
$allowed_status = ['menunggu', 'dalam_proses', 'selesai'];
|
||||
|
||||
if (!in_array($status, $allowed_status)) {
|
||||
return response()->json(['success' => false, 'message' => 'Status tidak valid']);
|
||||
}
|
||||
|
||||
try {
|
||||
DB::table('laporan_jalan')
|
||||
->where('id', $id)
|
||||
->update(['status' => $status]);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Gagal mengupdate status']);
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$laporan = DB::table('laporan_jalan')->where('id', $id)->first();
|
||||
if ($laporan) {
|
||||
// Hapus file foto jika ada
|
||||
if ($laporan->foto) {
|
||||
$path = public_path('storage/' . $laporan->foto);
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
DB::table('laporan_jalan')->where('id', $id)->delete();
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
return response()->json(['success' => false]);
|
||||
}
|
||||
|
||||
private function checkLaporanLimit($userId)
|
||||
{
|
||||
// Jika user ID adalah 60, 61, atau 62, tidak ada batasan
|
||||
if (in_array($userId, [60, 61, 62])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hitung jumlah laporan hari ini
|
||||
$today = now()->startOfDay();
|
||||
$count = DB::table('laporan_jalan')
|
||||
->where('user_id', $userId)
|
||||
->where('created_at', '>=', $today)
|
||||
->count();
|
||||
|
||||
// Batasi 10 laporan per hari
|
||||
return $count < 10;
|
||||
}
|
||||
|
||||
private function isWithinLumajang($latitude, $longitude)
|
||||
{
|
||||
// Koordinat batas wilayah Lumajang
|
||||
$minLat = -8.5; // Batas selatan
|
||||
$maxLat = -7.8; // Batas utara
|
||||
$minLng = 112.8; // Batas barat
|
||||
$maxLng = 113.4; // Batas timur
|
||||
|
||||
return ($latitude >= $minLat && $latitude <= $maxLat) &&
|
||||
($longitude >= $minLng && $longitude <= $maxLng);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
// Validasi koordinat
|
||||
if (!$this->isWithinLumajang($request->latitude, $request->longitude)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Lokasi yang dipilih berada di luar wilayah Lumajang'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Cek batasan laporan
|
||||
if (!$this->checkLaporanLimit(Auth::id())) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Anda telah mencapai batas maksimal laporan hari ini (10 laporan)'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
'lokasi' => 'required|string',
|
||||
'latitude' => 'required|numeric',
|
||||
'longitude' => 'required|numeric',
|
||||
'jenis_rusak' => 'required|in:jalan rusak ringan,jalan rusak berat',
|
||||
'deskripsi' => 'nullable|string',
|
||||
'foto' => 'nullable|image|max:5120', // maksimal 5MB
|
||||
]);
|
||||
|
||||
// Upload foto
|
||||
$fotoPath = null;
|
||||
if ($request->hasFile('foto')) {
|
||||
$foto = $request->file('foto');
|
||||
$fileName = time() . '_' . $foto->getClientOriginalName();
|
||||
$fotoPath = $foto->storeAs('laporan-jalan', $fileName, 'public');
|
||||
}
|
||||
|
||||
// Simpan data ke database
|
||||
$laporan = LaporanJalan::create([
|
||||
'user_id' => Auth::id(),
|
||||
'lokasi' => $request->lokasi,
|
||||
'latitude' => $request->latitude,
|
||||
'longitude' => $request->longitude,
|
||||
'jenis_rusak' => $request->jenis_rusak,
|
||||
'deskripsi' => $request->deskripsi,
|
||||
'foto' => $fotoPath,
|
||||
'status' => 'menunggu',
|
||||
]);
|
||||
|
||||
// Kirim notifikasi ke semua admin
|
||||
$admins = \App\Models\User::where('tipe_pengguna', 'admin')->orWhere('tipe_pengguna', 'super admin')->get();
|
||||
foreach ($admins as $admin) {
|
||||
$admin->notify(new \App\Notifications\NewLaporanJalanNotification($laporan));
|
||||
}
|
||||
|
||||
broadcast(new LaporanDibuat($laporan));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Laporan berhasil dikirim',
|
||||
'data' => [
|
||||
'id' => $laporan->id,
|
||||
'foto_url' => $fotoPath ? asset('storage/' . $fotoPath) : null
|
||||
]
|
||||
], 201);
|
||||
} catch (\Exception $e) {
|
||||
// Hapus foto jika upload gagal
|
||||
if (isset($fotoPath)) {
|
||||
Storage::disk('public')->delete($fotoPath);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengirim laporan',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function rekap($format)
|
||||
{
|
||||
$tahun = request('tahun');
|
||||
$bulan = request('bulan');
|
||||
|
||||
$query = DB::table('laporan_jalan')
|
||||
->join('users', 'laporan_jalan.user_id', '=', 'users.id')
|
||||
->select('laporan_jalan.*', 'users.name as pelapor');
|
||||
|
||||
if ($bulan) {
|
||||
$query->whereYear('laporan_jalan.created_at', $tahun)
|
||||
->whereMonth('laporan_jalan.created_at', $bulan);
|
||||
} else {
|
||||
$query->whereYear('laporan_jalan.created_at', $tahun);
|
||||
}
|
||||
|
||||
$data = $query->get();
|
||||
|
||||
if ($format === 'pdf') {
|
||||
$pdf = PDF::loadView('jalan.rekap', [
|
||||
'data' => $data,
|
||||
'tahun' => $tahun,
|
||||
'bulan' => $bulan
|
||||
]);
|
||||
|
||||
return $pdf->download('rekap-jalan-' . ($bulan ? $tahun . '-' . $bulan : $tahun) . '.pdf');
|
||||
} else {
|
||||
return Excel::download(new JalanExport($data), 'rekap-jalan-' . ($bulan ? $tahun . '-' . $bulan : $tahun) . '.xlsx');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Events\NewNotification;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
public function getNotificationsCount()
|
||||
{
|
||||
$count = DB::table('notifications')
|
||||
->where('notifiable_id', Auth::id())
|
||||
->whereNull('read_at')
|
||||
->count();
|
||||
|
||||
return response()->json(['count' => $count]);
|
||||
}
|
||||
|
||||
public function deleteRead()
|
||||
{
|
||||
DB::table('notifications')
|
||||
->where('notifiable_id', Auth::id())
|
||||
->whereNotNull('read_at')
|
||||
->delete();
|
||||
|
||||
return response()->json(['message' => 'Notifikasi yang sudah dibaca berhasil dihapus']);
|
||||
}
|
||||
|
||||
public function markAsRead($id)
|
||||
{
|
||||
$notification = DB::table('notifications')->where('id', $id)->first();
|
||||
|
||||
if ($notification && $notification->notifiable_id == Auth::id()) {
|
||||
DB::table('notifications')
|
||||
->where('id', $id)
|
||||
->update(['read_at' => Carbon::now()]);
|
||||
|
||||
return response()->json(['message' => 'Notifikasi ditandai sebagai sudah dibaca']);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Notifikasi tidak ditemukan'], 404);
|
||||
}
|
||||
|
||||
public function markAllRead()
|
||||
{
|
||||
DB::table('notifications')
|
||||
->where('notifiable_id', Auth::id())
|
||||
->whereNull('read_at')
|
||||
->update(['read_at' => Carbon::now()]);
|
||||
|
||||
return response()->json(['message' => 'Semua notifikasi ditandai sebagai sudah dibaca']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PrivacyPolicyController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('privacy-policy');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
$user = JWTAuth::parseToken()->authenticate();
|
||||
|
||||
$user->update([
|
||||
'name' => $request->name,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Profil berhasil diperbarui',
|
||||
'data' => [
|
||||
'name' => $user->name
|
||||
]
|
||||
]);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenExpiredException $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token telah kadaluarsa'
|
||||
], 401);
|
||||
} catch (\Tymon\JWTAuth\Exceptions\TokenInvalidException $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token tidak valid'
|
||||
], 401);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal memperbarui profil',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
public function showResetForm($token)
|
||||
{
|
||||
try {
|
||||
\Illuminate\Support\Facades\Log::info('Received reset token: ' . $token);
|
||||
|
||||
$user = User::where('reset_password_token', $token)
|
||||
->where('reset_password_expires_at', '>', now())
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
\Illuminate\Support\Facades\Log::error('Token tidak ditemukan atau kadaluarsa: ' . $token);
|
||||
return view('reset_password.failed', [
|
||||
'message' => 'Link reset password tidak valid atau sudah kadaluarsa'
|
||||
]);
|
||||
}
|
||||
|
||||
return view('reset_password.form', [
|
||||
'token' => $token,
|
||||
'email' => $user->email
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Reset password error: ' . $e->getMessage());
|
||||
return view('reset_password.failed', [
|
||||
'message' => 'Terjadi kesalahan saat memproses reset password'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function reset(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'token' => 'required',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput();
|
||||
}
|
||||
|
||||
try {
|
||||
$user = User::where('reset_password_token', $request->token)
|
||||
->where('reset_password_expires_at', '>', now())
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
return view('reset_password.failed', [
|
||||
'message' => 'Link reset password tidak valid atau sudah kadaluarsa'
|
||||
]);
|
||||
}
|
||||
|
||||
$user->password = Hash::make($request->password);
|
||||
$user->reset_password_token = null;
|
||||
$user->reset_password_expires_at = null;
|
||||
$user->save();
|
||||
|
||||
return view('reset_password.success', [
|
||||
'message' => 'Password berhasil diperbarui. Silakan login dengan password baru Anda.'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Reset password error: ' . $e->getMessage());
|
||||
return view('reset_password.failed', [
|
||||
'message' => 'Terjadi kesalahan saat memproses reset password'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ResetPasswordRedirectController extends Controller
|
||||
{
|
||||
public function redirect($token, $email)
|
||||
{
|
||||
// Log untuk debugging
|
||||
\Illuminate\Support\Facades\Log::info("Redirecting to app with token: $token and email: $email");
|
||||
|
||||
// Buat URL deep link untuk aplikasi
|
||||
$appUrl = "jagajalan://reset-password?token={$token}&email={$email}";
|
||||
|
||||
return view('reset_password.redirect', [
|
||||
'appUrl' => $appUrl,
|
||||
'token' => $token,
|
||||
'email' => $email
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Models\Admin;
|
||||
use App\Models\User;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function profile()
|
||||
{
|
||||
$user = Auth::user();
|
||||
return view('profile.index', compact('user'));
|
||||
}
|
||||
|
||||
public function updateProfile(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:admins,email,' . $user->id,
|
||||
'alamat' => 'required|string',
|
||||
'telepon' => 'required|string',
|
||||
]);
|
||||
|
||||
Admin::where('id', $user->id)->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'alamat' => $request->alamat,
|
||||
'telepon' => $request->telepon,
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Profile berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'current_password' => 'required|string',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if (!Hash::check($request->current_password, $user->password)) {
|
||||
return back()->withErrors(['current_password' => 'Password saat ini tidak sesuai.']);
|
||||
}
|
||||
|
||||
Admin::where('id', $user->id)->update([
|
||||
'password' => Hash::make($request->password)
|
||||
]);
|
||||
|
||||
return back()->with('success', 'Password berhasil diperbarui.');
|
||||
}
|
||||
|
||||
// Admin management methods
|
||||
public function index()
|
||||
{
|
||||
$users = User::where('tipe_pengguna', 'user')->get();
|
||||
return view('users.index', compact('users'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('users.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:admins',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'alamat' => 'required|string',
|
||||
'telepon' => 'required|string',
|
||||
]);
|
||||
|
||||
Admin::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'alamat' => $request->alamat,
|
||||
'telepon' => $request->telepon,
|
||||
'tipe_pengguna' => 'user',
|
||||
]);
|
||||
|
||||
return redirect()->route('users.index')
|
||||
->with('success', 'User berhasil ditambahkan.');
|
||||
}
|
||||
|
||||
public function edit(Admin $user)
|
||||
{
|
||||
return view('users.edit', compact('user'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Admin $user)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:admins,email,' . $user->id,
|
||||
'alamat' => 'required|string',
|
||||
'telepon' => 'required|string',
|
||||
]);
|
||||
|
||||
Admin::where('id', $user->id)->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'alamat' => $request->alamat,
|
||||
'telepon' => $request->telepon,
|
||||
]);
|
||||
|
||||
return redirect()->route('users.index')
|
||||
->with('success', 'User berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
if ($user) {
|
||||
$user->delete();
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
return response()->json(['success' => false]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
public function verifyEmail($token)
|
||||
{
|
||||
try {
|
||||
\Illuminate\Support\Facades\Log::info('Received verification token: ' . $token);
|
||||
|
||||
$user = User::where('verification_token', $token)->first();
|
||||
|
||||
if (!$user) {
|
||||
\Illuminate\Support\Facades\Log::error('Token tidak ditemukan: ' . $token);
|
||||
return view('verification.failed', [
|
||||
'message' => 'Link verifikasi tidak valid atau sudah kadaluarsa'
|
||||
]);
|
||||
}
|
||||
|
||||
$user->is_verified = true;
|
||||
$user->email_verified_at = now();
|
||||
$user->verification_token = null;
|
||||
$user->save();
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Email berhasil diverifikasi: ' . $user->email);
|
||||
|
||||
return view('verification.success', [
|
||||
'name' => $user->name,
|
||||
'message' => 'Email berhasil diverifikasi'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Illuminate\Support\Facades\Log::error('Verification error: ' . $e->getMessage());
|
||||
return view('verification.failed', [
|
||||
'message' => 'Terjadi kesalahan saat verifikasi'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WeatherController extends Controller
|
||||
{
|
||||
private $apiKey;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->apiKey = config('services.weatherapi.key');
|
||||
}
|
||||
|
||||
public function getWeather(Request $request)
|
||||
{
|
||||
try {
|
||||
$lat = $request->query('lat');
|
||||
$lon = $request->query('lon');
|
||||
|
||||
Log::info('Weather request params:', [
|
||||
'lat' => $lat,
|
||||
'lon' => $lon
|
||||
]);
|
||||
|
||||
// Get weather data from WeatherAPI.com
|
||||
$response = Http::get("http://api.weatherapi.com/v1/forecast.json", [
|
||||
'key' => $this->apiKey,
|
||||
'q' => "$lat,$lon",
|
||||
'days' => 1,
|
||||
'aqi' => 'no',
|
||||
'lang' => 'id'
|
||||
]);
|
||||
|
||||
Log::info('WeatherAPI response:', [
|
||||
'status' => $response->status(),
|
||||
'body' => $response->body()
|
||||
]);
|
||||
|
||||
if (!$response->successful()) {
|
||||
throw new \Exception('Failed to fetch weather data: ' . $response->body());
|
||||
}
|
||||
|
||||
$weatherData = $response->json();
|
||||
$currentHour = now()->format('H');
|
||||
|
||||
// Get current weather from hourly forecast
|
||||
$currentWeather = collect($weatherData['forecast']['forecastday'][0]['hour'])
|
||||
->first(function($hour) use ($currentHour) {
|
||||
return date('H', strtotime($hour['time'])) == $currentHour;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'location' => [
|
||||
'name' => $weatherData['location']['name'],
|
||||
'state' => $weatherData['location']['region'],
|
||||
'country' => $weatherData['location']['country'],
|
||||
'lat' => $weatherData['location']['lat'],
|
||||
'lon' => $weatherData['location']['lon']
|
||||
],
|
||||
'current_weather' => [
|
||||
'datetime' => $currentWeather['time'],
|
||||
'temp' => round($currentWeather['temp_c']),
|
||||
'humidity' => $currentWeather['humidity'],
|
||||
'description' => $currentWeather['condition']['text'],
|
||||
'icon' => $currentWeather['condition']['icon'],
|
||||
],
|
||||
'weather' => array_map(function($hour) {
|
||||
return [
|
||||
'datetime' => $hour['time'],
|
||||
'temp' => round($hour['temp_c']),
|
||||
'humidity' => $hour['humidity'],
|
||||
'description' => $hour['condition']['text'],
|
||||
'icon' => $hour['condition']['icon'],
|
||||
];
|
||||
}, $weatherData['forecast']['forecastday'][0]['hour'])
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Weather API error:', [
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal mengambil data cuaca',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
\App\Http\Middleware\ApiMiddleware::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'admin' => \App\Http\Middleware\AdminMiddleware::class,
|
||||
'superadmin' => \App\Http\Middleware\SuperAdminMiddleware::class,
|
||||
'web' => \App\Http\Middleware\Authenticate::class,
|
||||
];
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AdminMiddleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
// Cek apakah pengguna terautentikasi
|
||||
if (Auth::guard('web')->check()) {
|
||||
$user = Auth::user();
|
||||
if ($user && $user->tipe_pengguna === 'admin') {
|
||||
return $next($request); // Izinkan akses jika terautentikasi dan tipe pengguna adalah admin
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu.'); // Arahkan ke halaman login jika tidak terautentikasi
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApiMiddleware
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
// Disable session and CSRF for API routes
|
||||
config(['session.driver' => 'array']);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
|
||||
protected function authenticate($request, array $guards)
|
||||
{
|
||||
\Illuminate\Support\Facades\Log::info('Auth Headers:', [
|
||||
'Authorization' => $request->header('Authorization'),
|
||||
'Accept' => $request->header('Accept')
|
||||
]);
|
||||
if (empty($guards)) {
|
||||
$guards = [null];
|
||||
}
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
return $this->auth->shouldUse($guard);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthenticationException(
|
||||
'Unauthenticated.', $guards
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\RedirectIfAuthenticated as Middleware;
|
||||
|
||||
class RedirectIfAuthenticated extends Middleware
|
||||
{
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SuperAdminMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
// Check if user is authenticated
|
||||
if (!Auth::guard('web')->check()) {
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized. Silakan login terlebih dahulu.'
|
||||
], 401);
|
||||
}
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
// Check if user is super admin
|
||||
$user = Auth::guard('web')->user();
|
||||
if ($user && $user->tipe_pengguna !== 'super admin') {
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthorized. Hanya Super Admin yang dapat mengakses fitur ini.'
|
||||
], 403);
|
||||
}
|
||||
return redirect()->route('dashboard')
|
||||
->with('error', 'Anda tidak memiliki akses ke halaman tersebut.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'api/*'
|
||||
];
|
||||
|
||||
// Custom logic jika diperlukan
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Outlet;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class OutletPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the outlet.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Outlet $outlet
|
||||
* @return mixed
|
||||
*/
|
||||
public function view(User $user, Outlet $outlet)
|
||||
{
|
||||
// Update user authorization to view the outlet here.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create an outlet.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
// Update user authorization to create an outlet here.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the outlet.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Outlet $outlet
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(User $user, Outlet $outlet)
|
||||
{
|
||||
// Update user authorization to update the outlet here.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the outlet.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Outlet $outlet
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(User $user, Outlet $outlet)
|
||||
{
|
||||
// Update user authorization to delete the outlet here.
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class EmailVerification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $user;
|
||||
public $verificationUrl;
|
||||
|
||||
public function __construct($user, $verificationUrl)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->verificationUrl = $verificationUrl;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$this->verificationUrl = route('email.verify', ['token' => $this->user->verification_token]);
|
||||
|
||||
return $this->view('emails.verification')
|
||||
->subject('Verifikasi Email Anda - Jaga Jalan');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ResetPassword extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $user;
|
||||
public $resetUrl;
|
||||
|
||||
public function __construct($user, $resetUrl)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->resetUrl = $resetUrl;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->view('emails.reset_password')
|
||||
->subject('Reset Password - Jaga Jalan');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class Admin extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, Notifiable;
|
||||
|
||||
protected $table = 'admins';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'alamat',
|
||||
'telepon',
|
||||
'tipe_pengguna',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->tipe_pengguna === 'admin';
|
||||
}
|
||||
|
||||
// Accessor untuk ID
|
||||
public function getIdAttribute()
|
||||
{
|
||||
return $this->attributes['id'];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class LaporanBencana extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'laporan_bencana';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'lokasi',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'jenis_bencana',
|
||||
'deskripsi',
|
||||
'foto',
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->belongsTo(Admin::class, 'user_id'); // Jika user_id bisa merujuk ke admin
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class LaporanJalan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'laporan_jalan';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'lokasi',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'alamat',
|
||||
'jenis_rusak',
|
||||
'deskripsi',
|
||||
'foto',
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Notifications\DatabaseNotification;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'alamat',
|
||||
'tipe_pengguna',
|
||||
'instansi',
|
||||
'jabatan',
|
||||
'is_verified',
|
||||
'verification_token',
|
||||
'updated_at',
|
||||
'role',
|
||||
'reset_password_token',
|
||||
'reset_password_expires_at'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->tipe_pengguna === 'admin' || $this->tipe_pengguna === 'super admin';
|
||||
}
|
||||
|
||||
public static function getJabatanOptions($instansi = null)
|
||||
{
|
||||
$jabatanOptions = [
|
||||
'BPBD' => [
|
||||
'Kepala Seksi Kedaruratan dan Logistik' => 'Bertanggung jawab atas penanganan darurat bencana.',
|
||||
'Operator Pusdalops (Pusat Pengendalian Operasi)' => 'Mengelola data dan sistem informasi kebencanaan.',
|
||||
'Staf Kedaruratan dan Rehabilitasi' => 'Memverifikasi laporan masyarakat terkait bencana.',
|
||||
'Koordinator Tim Reaksi Cepat (TRC)' => 'Menilai dan menindaklanjuti laporan yang masuk.'
|
||||
],
|
||||
'PUPR' => [
|
||||
'Kepala Bidang Bina Marga' => 'Bertanggung jawab atas pemeliharaan dan pembangunan jalan.',
|
||||
'Kepala Seksi Pemeliharaan Jalan dan Jembatan' => 'Menangani perbaikan jalan berlubang.',
|
||||
'Staf Pengawas Infrastruktur' => 'Mengevaluasi kondisi jalan berdasarkan laporan masyarakat.',
|
||||
'Operator GIS (Geographic Information System)' => 'Mengelola data berbasis peta (Leaflet.js).'
|
||||
]
|
||||
];
|
||||
|
||||
if ($instansi && isset($jabatanOptions[$instansi])) {
|
||||
return $jabatanOptions[$instansi];
|
||||
}
|
||||
|
||||
return $jabatanOptions;
|
||||
}
|
||||
|
||||
public static function getInstansiOptions()
|
||||
{
|
||||
return ['BPBD', 'PUPR'];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\DatabaseMessage;
|
||||
|
||||
class NewLaporanBencanaNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $laporan;
|
||||
|
||||
public function __construct($laporan)
|
||||
{
|
||||
$this->laporan = $laporan;
|
||||
}
|
||||
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable)
|
||||
{
|
||||
return [
|
||||
'message' => 'Laporan bencana baru: ' . ucfirst($this->laporan->jenis_bencana),
|
||||
'laporan_id' => $this->laporan->id,
|
||||
'lokasi' => $this->laporan->lokasi,
|
||||
'type' => 'bencana'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\DatabaseMessage;
|
||||
|
||||
class NewLaporanJalanNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $laporan;
|
||||
|
||||
public function __construct($laporan)
|
||||
{
|
||||
$this->laporan = $laporan;
|
||||
}
|
||||
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable)
|
||||
{
|
||||
return [
|
||||
'message' => 'Laporan jalan rusak baru: ' . ucfirst($this->laporan->jenis_rusak),
|
||||
'laporan_id' => $this->laporan->id,
|
||||
'lokasi' => $this->laporan->lokasi,
|
||||
'type' => 'jalan'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string|null>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
Auth::viaRequest('jwt', function ($request) {
|
||||
\Illuminate\Support\Facades\Log::info('JWT Auth Check', [
|
||||
'token' => $request->bearerToken(),
|
||||
'headers' => $request->headers->all()
|
||||
]);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes(['middleware' => ['web', 'auth']]);
|
||||
|
||||
// Channel untuk notifikasi pribadi - perhatikan nama channel harus sesuai dengan di JS
|
||||
// Pada Pusher, channel private akan otomatis ditambahkan prefix 'private-'
|
||||
Broadcast::channel('notifications.{userId}', function ($user, $userId) {
|
||||
return (int) $user->id === (int) $userId;
|
||||
});
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/dashboard';
|
||||
|
||||
protected $namespace = 'App\\Http\\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
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...
|
||||
$status = (require_once __DIR__.'/bootstrap/app.php')
|
||||
->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
|
@ -0,0 +1,19 @@
|
|||
<?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) {
|
||||
//
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
//
|
||||
})->create();
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
];
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"intervention/image": "*",
|
||||
"laravel/framework": "^11.9",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"pusher/pusher-php-server": "^7.2",
|
||||
"tymon/jwt-auth": "^2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pint": "^1.13",
|
||||
"laravel/sail": "^1.26",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.0",
|
||||
"phpunit/phpunit": "^11.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
]
|
||||
},
|
||||
"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' => env('APP_TIMEZONE', 'UTC'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,128 @@
|
|||
<?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' => 'admin',
|
||||
'passwords' => 'admins',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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',
|
||||
],
|
||||
'api' => [
|
||||
'driver' => 'jwt',
|
||||
'provider' => 'users',
|
||||
],
|
||||
'admin' => [
|
||||
'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' => App\Models\User::class,
|
||||
],
|
||||
'admins' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => 'password_reset_tokens',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
'admins' => [
|
||||
'provider' => 'users',
|
||||
'table' => 'password_reset_tokens',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', '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", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: http://cors.info
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => ['*'],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => true,
|
||||
];
|
|
@ -0,0 +1,170 @@
|
|||
<?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),
|
||||
],
|
||||
|
||||
'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([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,76 @@
|
|||
<?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'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => 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,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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,301 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT Authentication Secret
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Don't forget to set this in your .env file, as it will be used to sign
|
||||
| your tokens. A helper command is provided for this:
|
||||
| `php artisan jwt:secret`
|
||||
|
|
||||
| Note: This will be used for Symmetric algorithms only (HMAC),
|
||||
| since RSA and ECDSA use a private/public key combo (See below).
|
||||
|
|
||||
*/
|
||||
|
||||
'secret' => env('JWT_SECRET'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT Authentication Keys
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The algorithm you are using, will determine whether your tokens are
|
||||
| signed with a random string (defined in `JWT_SECRET`) or using the
|
||||
| following public & private keys.
|
||||
|
|
||||
| Symmetric Algorithms:
|
||||
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
||||
|
|
||||
| Asymmetric Algorithms:
|
||||
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
||||
|
|
||||
*/
|
||||
|
||||
'keys' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Public Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| A path or resource to your public key.
|
||||
|
|
||||
| E.g. 'file://path/to/public/key'
|
||||
|
|
||||
*/
|
||||
|
||||
'public' => env('JWT_PUBLIC_KEY'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Private Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| A path or resource to your private key.
|
||||
|
|
||||
| E.g. 'file://path/to/private/key'
|
||||
|
|
||||
*/
|
||||
|
||||
'private' => env('JWT_PRIVATE_KEY'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Passphrase
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The passphrase for your private key. Can be null if none set.
|
||||
|
|
||||
*/
|
||||
|
||||
'passphrase' => env('JWT_PASSPHRASE'),
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT time to live
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the length of time (in minutes) that the token will be valid for.
|
||||
| Defaults to 1 hour.
|
||||
|
|
||||
| You can also set this to null, to yield a never expiring token.
|
||||
| Some people may want this behaviour for e.g. a mobile app.
|
||||
| This is not particularly recommended, so make sure you have appropriate
|
||||
| systems in place to revoke the token if necessary.
|
||||
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
|
||||
|
|
||||
*/
|
||||
|
||||
'ttl' => env('JWT_TTL', 525600),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Refresh time to live
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the length of time (in minutes) that the token can be refreshed
|
||||
| within. I.E. The user can refresh their token within a 2 week window of
|
||||
| the original token being created until they must re-authenticate.
|
||||
| Defaults to 2 weeks.
|
||||
|
|
||||
| You can also set this to null, to yield an infinite refresh time.
|
||||
| Some may want this instead of never expiring tokens for e.g. a mobile app.
|
||||
| This is not particularly recommended, so make sure you have appropriate
|
||||
| systems in place to revoke the token if necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT hashing algorithm
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the hashing algorithm that will be used to sign the token.
|
||||
|
|
||||
*/
|
||||
|
||||
'algo' => env('JWT_ALGO', Tymon\JWTAuth\Providers\JWT\Provider::ALGO_HS256),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Required Claims
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the required claims that must exist in any token.
|
||||
| A TokenInvalidException will be thrown if any of these claims are not
|
||||
| present in the payload.
|
||||
|
|
||||
*/
|
||||
|
||||
'required_claims' => [
|
||||
'iss',
|
||||
'iat',
|
||||
'exp',
|
||||
'nbf',
|
||||
'sub',
|
||||
'jti',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Persistent Claims
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the claim keys to be persisted when refreshing a token.
|
||||
| `sub` and `iat` will automatically be persisted, in
|
||||
| addition to the these claims.
|
||||
|
|
||||
| Note: If a claim does not exist then it will be ignored.
|
||||
|
|
||||
*/
|
||||
|
||||
'persistent_claims' => [
|
||||
// 'foo',
|
||||
// 'bar',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Lock Subject
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This will determine whether a `prv` claim is automatically added to
|
||||
| the token. The purpose of this is to ensure that if you have multiple
|
||||
| authentication models e.g. `App\User` & `App\OtherPerson`, then we
|
||||
| should prevent one authentication request from impersonating another,
|
||||
| if 2 tokens happen to have the same id across the 2 different models.
|
||||
|
|
||||
| Under specific circumstances, you may want to disable this behaviour
|
||||
| e.g. if you only have one authentication model, then you would save
|
||||
| a little on token size.
|
||||
|
|
||||
*/
|
||||
|
||||
'lock_subject' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Leeway
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This property gives the jwt timestamp claims some "leeway".
|
||||
| Meaning that if you have any unavoidable slight clock skew on
|
||||
| any of your servers then this will afford you some level of cushioning.
|
||||
|
|
||||
| This applies to the claims `iat`, `nbf` and `exp`.
|
||||
|
|
||||
| Specify in seconds - only if you know you need it.
|
||||
|
|
||||
*/
|
||||
|
||||
'leeway' => env('JWT_LEEWAY', 0),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Blacklist Enabled
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| In order to invalidate tokens, you must have the blacklist enabled.
|
||||
| If you do not want or need this functionality, then set this to false.
|
||||
|
|
||||
*/
|
||||
|
||||
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------------
|
||||
| Blacklist Grace Period
|
||||
| -------------------------------------------------------------------------
|
||||
|
|
||||
| When multiple concurrent requests are made with the same JWT,
|
||||
| it is possible that some of them fail, due to token regeneration
|
||||
| on every request.
|
||||
|
|
||||
| Set grace period in seconds to prevent parallel request failure.
|
||||
|
|
||||
*/
|
||||
|
||||
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cookies encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default Laravel encrypt cookies for security reason.
|
||||
| If you decide to not decrypt cookies, you will have to configure Laravel
|
||||
| to not encrypt your cookie token by adding its name into the $except
|
||||
| array available in the middleware "EncryptCookies" provided by Laravel.
|
||||
| see https://laravel.com/docs/master/responses#cookies-and-encryption
|
||||
| for details.
|
||||
|
|
||||
| Set it to true if you want to decrypt cookies.
|
||||
|
|
||||
*/
|
||||
|
||||
'decrypt_cookies' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the various providers used throughout the package.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JWT Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to create and decode the tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to authenticate users.
|
||||
|
|
||||
*/
|
||||
|
||||
'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Storage Provider
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify the provider that is used to store tokens in the blacklist.
|
||||
|
|
||||
*/
|
||||
|
||||
'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,
|
||||
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'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,116 @@
|
|||
<?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',
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
|
@ -0,0 +1,83 @@
|
|||
<?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,localhost:8000,127.0.0.1,127.0.0.1:8000,::1,10.10.177.252,10.10.177.252:8000,127.0.0.1,192.168.1.15,192.168.1.15:8000',
|
||||
env('APP_URL') ? ',' . parse_url(env('APP_URL'), PHP_URL_HOST) : ''
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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,42 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_KEY'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
'weatherapi' => [
|
||||
'key' => env('WEATHERAPI_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", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Admin;
|
||||
use App\Models\Outlet;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
Outlet::factory()->define(function (Faker $faker) {
|
||||
$mapCenterLatitude = config('leaflet.map_center_latitude');
|
||||
$mapCenterLongitude = config('leaflet.map_center_longitude');
|
||||
$minLatitude = $mapCenterLatitude - 0.05;
|
||||
$maxLatitude = $mapCenterLatitude + 0.05;
|
||||
$minLongitude = $mapCenterLongitude - 0.07;
|
||||
$maxLongitude = $mapCenterLongitude + 0.07;
|
||||
|
||||
return [
|
||||
'name' => ucwords($faker->words(2, true)),
|
||||
'address' => $faker->address,
|
||||
'latitude' => $faker->latitude($minLatitude, $maxLatitude),
|
||||
'longitude' => $faker->longitude($minLongitude, $maxLongitude),
|
||||
'creator_id' => Admin::factory(), // Membuat data Admin baru dan mendapatkan ID-nya
|
||||
];
|
||||
});
|
|
@ -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,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,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('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->text('alamat');
|
||||
$table->string('telepon');
|
||||
$table->enum('tipe_pengguna', ['admin', 'super admin'])->default('admin');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,38 @@
|
|||
<?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->enum('tipe_pengguna', ['user', 'admin', 'super admin'])->default('user');
|
||||
$table->string('instansi')->nullable();
|
||||
$table->string('jabatan')->nullable();
|
||||
$table->string('alamat');
|
||||
$table->string('verification_token')->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->boolean('is_verified')->default(false);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJenisBencanaTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jenis_bencana', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jenis_bencana');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateLaporanJalanTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('laporan_jalan', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('lokasi');
|
||||
$table->double('latitude');
|
||||
$table->double('longitude');
|
||||
$table->enum('jenis_rusak', ['jalan rusak ringan', 'jalan rusak berat']);
|
||||
$table->text('deskripsi')->nullable();
|
||||
$table->string('foto')->nullable();
|
||||
$table->enum('status', ['menunggu', 'dalam_proses', 'selesai'])->default('menunggu');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('laporan_jalan');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateLaporanBencanaTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('laporan_bencana', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('lokasi');
|
||||
$table->double('latitude');
|
||||
$table->double('longitude');
|
||||
$table->enum('jenis_bencana', [
|
||||
'Banjir',
|
||||
'Longsor',
|
||||
'Erupsi',
|
||||
'Lahar Panas',
|
||||
'Lahar Dingin',
|
||||
'Gempa',
|
||||
'Angin Topan'
|
||||
]);
|
||||
$table->text('deskripsi')->nullable();
|
||||
$table->string('foto')->nullable();
|
||||
$table->enum('status', ['menunggu', 'dalam_proses', 'selesai'])->default('menunggu');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('laporan_bencana');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?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('admins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('alamat');
|
||||
$table->string('telepon');
|
||||
$table->enum('tipe_pengguna', ['super admin', 'admin'])->default('admin');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('admins');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('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('sessions');
|
||||
}
|
||||
};
|
|
@ -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->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
|
@ -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->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
|
@ -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->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddEmailVerificationToUsersTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('verification_token')->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->boolean('is_verified')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['verification_token', 'email_verified_at', 'is_verified']);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddResetPasswordFieldsToUsersTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('reset_password_token')->nullable();
|
||||
$table->timestamp('reset_password_expires_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['reset_password_token', 'reset_password_expires_at']);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AdminSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Admin::create([
|
||||
'name' => 'Super Admin',
|
||||
'email' => 'admin@admin.com',
|
||||
'password' => Hash::make('admin123'),
|
||||
'alamat' => 'Alamat Admin',
|
||||
'telepon' => '08123456789',
|
||||
'tipe_pengguna' => 'admin',
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
UserSeeder::class,
|
||||
AdminSeeder::class,
|
||||
JenisBencanaSeeder::class,
|
||||
LaporanJalanSeeder::class,
|
||||
LaporanBencanaSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class JenisBencanaSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$jenisBencana = [
|
||||
['nama' => 'Banjir'],
|
||||
['nama' => 'Longsor'],
|
||||
['nama' => 'Erupsi'],
|
||||
['nama' => 'Lahar Panas'],
|
||||
['nama' => 'Lahar Dingin'],
|
||||
['nama' => 'Gempa'],
|
||||
['nama' => 'Angin Topan'],
|
||||
];
|
||||
|
||||
foreach ($jenisBencana as $jenis) {
|
||||
DB::table('jenis_bencana')->insert([
|
||||
'nama' => $jenis['nama'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\LaporanBencana;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LaporanBencanaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
LaporanBencana::create([
|
||||
'user_id' => 60,
|
||||
'lokasi' => 'Lat: -8.238508511114578, Lng: 113.14954286455946',
|
||||
'latitude' => -8.238508511114578,
|
||||
'longitude' => 113.14954286455946,
|
||||
'jenis_bencana' => 'Angin Topan',
|
||||
'status' => 'selesai',
|
||||
'created_at' => Carbon::parse('2024-10-08'),
|
||||
'updated_at' => Carbon::parse('2024-10-08'),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LaporanJalanSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Hapus data yang ada di tabel laporan_jalan saja
|
||||
DB::table('laporan_jalan')->truncate();
|
||||
|
||||
$data = [
|
||||
[-8.2053897448152, 113.17503656814328, 'jalan rusak berat'],
|
||||
[-8.20531946878947, 113.17486996814337, 'jalan rusak ringan'],
|
||||
[-8.20518307371403, 113.1746476681434, 'jalan rusak ringan'],
|
||||
[-8.2049796066537, 113.17374365280199, 'jalan rusak berat'],
|
||||
[-8.19928369600686, 113.16667945280189, 'jalan rusak berat'],
|
||||
[-8.20372255789147, 113.17254747834295, 'jalan rusak ringan'],
|
||||
[-8.19958558703847, 113.16727206307439, 'jalan rusak berat'],
|
||||
[-8.19804788185248, 113.16478497173593, 'jalan rusak ringan'],
|
||||
[-8.1975984634749, 113.16421648526139, 'jalan rusak berat'],
|
||||
[-8.19665386682485, 113.16291014435866, 'jalan rusak berat'],
|
||||
[-8.19604539761673, 113.16205990727133, 'jalan rusak berat'],
|
||||
[-8.19596197838114, 113.16196819074281, 'jalan rusak berat'],
|
||||
[-8.19349754154608, 113.15790825213077, 'jalan rusak berat'],
|
||||
[-8.19270764937709, 113.15731441842738, 'jalan rusak berat'],
|
||||
[-8.1924730046386, 113.1574317768654, 'jalan rusak berat'],
|
||||
[-8.19173189805958, 113.15787069741772, 'jalan rusak berat'],
|
||||
[-8.19173189805958, 113.15787069741772, 'jalan rusak ringan'],
|
||||
[-8.19173189805958, 113.15787069741772, 'jalan rusak berat'],
|
||||
[-8.1844933255441, 113.15410243532753, 'jalan rusak berat'],
|
||||
[-8.18182621124981, 113.15457891061641, 'jalan rusak berat'],
|
||||
[-8.1837075869878, 113.15414705722526, 'jalan rusak ringan'],
|
||||
[-8.20802787237037, 113.17600509980660, 'jalan rusak ringan'],
|
||||
[-8.20911162867179, 113.17780845971807, 'jalan rusak ringan'],
|
||||
[-8.20947345171917, 113.17782159538099, 'jalan rusak ringan'],
|
||||
[-8.20949084571963, 113.17782159537950, 'jalan rusak ringan'],
|
||||
[-8.20991171773960, 113.17783313812822, 'jalan rusak ringan'],
|
||||
[-8.21171397495305, 113.18258920081308, 'jalan rusak ringan'],
|
||||
[-8.21174370488054, 113.18279140966845, 'jalan rusak ringan'],
|
||||
[-8.21177168960574, 113.18300309646767, 'jalan rusak berat'],
|
||||
[-8.212423443922, 113.18512663270613, 'jalan rusak ringan'],
|
||||
[-8.212806409903934, 113.18587999177089, 'jalan rusak berat'],
|
||||
[-8.213057385123594, 113.18642874383065, 'jalan rusak ringan'],
|
||||
[-8.213206223363539, 113.18698364610107, 'jalan rusak berat'],
|
||||
|
||||
];
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
foreach ($data as $item) {
|
||||
DB::table('laporan_jalan')->insert([
|
||||
'user_id' => 61,
|
||||
'lokasi' => "Lat: {$item[0]}, Lng: {$item[1]}",
|
||||
'latitude' => $item[0],
|
||||
'longitude' => $item[1],
|
||||
'jenis_rusak' => $item[2],
|
||||
'deskripsi' => null,
|
||||
'foto' => null,
|
||||
'status' => 'dalam_proses',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Menghapus semua data pengguna sebelumnya
|
||||
User::query()->delete();
|
||||
|
||||
// Menambahkan data admin
|
||||
User::create([
|
||||
'name' => 'Admin BPBD',
|
||||
'email' => 'admin1@gmail.com',
|
||||
'password' => Hash::make('admin123'),
|
||||
'alamat' => 'Alamat Admin 1',
|
||||
'tipe_pengguna' => 'admin',
|
||||
'instansi' => 'BPBD',
|
||||
'jabatan' => 'Kepala Seksi Kedaruratan dan Logistik',
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => 'Admin PUPR',
|
||||
'email' => 'admin2@gmail.com',
|
||||
'password' => Hash::make('admin123'),
|
||||
'alamat' => 'Alamat Admin 2',
|
||||
'tipe_pengguna' => 'admin',
|
||||
'instansi' => 'PUPR',
|
||||
'jabatan' => 'Kepala Bidang Bina Marga',
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => 'Super Admin',
|
||||
'email' => 'superadmin@gmail.com',
|
||||
'password' => Hash::make('superadmin123'),
|
||||
'alamat' => 'Alamat Super Admin',
|
||||
'tipe_pengguna' => 'super admin',
|
||||
'instansi' => 'BPBD',
|
||||
'jabatan' => 'Koordinator Tim Reaksi Cepat (TRC)',
|
||||
]);
|
||||
|
||||
// Menambahkan data pengguna biasa
|
||||
$users = [
|
||||
['name' => 'Ahmad Fauzi', 'email' => 'ahmad.fauzi87@gmail.com', 'alamat' => 'Jl. Gajah Mada No. 23, Lumajang'],
|
||||
['name' => 'Siti Rohmah Wati', 'email' => 'siti.rohmah1992@gmail.com', 'alamat' => 'Perumahan Sukodono Indah Blok C-5, Lumajang'],
|
||||
['name' => 'Budi Santoso', 'email' => 'budi.s@gmail.com', 'alamat' => 'Dusun Krajan RT 03/RW 02, Tempeh'],
|
||||
['name' => 'Dewi Lestari', 'email' => 'dewilestari_90@gmail.com', 'alamat' => 'Jl. Ahmad Yani Km 3, Pasirian'],
|
||||
['name' => 'Eko Prasetyo Nugroho', 'email' => 'eko.pras78@gmail.com', 'alamat' => 'Perum Griya Asri Blok D-12, Kunir'],
|
||||
['name' => 'Fitri Handayani', 'email' => 'fitri.h@gmail.com', 'alamat' => 'Jl. Raya Randuagung No. 45, Randuagung'],
|
||||
['name' => 'Gunawan Saputra', 'email' => 'gunawan_s@gmail.com', 'alamat' => 'Desa Tunjung RT 05/RW 01, Yosowilangun'],
|
||||
['name' => 'Hesti Wahyuni Putri', 'email' => 'hestiwahyuni1995@gmail.com', 'alamat' => 'Jl. Pahlawan No. 17, Pasrujambe'],
|
||||
['name' => 'Indra Wijaya', 'email' => 'indra.wijaya85@gmail.com', 'alamat' => 'Perumahan Senduro Asri Blok F-7, Senduro'],
|
||||
['name' => 'Joko Susilo', 'email' => 'joko_s@gmail.com', 'alamat' => 'Dusun Sumbersari RT 02/RW 03, Candipuro'],
|
||||
['name' => 'Kartika Dewi Anggraini', 'email' => 'kartika.d@gmail.com', 'alamat' => 'Jl. Veteran No. 32, Tekung'],
|
||||
['name' => 'Lukman Hakim', 'email' => 'lukman.h1989@gmail.com', 'alamat' => 'Jl. Wijaya Kusuma Gang 3 No. 12, Padang'],
|
||||
['name' => 'Maria Ulfa Rahmawati', 'email' => 'maria_ulfa@gmail.com', 'alamat' => 'Perum Griya Sukodono Blok A-9, Sukodono'],
|
||||
['name' => 'Nugroho Prabowo', 'email' => 'nugroho.p@gmail.com', 'alamat' => 'Desa Wonorejo RT 04/RW 02, Gucialit'],
|
||||
['name' => 'Okta Sari', 'email' => 'okta.sari93@gmail.com', 'alamat' => 'Jl. Kenanga No. 7, Jatiroto'],
|
||||
['name' => 'Prasetya Adi Nugraha', 'email' => 'prasetya_adi@gmail.com', 'alamat' => 'Dusun Karangsari RT 01/RW 04, Tempursari'],
|
||||
['name' => 'Qorina Setiawati', 'email' => 'qorina.s@gmail.com', 'alamat' => 'Jl. Sumberwuluh Gang Mawar No. 3, Pronojiwo'],
|
||||
['name' => 'Rizky Ramadhan Saputra', 'email' => 'rizky.r1994@gmail.com', 'alamat' => 'Perum Griya Ranuyoso Blok B-15, Ranuyoso'],
|
||||
['name' => 'Sulastri Handayani', 'email' => 'sulastri_h@gmail.com', 'alamat' => 'Jl. Anggrek No. 21, Klakah'],
|
||||
['name' => 'Teguh Wicaksono', 'email' => 'teguh.w88@gmail.com', 'alamat' => 'Desa Kalipepe RT 03/RW 01, Rowokangkung'],
|
||||
['name' => 'Umi Salamah Hidayati', 'email' => 'umi.salamah91@gmail.com', 'alamat' => 'Jl. Mawar No. 9, Kedungjajang'],
|
||||
['name' => 'Vina Melati', 'email' => 'vina_melati@gmail.com', 'alamat' => 'Perumahan Kunir Indah Blok G-3, Kunir'],
|
||||
['name' => 'Wahyudi Syahputra Pratama', 'email' => 'wahyudi.s@gmail.com', 'alamat' => 'Jl. Duren No. 15, Lumajang'],
|
||||
['name' => 'Xaverius Angga', 'email' => 'xave.angga90@gmail.com', 'alamat' => 'Perum Tempeh Permai Blok C-8, Tempeh'],
|
||||
];
|
||||
|
||||
foreach ($users as $user) {
|
||||
User::create([
|
||||
'name' => $user['name'],
|
||||
'email' => $user['email'],
|
||||
'password' => Hash::make('password123'),
|
||||
'alamat' => $user['alamat'],
|
||||
'tipe_pengguna' => 'user',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.6.4",
|
||||
"laravel-vite-plugin": "^1.0",
|
||||
"vite": "^5.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
||||
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
|
@ -0,0 +1,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}]
|
||||
|
||||
# Ensure the request is not for an existing file or directory
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
|
||||
# Redirect all requests to index.php
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
|
||||
# Allow CORS (Opsional, jika API diakses dari domain lain)
|
||||
<IfModule mod_headers.c>
|
||||
Header Set Access-Control-Allow-Origin "*"
|
||||
Header Set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
Header Set Access-Control-Allow-Headers "Content-Type, Authorization"
|
||||
</IfModule>
|
||||
</IfModule>
|
Binary file not shown.
After Width: | Height: | Size: 809 KiB |
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue