Initial commit: Sistem Informasi Klinik Sahabat Keluarga
This commit is contained in:
commit
1dc1b37409
|
|
@ -0,0 +1,18 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
CHANGELOG.md export-ignore
|
||||
README.md export-ignore
|
||||
.github/workflows/browser-tests.yml export-ignore
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
name: linter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- main
|
||||
- master
|
||||
- workos
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
- main
|
||||
- master
|
||||
- workos
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
environment: Testing
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
|
||||
- name: Add Flux Credentials Loaded From ENV
|
||||
run: composer config http-basic.composer.fluxui.dev "${{ secrets.FLUX_USERNAME }}" "${{ secrets.FLUX_LICENSE_KEY }}"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||
npm install
|
||||
|
||||
- name: Run Pint
|
||||
run: composer lint
|
||||
|
||||
# - name: Commit Changes
|
||||
# uses: stefanzweifel/git-auto-commit-action@v7
|
||||
# with:
|
||||
# commit_message: fix code style
|
||||
# commit_options: '--no-verify'
|
||||
# file_pattern: |
|
||||
# **/*
|
||||
# !.github/workflows/*
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
name: tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- main
|
||||
- master
|
||||
- workos
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
- main
|
||||
- master
|
||||
- workos
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
environment: Testing
|
||||
strategy:
|
||||
matrix:
|
||||
php-version: ['8.4', '8.5']
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
tools: composer:v2
|
||||
coverage: xdebug
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Install Node Dependencies
|
||||
run: npm i
|
||||
|
||||
- name: Add Flux Credentials Loaded From ENV
|
||||
run: composer config http-basic.composer.fluxui.dev "${{ secrets.FLUX_USERNAME }}" "${{ secrets.FLUX_LICENSE_KEY }}"
|
||||
|
||||
- name: Install Dependencies
|
||||
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Copy Environment File
|
||||
run: cp .env.example .env
|
||||
|
||||
- name: Generate Application Key
|
||||
run: php artisan key:generate
|
||||
|
||||
- name: Build Assets
|
||||
run: npm run build
|
||||
|
||||
- name: Run Tests
|
||||
run: ./vendor/bin/phpunit
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/auth.json
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.vscode
|
||||
/.zed
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
# Jika request belum mengarah ke folder public, arahkan ke public
|
||||
RewriteCond %{REQUEST_URI} !^/public/
|
||||
RewriteRule ^(.*)$ public/$1 [L]
|
||||
</IfModule>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use App\Concerns\ProfileValidationRules;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
|
||||
class CreateNewUser implements CreatesNewUsers
|
||||
{
|
||||
use PasswordValidationRules, ProfileValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and create a newly registered user.
|
||||
*
|
||||
* @param array<string, string> $input
|
||||
*/
|
||||
public function create(array $input): User
|
||||
{
|
||||
Validator::make($input, [
|
||||
...$this->profileRules(),
|
||||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
return User::create([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'password' => $input['password'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
||||
|
||||
class ResetUserPassword implements ResetsUserPasswords
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
/**
|
||||
* Validate and reset the user's forgotten password.
|
||||
*
|
||||
* @param array<string, string> $input
|
||||
*/
|
||||
public function reset(User $user, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
$user->forceFill([
|
||||
'password' => $input['password'],
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Concerns;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
trait PasswordValidationRules
|
||||
{
|
||||
/**
|
||||
* Get the validation rules used to validate passwords.
|
||||
*
|
||||
* @return array<int, Rule|array<mixed>|string>
|
||||
*/
|
||||
protected function passwordRules(): array
|
||||
{
|
||||
return ['required', 'string', Password::default(), 'confirmed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules used to validate the current password.
|
||||
*
|
||||
* @return array<int, Rule|array<mixed>|string>
|
||||
*/
|
||||
protected function currentPasswordRules(): array
|
||||
{
|
||||
return ['required', 'string', 'current_password'];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Concerns;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
trait ProfileValidationRules
|
||||
{
|
||||
/**
|
||||
* Get the validation rules used to validate user profiles.
|
||||
*
|
||||
* @return array<string, array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>>
|
||||
*/
|
||||
protected function profileRules(?int $userId = null): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->nameRules(),
|
||||
'email' => $this->emailRules($userId),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules used to validate user names.
|
||||
*
|
||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
||||
*/
|
||||
protected function nameRules(): array
|
||||
{
|
||||
return ['required', 'string', 'max:255'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules used to validate user emails.
|
||||
*
|
||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
||||
*/
|
||||
protected function emailRules(?int $userId = null): array
|
||||
{
|
||||
return [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:255',
|
||||
$userId === null
|
||||
? Rule::unique(User::class)
|
||||
: Rule::unique(User::class)->ignore($userId),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Patient;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GeneratePatientMedicalRecordNumbers extends Command
|
||||
{
|
||||
/**
|
||||
* Perintah yang nanti dijalankan di terminal.
|
||||
*/
|
||||
protected $signature = 'patients:generate-rm';
|
||||
|
||||
/**
|
||||
* Deskripsi perintah.
|
||||
*/
|
||||
protected $description = 'Generate medical_record_number untuk pasien lama yang masih NULL';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// Ambil semua pasien yang belum punya nomor RM, diurutkan berdasarkan waktu dibuat
|
||||
$patients = Patient::whereNull('medical_record_number')
|
||||
->orWhere('medical_record_number', '')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
|
||||
if ($patients->isEmpty()) {
|
||||
$this->info('Semua pasien sudah memiliki nomor Rekam Medis!');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$this->info("Menemukan {$patients->count()} pasien tanpa No. RM. Memulai proses...");
|
||||
|
||||
$bar = $this->output->createProgressBar($patients->count());
|
||||
$bar->start();
|
||||
|
||||
foreach ($patients as $patient) {
|
||||
// Gunakan tanggal buat pasien (created_at) agar prefix tahun-bulan sesuai waktu daftar
|
||||
$prefix = 'RM' . $patient->created_at->format('ym');
|
||||
|
||||
// Cari nomor RM terakhir berdasarkan prefix bulan/tahun pasien tersebut
|
||||
$latestNumber = Patient::where('medical_record_number', 'like', $prefix . '%')
|
||||
->orderByDesc('medical_record_number')
|
||||
->value('medical_record_number');
|
||||
|
||||
if ($latestNumber) {
|
||||
$nextNumber = ((int) substr($latestNumber, -4)) + 1;
|
||||
} else {
|
||||
$nextNumber = 1;
|
||||
}
|
||||
|
||||
// Simpan tanpa memicu event 'creating' lagi
|
||||
$patient->medical_record_number = $prefix . str_pad($nextNumber, 4, '0', STR_PAD_LEFT);
|
||||
$patient->saveQuietly(); // saveQuietly mencegah trigger event model
|
||||
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->newLine();
|
||||
$this->info('Berhasil menggenerate semua No. RM untuk pasien lama!');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Patient;
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
|
||||
class PatientController extends Controller
|
||||
{
|
||||
public function print(Patient $patient)
|
||||
{
|
||||
$patient->load('user');
|
||||
|
||||
// Generate URL verifikasi (ganti dengan domain asli kamu nanti)
|
||||
$url = route('verify.patient', $patient->nik);
|
||||
|
||||
$renderer = new ImageRenderer(
|
||||
new RendererStyle(200, 0),
|
||||
new SvgImageBackEnd()
|
||||
);
|
||||
$writer = new Writer($renderer);
|
||||
|
||||
// Sekarang QR Code berisi LINK, bukan cuma angka NIK
|
||||
$qrcode = $writer->writeString($url);
|
||||
|
||||
return view('admin.patients.print', compact('patient', 'qrcode'));
|
||||
}
|
||||
|
||||
public function verify($nik)
|
||||
{
|
||||
$patient = Patient::with('user')->where('nik', $nik)->firstOrFail();
|
||||
return view('admin.patients.verify-status', compact('patient'));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckMaintenanceMode
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$isMaintenance = \App\Models\Setting::get('maintenance_mode');
|
||||
|
||||
if ($isMaintenance === 'true') {
|
||||
// Pengecekan agar Admin tidak terkunci (lockout)
|
||||
// Jika user adalah admin, biarkan mereka lewat
|
||||
if (auth()->check() && auth()->user()->hasRole('admin')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Izinkan akses ke halaman login agar admin bisa masuk untuk mematikan mode maintenance
|
||||
if ($request->is('login') || $request->is('livewire*')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Tampilkan halaman maintenance
|
||||
return response()->view('errors.maintenance', [], 503);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Actions;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class Logout
|
||||
{
|
||||
/**
|
||||
* Log the current user out of the application.
|
||||
*/
|
||||
public function __invoke()
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
Session::invalidate();
|
||||
Session::regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Category;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Str;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class Categories extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $name, $selected_id;
|
||||
public $search = '';
|
||||
public $isModalOpen = false;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|min:3|unique:categories,name',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.categories', [
|
||||
'categories' => Category::withCount('news')
|
||||
->where('name', 'like', '%' . $this->search . '%')
|
||||
->latest()
|
||||
->paginate(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->reset(['name', 'selected_id']);
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit(Category $category)
|
||||
{
|
||||
$this->selected_id = $category->id;
|
||||
$this->name = $category->name;
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$validationRules = $this->selected_id
|
||||
? ['name' => 'required|min:3|unique:categories,name,' . $this->selected_id]
|
||||
: $this->rules;
|
||||
|
||||
$this->validate($validationRules);
|
||||
|
||||
Category::updateOrCreate(['id' => $this->selected_id], [
|
||||
'name' => $this->name,
|
||||
'slug' => Str::slug($this->name),
|
||||
]);
|
||||
|
||||
$pesan = $this->selected_id ? 'Kategori berhasil diperbarui!' : 'Kategori baru berhasil ditambahkan!';
|
||||
Toaster::success($pesan);
|
||||
|
||||
$this->isModalOpen = false;
|
||||
$this->reset(['name', 'selected_id']);
|
||||
}
|
||||
|
||||
public function delete(Category $category)
|
||||
{
|
||||
// Opsional: Cek jika kategori masih punya berita
|
||||
if ($category->news_count > 0) {
|
||||
Toaster::error('Kategori tidak bisa dihapus karena masih memiliki berita!');
|
||||
return;
|
||||
}
|
||||
|
||||
$category->delete();
|
||||
Toaster::error('Kategori telah dihapus permanen.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Patient;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Doctor;
|
||||
use App\Models\News;
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
// Menggunakan date() jauh lebih aman dari error argumen
|
||||
$today = date('Y-m-d');
|
||||
|
||||
return view('livewire.admin.dashboard', [
|
||||
'stats' => [
|
||||
'total_patients' => Patient::count(),
|
||||
'today_appointments' => Appointment::whereDate('appointment_date', $today)->count(),
|
||||
'total_doctors' => Doctor::count(),
|
||||
'published_news' => News::where('is_published', true)->count(),
|
||||
],
|
||||
'recentAppointments' => Appointment::with(['patient', 'serviceCategory'])
|
||||
->whereDate('appointment_date', $today)
|
||||
->whereIn('status', ['waiting', 'calling'])
|
||||
->orderBy('queue_number', 'asc')
|
||||
->take(5)
|
||||
->get(),
|
||||
'popularNews' => News::orderBy('view_count', 'desc')->take(5)->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Doctor;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\WithFileUploads;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class DoctorManager extends Component
|
||||
{
|
||||
use WithPagination, WithFileUploads;
|
||||
|
||||
public $search = '';
|
||||
public $filterSpecialization = '';
|
||||
|
||||
public $doctorId;
|
||||
public $name, $specialization, $phone, $email, $schedule, $photo;
|
||||
public $oldPhoto;
|
||||
|
||||
public $isModalOpen = false;
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFilterSpecialization()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->resetForm();
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$doctor = Doctor::findOrFail($id);
|
||||
|
||||
$this->doctorId = $doctor->id;
|
||||
$this->name = $doctor->name;
|
||||
$this->specialization = $doctor->specialization;
|
||||
$this->phone = $doctor->phone;
|
||||
$this->email = $doctor->email;
|
||||
$this->oldPhoto = $doctor->photo;
|
||||
|
||||
$this->schedule = $doctor->schedule ?? [
|
||||
'Senin' => '',
|
||||
'Selasa' => '',
|
||||
'Rabu' => '',
|
||||
'Kamis' => '',
|
||||
'Jumat' => '',
|
||||
'Sabtu' => '',
|
||||
'Minggu' => ''
|
||||
];
|
||||
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'specialization' => 'required|string|max:255',
|
||||
'phone' => 'required|string|max:20',
|
||||
'email' => 'nullable|email',
|
||||
'photo' => 'nullable|image|max:2048', // 2MB
|
||||
]);
|
||||
|
||||
// Upload foto jika ada
|
||||
$photoPath = $this->oldPhoto;
|
||||
|
||||
if ($this->photo) {
|
||||
$photoPath = $this->photo->store('doctors', 'public');
|
||||
}
|
||||
|
||||
Doctor::updateOrCreate(
|
||||
['id' => $this->doctorId],
|
||||
[
|
||||
'name' => $this->name,
|
||||
'specialization' => $this->specialization,
|
||||
'phone' => $this->phone,
|
||||
'email' => $this->email,
|
||||
'schedule' => $this->schedule,
|
||||
'photo' => $photoPath,
|
||||
]
|
||||
);
|
||||
|
||||
$this->isModalOpen = false;
|
||||
$this->resetForm();
|
||||
|
||||
Toaster::success('Data dokter berhasil disimpan.');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Doctor::findOrFail($id)->delete();
|
||||
Toaster::success('Data dokter berhasil dihapus.');
|
||||
}
|
||||
|
||||
private function resetForm()
|
||||
{
|
||||
$this->doctorId = null;
|
||||
$this->name = '';
|
||||
$this->specialization = '';
|
||||
$this->phone = '';
|
||||
$this->email = '';
|
||||
$this->photo = null;
|
||||
$this->oldPhoto = null;
|
||||
|
||||
$this->schedule = [
|
||||
'Senin' => '',
|
||||
'Selasa' => '',
|
||||
'Rabu' => '',
|
||||
'Kamis' => '',
|
||||
'Jumat' => '',
|
||||
'Sabtu' => '',
|
||||
'Minggu' => '',
|
||||
];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Doctor::query();
|
||||
|
||||
if ($this->search) {
|
||||
$query->where(function ($q) {
|
||||
$q->where('name', 'like', "%{$this->search}%")
|
||||
->orWhere('specialization', 'like', "%{$this->search}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->filterSpecialization) {
|
||||
$query->where('specialization', $this->filterSpecialization);
|
||||
}
|
||||
|
||||
return view('livewire.admin.doctor-manager', [
|
||||
'doctors' => $query->latest()->paginate(10),
|
||||
'specializations' => Doctor::select('specialization')->distinct()->pluck('specialization')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,411 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Doctor;
|
||||
use App\Models\Patient;
|
||||
use App\Models\ServiceCategory;
|
||||
use App\Models\User;
|
||||
use App\Models\MedicalRecord;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class ManageAntrean extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
// Filter & State Properti
|
||||
public $search_patient_name = '';
|
||||
public $search_date;
|
||||
public $filter_doctor = '';
|
||||
public $target_number;
|
||||
public $current_tab = 'active'; // active (waiting, calling, skipped), finished, cancelled
|
||||
public $selectedAppointment = null;
|
||||
|
||||
// Properti Form Walk-in
|
||||
public $walkin_patient_id;
|
||||
public $walkin_doctor_id;
|
||||
public $walkin_service_id;
|
||||
public $walkin_notes;
|
||||
|
||||
// Properti untuk Rekam Medis
|
||||
public $currentExamining = null;
|
||||
public $symptoms;
|
||||
public $diagnosis;
|
||||
public $treatment;
|
||||
public $doctor_notes;
|
||||
|
||||
protected $queryString = [
|
||||
'search_date' => ['except' => ''],
|
||||
'current_tab' => ['except' => 'active'],
|
||||
'filter_doctor' => ['except' => '']
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Default ke tanggal hari ini jika tidak ada di URL
|
||||
$this->search_date = $this->search_date ?? date('Y-m-d');
|
||||
}
|
||||
|
||||
public function updatedSearchDate()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFilterDoctor()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedCurrentTab()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fungsi Utama Update Status & Trigger Suara
|
||||
*/
|
||||
public function updateStatus($id, $status)
|
||||
{
|
||||
$appointment = Appointment::with(['patient', 'doctor', 'serviceCategory'])->findOrFail($id);
|
||||
|
||||
// LOGIKA KHUSUS JIKA STATUS 'CALLING'
|
||||
if ($status === 'calling') {
|
||||
// Matikan pasien lain yang sedang 'calling' di dokter yang sama agar tidak bentrok
|
||||
Appointment::where('doctor_id', $appointment->doctor_id)
|
||||
->whereDate('appointment_date', $this->search_date)
|
||||
->where('status', 'calling')
|
||||
->where('id', '!=', $id)
|
||||
->update(['status' => 'waiting']);
|
||||
|
||||
// Kirim event suara ke Browser
|
||||
$this->dispatch(
|
||||
'play-calling-sound',
|
||||
name: $appointment->patient->name,
|
||||
number: $appointment->queue_number,
|
||||
poli: $appointment->serviceCategory->name ?? 'Ruang Pemeriksaan',
|
||||
doctor: $appointment->doctor->name ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
$appointment->update(['status' => $status]);
|
||||
|
||||
$message = match ($status) {
|
||||
'calling' => 'Pasien dipanggil ke ruang periksa.',
|
||||
'finished' => 'Pemeriksaan telah selesai.',
|
||||
'cancelled' => 'Antrean berhasil dibatalkan.',
|
||||
'skipped' => 'Pasien ditandai terlambat.',
|
||||
default => 'Status berhasil diperbarui.'
|
||||
};
|
||||
|
||||
Toaster::success($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Panggil Ulang Pasien (Hanya trigger suara)
|
||||
*/
|
||||
public function recall($id)
|
||||
{
|
||||
$appointment = Appointment::with(['patient', 'doctor', 'serviceCategory'])->findOrFail($id);
|
||||
|
||||
$this->dispatch(
|
||||
'play-calling-sound',
|
||||
name: $appointment->patient->name,
|
||||
number: $appointment->queue_number,
|
||||
poli: $appointment->serviceCategory->name ?? 'Ruang Pemeriksaan',
|
||||
doctor: $appointment->doctor->name ?? ''
|
||||
);
|
||||
|
||||
Toaster::info("Memanggil ulang antrean nomor #{$appointment->queue_number}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tandai Dilewati dan Langsung Panggil Berikutnya
|
||||
*/
|
||||
public function skipAndNext($id)
|
||||
{
|
||||
$appointment = Appointment::findOrFail($id);
|
||||
$appointment->update(['status' => 'skipped']);
|
||||
|
||||
Toaster::warning("Pasien #{$appointment->queue_number} ditandai dilewati.");
|
||||
|
||||
$this->callNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kembalikan Status (Undo)
|
||||
*/
|
||||
public function undoStatus($id)
|
||||
{
|
||||
$appointment = Appointment::findOrFail($id);
|
||||
$appointment->update(['status' => 'waiting']);
|
||||
|
||||
Toaster::info("Antrean #{$appointment->queue_number} dikembalikan ke status menunggu.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Panggil Pasien Berikutnya secara Otomatis
|
||||
*/
|
||||
public function callNext()
|
||||
{
|
||||
$query = Appointment::where('status', 'waiting')
|
||||
->whereDate('appointment_date', $this->search_date);
|
||||
|
||||
// Jika sedang filter dokter tertentu
|
||||
if (!empty($this->filter_doctor)) {
|
||||
$next = $query->where('doctor_id', $this->filter_doctor)
|
||||
->orderBy('queue_number', 'asc')
|
||||
->first();
|
||||
}
|
||||
// Jika mode Global (Semua Dokter)
|
||||
else {
|
||||
$next = $query->orderBy('created_at', 'asc')->first();
|
||||
}
|
||||
|
||||
if ($next) {
|
||||
// Sinkronkan filter ke dokter pasien tersebut jika di mode global
|
||||
if (empty($this->filter_doctor)) {
|
||||
$this->filter_doctor = $next->doctor_id;
|
||||
}
|
||||
|
||||
$this->updateStatus($next->id, 'calling');
|
||||
Toaster::success("Memanggil berikutnya: #{$next->queue_number}");
|
||||
} else {
|
||||
Toaster::error('Tidak ada pasien dalam antrean menunggu.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Panggil Berdasarkan Input Nomor Manual
|
||||
*/
|
||||
public function callSpecificNumber()
|
||||
{
|
||||
if (empty($this->target_number)) {
|
||||
Toaster::error('Masukkan nomor antrean.');
|
||||
return;
|
||||
}
|
||||
|
||||
$query = Appointment::where('queue_number', $this->target_number)
|
||||
->whereDate('appointment_date', $this->search_date)
|
||||
->whereIn('status', ['waiting', 'skipped']);
|
||||
|
||||
if (!empty($this->filter_doctor)) {
|
||||
$query->where('doctor_id', $this->filter_doctor);
|
||||
}
|
||||
|
||||
$results = $query->get();
|
||||
|
||||
if ($results->count() === 0) {
|
||||
Toaster::error("Nomor #{$this->target_number} tidak ditemukan.");
|
||||
} elseif ($results->count() > 1 && empty($this->filter_doctor)) {
|
||||
Toaster::warning("Ada beberapa nomor sama. Pilih dokter dahulu.");
|
||||
} else {
|
||||
$target = $results->first();
|
||||
$this->filter_doctor = $target->doctor_id;
|
||||
$this->updateStatus($target->id, 'calling');
|
||||
$this->target_number = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pindahkan Pasien ke Dokter/Poli Lain
|
||||
*/
|
||||
public function transferPatient($id, $newDoctorId)
|
||||
{
|
||||
$appointment = Appointment::findOrFail($id);
|
||||
|
||||
// Cari nomor terakhir di dokter tujuan hari ini
|
||||
$lastQueue = Appointment::where('doctor_id', $newDoctorId)
|
||||
->whereDate('appointment_date', $this->search_date)
|
||||
->max('queue_number') ?? 0;
|
||||
|
||||
$appointment->update([
|
||||
'doctor_id' => $newDoctorId,
|
||||
'queue_number' => $lastQueue + 1,
|
||||
'status' => 'waiting'
|
||||
]);
|
||||
|
||||
Toaster::success("Pasien berhasil dipindahkan ke Dokter/Poli tujuan.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Modal Tiket
|
||||
*/
|
||||
public function showTicketModal($id)
|
||||
{
|
||||
$this->selectedAppointment = Appointment::with(['patient', 'doctor', 'serviceCategory'])->findOrFail($id);
|
||||
$this->js("Flux.modal('ticket-modal').show()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk-in Registration
|
||||
*/
|
||||
public function openWalkInModal()
|
||||
{
|
||||
$this->reset(['walkin_patient_id', 'walkin_doctor_id', 'walkin_service_id', 'walkin_notes']);
|
||||
if ($this->filter_doctor) $this->walkin_doctor_id = $this->filter_doctor;
|
||||
$this->js("Flux.modal('walkin-modal').show()");
|
||||
}
|
||||
|
||||
protected function validationAttributes()
|
||||
{
|
||||
return [
|
||||
'walkin_patient_id' => 'pasien',
|
||||
'walkin_doctor_id' => 'dokter',
|
||||
'walkin_service_id' => 'poli/layanan',
|
||||
];
|
||||
}
|
||||
|
||||
public function saveWalkIn()
|
||||
{
|
||||
// 1. Validasi pastikan ID tersebut ada di tabel patients
|
||||
$this->validate([
|
||||
'walkin_patient_id' => 'required|exists:patients,id',
|
||||
'walkin_doctor_id' => 'required|exists:doctors,id',
|
||||
'walkin_service_id' => 'required|exists:service_categories,id',
|
||||
]);
|
||||
|
||||
// 2. AMBIL DATA PASIEN UNTUK MENDAPATKAN USER_ID NYA
|
||||
$patientData = \App\Models\Patient::with('user')->find($this->walkin_patient_id);
|
||||
|
||||
if (!$patientData || !$patientData->user_id) {
|
||||
Toaster::error('Gagal memproses data pengguna pasien.');
|
||||
return;
|
||||
}
|
||||
|
||||
$lastQueue = Appointment::where('doctor_id', $this->walkin_doctor_id)
|
||||
->whereDate('appointment_date', $this->search_date)
|
||||
->max('queue_number') ?? 0;
|
||||
|
||||
// 3. Simpan appointment menggunakan USER_ID (karena database Anda mendefinisikan patient_id sebagai ID User)
|
||||
$appointment = Appointment::create([
|
||||
'patient_id' => $patientData->user_id, // Gunakan user_id dari tabel patients
|
||||
'doctor_id' => $this->walkin_doctor_id,
|
||||
'service_category_id' => $this->walkin_service_id,
|
||||
'appointment_date' => $this->search_date,
|
||||
'queue_number' => $lastQueue + 1,
|
||||
'notes' => $this->walkin_notes,
|
||||
'status' => 'waiting',
|
||||
'created_by' => auth()->id(),
|
||||
]);
|
||||
|
||||
// Ambil data lengkap termasuk relasi untuk dikirim ke JS cetak
|
||||
$this->dispatch('print-after-save', data: [
|
||||
'number' => str_pad($appointment->queue_number, 2, '0', STR_PAD_LEFT),
|
||||
'name' => $patientData->user->name ?? 'Tanpa Nama',
|
||||
'poli' => $appointment->serviceCategory->name ?? 'UMUM',
|
||||
'doctor' => $appointment->doctor->name ?? '-',
|
||||
'date' => $appointment->created_at->translatedFormat('d M Y, H:i') . ' WIB',
|
||||
]);
|
||||
|
||||
$this->js("Flux.modal('walkin-modal').close()");
|
||||
Toaster::success('Pendaftaran Walk-in berhasil.');
|
||||
|
||||
$this->reset(['walkin_patient_id', 'walkin_notes']);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// Query Dasar berdasarkan Tanggal dan Filter Dokter
|
||||
$baseQuery = Appointment::with(['patient', 'doctor', 'serviceCategory'])
|
||||
->whereDate('appointment_date', $this->search_date)
|
||||
->when($this->filter_doctor, function ($q) {
|
||||
return $q->where('doctor_id', $this->filter_doctor);
|
||||
});
|
||||
|
||||
// Filter Tabel berdasarkan Tab Aktif
|
||||
$tableQuery = (clone $baseQuery);
|
||||
if ($this->current_tab === 'active') {
|
||||
$tableQuery->whereIn('status', ['waiting', 'calling', 'skipped']);
|
||||
} else {
|
||||
$tableQuery->where('status', $this->current_tab);
|
||||
}
|
||||
|
||||
return view('livewire.admin.manage-antrean', [
|
||||
'appointments' => $tableQuery->orderBy('queue_number', 'asc')->paginate(10),
|
||||
'currentCalling' => (clone $baseQuery)->where('status', 'calling')->first(),
|
||||
'stats' => [
|
||||
'total' => (clone $baseQuery)->count(),
|
||||
'waiting' => (clone $baseQuery)->whereIn('status', ['waiting', 'skipped'])->count(),
|
||||
'finished' => (clone $baseQuery)->where('status', 'finished')->count(),
|
||||
],
|
||||
'doctors' => Doctor::all(),
|
||||
'services' => ServiceCategory::all(),
|
||||
'patients' => strlen($this->search_patient_name) >= 3
|
||||
? User::query()
|
||||
->has('patient') // Hanya user yang sudah punya data di tabel patients
|
||||
->with('patient')
|
||||
->where(function ($q) {
|
||||
$q->where('name', 'like', '%' . $this->search_patient_name . '%')
|
||||
->orWhereHas('patient', function ($query) {
|
||||
$query->where('nik', 'like', '%' . $this->search_patient_name . '%');
|
||||
});
|
||||
})
|
||||
->limit(10)
|
||||
->get()
|
||||
: [],
|
||||
]);
|
||||
}
|
||||
|
||||
public function startMedicalRecord($appointmentId)
|
||||
{
|
||||
// 1. Ambil data janji temu beserta relasinya
|
||||
$this->currentExamining = Appointment::with(['doctor', 'serviceCategory'])->find($appointmentId);
|
||||
|
||||
if ($this->currentExamining) {
|
||||
// 2. Karena 'patient_id' di appointments adalah ID USER, kita langsung cari nama user-nya di sini
|
||||
$userPasien = \App\Models\User::find($this->currentExamining->patient_id);
|
||||
|
||||
// 3. Kita simpan nama aslinya ke dalam properti baru agar bisa dipanggil dengan aman di Blade
|
||||
$this->currentPatientName = $userPasien ? $userPasien->name : 'Tidak Diketahui';
|
||||
|
||||
// Set form default
|
||||
$this->symptoms = $this->currentExamining->notes;
|
||||
$this->diagnosis = '';
|
||||
$this->treatment = '';
|
||||
$this->doctor_notes = '';
|
||||
|
||||
// Munculkan Modal
|
||||
$this->js("Flux.modal('medical-record-modal').show()");
|
||||
}
|
||||
}
|
||||
|
||||
public function saveMedicalRecord()
|
||||
{
|
||||
$this->validate([
|
||||
'symptoms' => 'required',
|
||||
'diagnosis' => 'required',
|
||||
]);
|
||||
|
||||
$actualPatient = \App\Models\Patient::where('user_id', $this->currentExamining->patient_id)->first();
|
||||
|
||||
if (! $actualPatient) {
|
||||
session()->flash('error', 'Data Pasien tidak ditemukan di sistem.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Simpan ke database dengan ID Patient yang benar
|
||||
MedicalRecord::create([
|
||||
'patient_id' => $actualPatient->id, // Sekarang menggunakan ID Patient asli (Bukan 52 lagi)
|
||||
'appointment_id' => $this->currentExamining->id,
|
||||
'doctor_id' => $this->currentExamining->doctor_id,
|
||||
'symptoms' => $this->symptoms,
|
||||
'diagnosis' => $this->diagnosis,
|
||||
'treatment' => $this->treatment,
|
||||
'notes' => $this->doctor_notes,
|
||||
]);
|
||||
|
||||
// Update status antrean menjadi Selesai (finished)
|
||||
$this->currentExamining->update([
|
||||
'status' => 'finished'
|
||||
]);
|
||||
|
||||
$this->js("Flux.modal('medical-record-modal').close()");
|
||||
$this->reset(['currentExamining', 'symptoms', 'diagnosis', 'treatment', 'doctor_notes']);
|
||||
|
||||
session()->flash('message', 'Pemeriksaan selesai dan Rekam Medis berhasil disimpan.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\News as NewsModel;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class News extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $search = '';
|
||||
|
||||
// Reset halaman jika pencarian berubah
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function togglePublish($id)
|
||||
{
|
||||
$news = NewsModel::findOrFail($id);
|
||||
$news->is_published = !$news->is_published;
|
||||
$news->save();
|
||||
|
||||
Toaster::info('Status publikasi berhasil diubah.');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$news = NewsModel::findOrFail($id);
|
||||
|
||||
// Hapus file fisik gambar jika ada
|
||||
if ($news->image) {
|
||||
Storage::disk('public')->delete($news->image);
|
||||
}
|
||||
|
||||
$news->delete();
|
||||
Toaster::error('Berita telah dihapus permanen.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.news.news', [
|
||||
'news' => NewsModel::with('category')
|
||||
->where('title', 'like', '%' . $this->search . '%')
|
||||
->latest()
|
||||
->paginate(10)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Models\Category;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Str;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class NewsCreate extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
// Properti form berita
|
||||
public $title, $image, $content;
|
||||
public $category_id = '';
|
||||
public $is_published = false;
|
||||
|
||||
protected $rules = [
|
||||
'title' => 'required|min:5|unique:news,title',
|
||||
'category_id' => 'required|exists:categories,id',
|
||||
'image' => 'nullable|image|max:2048', // Max 2MB
|
||||
'content' => 'required|min:20',
|
||||
];
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
// Proses upload gambar
|
||||
$imagePath = $this->image ? $this->image->store('news', 'public') : null;
|
||||
|
||||
News::create([
|
||||
'title' => $this->title,
|
||||
'slug' => Str::slug($this->title),
|
||||
'category_id' => $this->category_id,
|
||||
'image' => $imagePath,
|
||||
'content' => $this->content,
|
||||
'user_id' => auth()->id(),
|
||||
'is_published' => $this->is_published,
|
||||
]);
|
||||
|
||||
Toaster::success('Berita berhasil diterbitkan!');
|
||||
|
||||
return redirect()->route('admin.news');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.news.news-create', [
|
||||
'categories' => Category::all()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Models\Category;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class NewsEdit extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public News $news;
|
||||
public $title, $category_id, $content, $oldImage;
|
||||
public $is_published = false; // Default ke false
|
||||
public $image;
|
||||
|
||||
public function mount(News $news)
|
||||
{
|
||||
$this->news = $news;
|
||||
$this->title = $news->title;
|
||||
$this->category_id = $news->category_id;
|
||||
$this->content = $news->content;
|
||||
|
||||
// Memastikan tipe data boolean agar checkbox tercentang
|
||||
$this->is_published = (bool) $news->is_published;
|
||||
|
||||
$this->oldImage = $news->image;
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min:5|unique:news,title,' . $this->news->id,
|
||||
'category_id' => 'required|exists:categories,id',
|
||||
'image' => 'nullable|image|max:2048',
|
||||
'content' => 'required|min:20',
|
||||
'is_published' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$data = [
|
||||
'title' => $this->title,
|
||||
'category_id' => $this->category_id,
|
||||
'content' => $this->content,
|
||||
'is_published' => $this->is_published,
|
||||
];
|
||||
|
||||
if ($this->image) {
|
||||
// Hapus gambar lama jika user upload gambar baru
|
||||
if ($this->oldImage) {
|
||||
Storage::disk('public')->delete($this->oldImage);
|
||||
}
|
||||
$data['image'] = $this->image->store('news', 'public');
|
||||
}
|
||||
|
||||
$this->news->update($data);
|
||||
|
||||
Toaster::success('Berita berhasil diperbarui!');
|
||||
|
||||
return redirect()->route('admin.news');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.news.news-edit', [
|
||||
'categories' => Category::all()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Patient;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class PatientHistory extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public Patient $patient;
|
||||
|
||||
public function mount(Patient $patient)
|
||||
{
|
||||
// Load relasi user bawaan pasien
|
||||
$this->patient = $patient->load('user');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// Mengambil data rekam medis pasien yang diurutkan dari pemeriksaan terbaru[cite: 4, 7]
|
||||
$medicalRecords = $this->patient->medicalRecords()
|
||||
->with(['doctor', 'appointment.serviceCategory']) // Load relasi dokter dan poli[cite: 3, 7]
|
||||
->latest()
|
||||
->paginate(5);
|
||||
|
||||
return view('livewire.admin.patient-history', [
|
||||
'medicalRecords' => $medicalRecords, // Mengirim variabel medicalRecords ke view
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Patient;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class PatientManager extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $search = '';
|
||||
public $filterInsurance = '';
|
||||
public $selectedPatient = null;
|
||||
|
||||
protected function validationAttributes()
|
||||
{
|
||||
return [
|
||||
// Alias untuk Form Tambah
|
||||
'createForm.name' => 'Nama pasien',
|
||||
'createForm.email' => 'Alamat email',
|
||||
'createForm.nik' => 'NIK',
|
||||
'createForm.gender' => 'Jenis kelamin',
|
||||
'createForm.date_of_birth' => 'Tanggal lahir',
|
||||
'createForm.place_of_birth' => 'Tempat lahir',
|
||||
'createForm.phone' => 'Nomor telepon',
|
||||
'createForm.address' => 'Alamat domisili',
|
||||
'createForm.insurance_type' => 'Jenis penjaminan',
|
||||
'createForm.insurance_number' => 'Nomor kartu',
|
||||
|
||||
// Alias untuk Form Edit
|
||||
'editForm.name' => 'Nama pasien',
|
||||
'editForm.nik' => 'NIK',
|
||||
'editForm.gender' => 'Jenis kelamin',
|
||||
'editForm.date_of_birth' => 'Tanggal lahir',
|
||||
'editForm.place_of_birth' => 'Tempat lahir',
|
||||
'editForm.phone' => 'Nomor telepon',
|
||||
'editForm.address' => 'Alamat domisili',
|
||||
'editForm.insurance_type' => 'Jenis penjaminan',
|
||||
'editForm.insurance_number' => 'Nomor kartu',
|
||||
];
|
||||
}
|
||||
|
||||
// Tambahkan properti untuk menangani perubahan UI di modal
|
||||
public $createForm = [
|
||||
'name' => '',
|
||||
'email' => '',
|
||||
'nik' => '',
|
||||
'gender' => '',
|
||||
'blood_type' => '',
|
||||
'place_of_birth' => '',
|
||||
'date_of_birth' => '',
|
||||
'phone' => '',
|
||||
'address' => '',
|
||||
'emergency_contact_name' => '',
|
||||
'emergency_contact_relation' => '',
|
||||
'emergency_contact_phone' => '',
|
||||
'insurance_type' => 'Umum',
|
||||
'insurance_number' => '',
|
||||
];
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->validate([
|
||||
'createForm.name' => 'required|string|max:255',
|
||||
'createForm.email' => 'required|email|unique:users,email',
|
||||
'createForm.nik' => 'required|digits:16|unique:patients,nik',
|
||||
'createForm.gender' => 'required|in:L,P',
|
||||
'createForm.date_of_birth' => 'required|date',
|
||||
'createForm.phone' => 'required',
|
||||
'createForm.address' => 'required',
|
||||
'createForm.insurance_type' => 'required',
|
||||
]);
|
||||
|
||||
// DB Transaction direkomendasikan karena insert ke 2 tabel
|
||||
DB::transaction(function () {
|
||||
$user = User::create([
|
||||
'name' => $this->createForm['name'],
|
||||
'email' => $this->createForm['email'],
|
||||
'password' => bcrypt($this->createForm['nik']),
|
||||
]);
|
||||
|
||||
$user->patient()->create([
|
||||
'nik' => $this->createForm['nik'],
|
||||
'gender' => $this->createForm['gender'],
|
||||
'blood_type' => $this->createForm['blood_type'],
|
||||
'place_of_birth' => $this->createForm['place_of_birth'],
|
||||
'date_of_birth' => $this->createForm['date_of_birth'],
|
||||
'phone' => $this->createForm['phone'],
|
||||
'address' => $this->createForm['address'],
|
||||
'emergency_contact_name' => $this->createForm['emergency_contact_name'],
|
||||
'emergency_contact_relation' => $this->createForm['emergency_contact_relation'],
|
||||
'emergency_contact_phone' => $this->createForm['emergency_contact_phone'],
|
||||
'insurance_type' => $this->createForm['insurance_type'],
|
||||
'insurance_number' => $this->createForm['insurance_number'],
|
||||
]);
|
||||
|
||||
$user->syncRoles('patient');
|
||||
});
|
||||
|
||||
$this->js("Flux.modal('add-patient').close()");
|
||||
Toaster::success('Data pasien berhasil didaftarkan. password default adalah NIK pasien.');
|
||||
$this->reset('createForm');
|
||||
}
|
||||
|
||||
// Fungsi untuk reset form tambah
|
||||
public function create()
|
||||
{
|
||||
$this->reset('createForm');
|
||||
$this->createForm['insurance_type'] = 'Umum'; // default
|
||||
$this->js("Flux.modal('add-patient').show()");
|
||||
}
|
||||
|
||||
// Properti untuk Form Edit
|
||||
public $editForm = [
|
||||
'id' => null,
|
||||
'name' => '',
|
||||
'nik' => '',
|
||||
'place_of_birth' => '',
|
||||
'date_of_birth' => '',
|
||||
'gender' => '',
|
||||
'blood_type' => '',
|
||||
'phone' => '',
|
||||
'address' => '',
|
||||
'emergency_contact_name' => '',
|
||||
'emergency_contact_phone' => '',
|
||||
'emergency_contact_relation' => '',
|
||||
'insurance_type' => '',
|
||||
'insurance_number' => '',
|
||||
];
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFilterInsurance()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
// Fungsi membuka modal detail
|
||||
public function showDetail($id)
|
||||
{
|
||||
$this->selectedPatient = Patient::with('user')->find($id);
|
||||
$this->js("Flux.modal('patient-detail').show()");
|
||||
}
|
||||
|
||||
// Fungsi memuat data ke modal edit
|
||||
public function edit($id)
|
||||
{
|
||||
$patient = Patient::with('user')->findOrFail($id);
|
||||
|
||||
$this->editForm = [
|
||||
'id' => $patient->id,
|
||||
'name' => $patient->user->name,
|
||||
'nik' => $patient->nik,
|
||||
'place_of_birth' => $patient->place_of_birth,
|
||||
'date_of_birth' => $patient->date_of_birth,
|
||||
'gender' => $patient->gender,
|
||||
'blood_type' => $patient->blood_type,
|
||||
'phone' => $patient->phone,
|
||||
'address' => $patient->address,
|
||||
'emergency_contact_name' => $patient->emergency_contact_name,
|
||||
'emergency_contact_phone' => $patient->emergency_contact_phone,
|
||||
'emergency_contact_relation' => $patient->emergency_contact_relation,
|
||||
'insurance_type' => $patient->insurance_type,
|
||||
'insurance_number' => $patient->insurance_number,
|
||||
];
|
||||
|
||||
$this->js("Flux.modal('edit-patient').show()");
|
||||
}
|
||||
|
||||
// Fungsi simpan perubahan
|
||||
public function update()
|
||||
{
|
||||
$this->validate([
|
||||
'editForm.name' => 'required|string|max:255',
|
||||
'editForm.nik' => 'required|digits:16|unique:patients,nik,' . $this->editForm['id'],
|
||||
'editForm.place_of_birth' => 'required',
|
||||
'editForm.date_of_birth' => 'required|date',
|
||||
'editForm.gender' => 'required|in:L,P',
|
||||
'editForm.phone' => 'required',
|
||||
'editForm.address' => 'required',
|
||||
'editForm.insurance_type' => 'required',
|
||||
]);
|
||||
|
||||
$patient = Patient::findOrFail($this->editForm['id']);
|
||||
|
||||
$patient->user->update(['name' => $this->editForm['name']]);
|
||||
|
||||
$patient->update([
|
||||
'nik' => $this->editForm['nik'],
|
||||
'place_of_birth' => $this->editForm['place_of_birth'],
|
||||
'date_of_birth' => $this->editForm['date_of_birth'],
|
||||
'gender' => $this->editForm['gender'],
|
||||
'blood_type' => $this->editForm['blood_type'],
|
||||
'phone' => $this->editForm['phone'],
|
||||
'address' => $this->editForm['address'],
|
||||
'emergency_contact_name' => $this->editForm['emergency_contact_name'],
|
||||
'emergency_contact_phone' => $this->editForm['emergency_contact_phone'],
|
||||
'emergency_contact_relation' => $this->editForm['emergency_contact_relation'],
|
||||
'insurance_type' => $this->editForm['insurance_type'],
|
||||
'insurance_number' => $this->editForm['insurance_number'],
|
||||
]);
|
||||
|
||||
$this->js("Flux.modal('edit-patient').close()");
|
||||
Toaster::success('Data pasien berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Patient::findOrFail($id)->delete();
|
||||
Toaster::success('Data pasien berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Patient::with('user');
|
||||
|
||||
if ($this->search) {
|
||||
$query->where(function ($q) {
|
||||
$q->where('nik', 'like', '%' . $this->search . '%')
|
||||
->orWhere('medical_record_number', 'like', '%' . $this->search . '%')
|
||||
->orWhereHas('user', function ($userQuery) {
|
||||
$userQuery->where('name', 'like', '%' . $this->search . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->filterInsurance) {
|
||||
$query->where('insurance_type', $this->filterInsurance);
|
||||
}
|
||||
|
||||
return view('livewire.admin.patient-manager', [
|
||||
'patients' => $query->latest()->paginate(10)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class PermissionManager extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $name, $permissionId;
|
||||
public $search = '';
|
||||
public $isModalOpen = false;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|min:3|unique:permissions,name',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.permission-manager', [
|
||||
'permissions' => Permission::where('name', 'like', '%' . $this->search . '%')
|
||||
->latest()
|
||||
->paginate(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->reset(['name', 'permissionId']);
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit(Permission $permission)
|
||||
{
|
||||
$this->permissionId = $permission->id;
|
||||
$this->name = $permission->name;
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$validationRules = $this->permissionId
|
||||
? ['name' => 'required|min:3|unique:permissions,name,' . $this->permissionId]
|
||||
: $this->rules;
|
||||
|
||||
$this->validate($validationRules);
|
||||
|
||||
Permission::updateOrCreate(['id' => $this->permissionId], [
|
||||
'name' => $this->name,
|
||||
'guard_name' => 'web'
|
||||
]);
|
||||
|
||||
$pesan = $this->permissionId ? 'Permission berhasil diperbarui!' : 'Permission baru berhasil ditambahkan!';
|
||||
Toaster::success($pesan);
|
||||
|
||||
$this->isModalOpen = false;
|
||||
$this->reset(['name', 'permissionId']);
|
||||
}
|
||||
|
||||
public function delete(Permission $permission)
|
||||
{
|
||||
// Opsional: Proteksi permission krusial agar tidak terhapus
|
||||
$protectedPermissions = ['role-list', 'role-create', 'permission-list'];
|
||||
|
||||
if (in_array($permission->name, $protectedPermissions)) {
|
||||
Toaster::error('Permission ini dilindungi sistem dan tidak boleh dihapus!');
|
||||
return;
|
||||
}
|
||||
|
||||
$permission->delete();
|
||||
Toaster::error('Permission telah dihapus.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster; // Import Toaster
|
||||
|
||||
class RoleManager extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $name, $roleId;
|
||||
public $search = '';
|
||||
public $isModalOpen = false;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|min:3|unique:roles,name',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.role-manager', [
|
||||
'roles' => Role::where('name', 'like', '%' . $this->search . '%')
|
||||
->latest()
|
||||
->paginate(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->reset(['name', 'roleId']);
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit(Role $role)
|
||||
{
|
||||
$this->roleId = $role->id;
|
||||
$this->name = $role->name;
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$validationRules = $this->roleId
|
||||
? ['name' => 'required|min:3|unique:roles,name,' . $this->roleId]
|
||||
: $this->rules;
|
||||
|
||||
$this->validate($validationRules);
|
||||
|
||||
Role::updateOrCreate(['id' => $this->roleId], [
|
||||
'name' => $this->name,
|
||||
'guard_name' => 'web' // Default guard
|
||||
]);
|
||||
|
||||
$pesan = $this->roleId ? 'Role berhasil diperbarui!' : 'Role baru berhasil ditambahkan!';
|
||||
Toaster::success($pesan);
|
||||
|
||||
$this->isModalOpen = false;
|
||||
$this->reset(['name', 'roleId']);
|
||||
}
|
||||
|
||||
public function delete(Role $role)
|
||||
{
|
||||
$protectedRoles = ['admin', 'Admin', 'super-admin'];
|
||||
|
||||
if (in_array($role->name, $protectedRoles)) {
|
||||
Toaster::error('Role ini adalah role sistem dan tidak boleh dihapus!');
|
||||
return;
|
||||
}
|
||||
|
||||
$role->delete();
|
||||
Toaster::error('Role telah dihapus permanen.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class RolePermissions extends Component
|
||||
{
|
||||
public Role $role;
|
||||
public $selectedPermissions = [];
|
||||
|
||||
public function mount(Role $role)
|
||||
{
|
||||
$this->role = $role;
|
||||
// Ambil permission yang sudah dimiliki role ini
|
||||
$this->selectedPermissions = $role->permissions->pluck('name')->toArray();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->role->syncPermissions($this->selectedPermissions);
|
||||
Toaster::success('Hak akses untuk role ' . $this->role->name . ' berhasil diperbarui!');
|
||||
|
||||
return redirect()->route('admin.roles'); // Kembali ke daftar role
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.role-permissions', [
|
||||
'allPermissions' => Permission::all()->groupBy(function($perm) {
|
||||
// Opsional: Kelompokkan berdasarkan kata pertama (misal: 'user-list' jadi group 'user')
|
||||
return explode('-', $perm->name)[0];
|
||||
})
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceCategory;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ServiceManager extends Component
|
||||
{
|
||||
use WithPagination, WithFileUploads;
|
||||
|
||||
public $search = '';
|
||||
public $filterCategory = '';
|
||||
|
||||
public $serviceId;
|
||||
public $name, $category_id, $description;
|
||||
|
||||
public $isModalOpen = false;
|
||||
|
||||
public $photos = []; // Untuk menampung file baru yang diupload
|
||||
public $existingPhotos = []; // Untuk menampilkan foto yang sudah ada saat edit
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFilterCategory()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->resetForm();
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$service = Service::findOrFail($id);
|
||||
|
||||
$this->serviceId = $service->id;
|
||||
$this->name = $service->name;
|
||||
$this->category_id = $service->category_id;
|
||||
$this->description = $service->description;
|
||||
$this->existingPhotos = $service->photo ?? []; // Tampilkan foto yang sudah ada
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'name' => 'required',
|
||||
'category_id' => 'required',
|
||||
'photos.*' => 'image|max:2048', // Validasi tiap file (max 2MB)
|
||||
]);
|
||||
|
||||
$paths = $this->existingPhotos;
|
||||
if ($this->photos) {
|
||||
if (!Storage::disk('public')->exists('services')) {
|
||||
Storage::disk('public')->makeDirectory('services');
|
||||
}
|
||||
|
||||
foreach ($this->photos as $photo) {
|
||||
$paths[] = $photo->store('services', 'public');
|
||||
}
|
||||
}
|
||||
|
||||
Service::updateOrCreate(
|
||||
['id' => $this->serviceId],
|
||||
[
|
||||
'name' => $this->name,
|
||||
'category_id' => $this->category_id,
|
||||
'description' => $this->description,
|
||||
'photo' => $paths,
|
||||
]
|
||||
);
|
||||
|
||||
$this->isModalOpen = false;
|
||||
$this->resetForm();
|
||||
|
||||
Toaster::success('Data layanan berhasil disimpan.');
|
||||
}
|
||||
|
||||
public function removePhoto($index)
|
||||
{
|
||||
unset($this->existingPhotos[$index]);
|
||||
$this->existingPhotos = array_values($this->existingPhotos);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$service = Service::findOrFail($id);
|
||||
if ($service->photo) {
|
||||
foreach ($service->photo as $path) {
|
||||
Storage::disk('public')->delete($path);
|
||||
}
|
||||
}
|
||||
$service->delete();
|
||||
Toaster::success('Data layanan berhasil dihapus.');
|
||||
}
|
||||
|
||||
private function resetForm()
|
||||
{
|
||||
$this->serviceId = null;
|
||||
$this->name = '';
|
||||
$this->category_id = '';
|
||||
$this->description = '';
|
||||
$this->photos = []; // Reset input file
|
||||
$this->existingPhotos = []; // Reset foto yang sudah ada
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = Service::with('category');
|
||||
|
||||
if ($this->search) {
|
||||
$query->where('name', 'like', "%{$this->search}%");
|
||||
}
|
||||
|
||||
if ($this->filterCategory) {
|
||||
$query->where('category_id', $this->filterCategory);
|
||||
}
|
||||
|
||||
return view('livewire.admin.service-manager', [
|
||||
'services' => $query->latest()->paginate(10),
|
||||
'categories' => ServiceCategory::pluck('name', 'id')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class SiteSettings extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
// Properti Site & SEO
|
||||
public $site_name, $site_description, $meta_keywords;
|
||||
|
||||
// Properti Kontak Klinik
|
||||
public $clinic_address, $clinic_phone, $clinic_email;
|
||||
|
||||
// Properti Koordinat (Tambahan)
|
||||
public $clinic_latitude, $clinic_longitude;
|
||||
|
||||
// Media
|
||||
public $logo, $favicon, $existing_logo, $existing_favicon;
|
||||
|
||||
// Media Sosial
|
||||
public $social_facebook, $social_instagram, $social_twitter;
|
||||
|
||||
// Theme Settings
|
||||
public $accent, $base;
|
||||
|
||||
// Properti Operasional
|
||||
public $maintenance_mode, $registration_open;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Load data dari Model Setting
|
||||
$settings = [
|
||||
'site_name',
|
||||
'site_description',
|
||||
'meta_keywords',
|
||||
'clinic_address',
|
||||
'clinic_phone',
|
||||
'clinic_email',
|
||||
'clinic_latitude',
|
||||
'clinic_longitude',
|
||||
'accent_color',
|
||||
'base_color',
|
||||
'site_logo',
|
||||
'site_favicon',
|
||||
'social_facebook',
|
||||
'social_instagram',
|
||||
'social_twitter',
|
||||
'maintenance_mode',
|
||||
'registration_open',
|
||||
];
|
||||
|
||||
foreach ($settings as $key) {
|
||||
$value = Setting::get($key);
|
||||
|
||||
if (in_array($key, ['maintenance_mode', 'registration_open'])) {
|
||||
$this->{$key} = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
||||
} elseif ($key === 'accent_color') {
|
||||
$this->accent = $value;
|
||||
} elseif ($key === 'base_color') {
|
||||
$this->base = $value;
|
||||
} elseif ($key === 'site_logo') {
|
||||
$this->existing_logo = $value;
|
||||
} elseif ($key === 'site_favicon') {
|
||||
$this->existing_favicon = $value;
|
||||
} else {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'site_name' => 'required|string|max:255',
|
||||
'clinic_email' => 'nullable|email',
|
||||
'clinic_latitude' => 'nullable|string', // Validasi latitude
|
||||
'clinic_longitude' => 'nullable|string', // Validasi longitude
|
||||
'accent' => 'required',
|
||||
'base' => 'required',
|
||||
'logo' => 'nullable|image|max:1024', // Max 1MB
|
||||
'favicon' => 'nullable|image|max:512', // Max 512KB
|
||||
]);
|
||||
|
||||
// Simpan Data Text
|
||||
Setting::set('site_name', $this->site_name);
|
||||
Setting::set('site_description', $this->site_description);
|
||||
Setting::set('meta_keywords', $this->meta_keywords);
|
||||
Setting::set('clinic_address', $this->clinic_address);
|
||||
Setting::set('clinic_phone', $this->clinic_phone);
|
||||
Setting::set('clinic_email', $this->clinic_email);
|
||||
|
||||
// Simpan Data Koordinat
|
||||
Setting::set('clinic_latitude', $this->clinic_latitude);
|
||||
Setting::set('clinic_longitude', $this->clinic_longitude);
|
||||
|
||||
Setting::set('accent_color', $this->accent);
|
||||
Setting::set('base_color', $this->base);
|
||||
Setting::set('social_facebook', $this->social_facebook);
|
||||
Setting::set('social_instagram', $this->social_instagram);
|
||||
Setting::set('social_twitter', $this->social_twitter);
|
||||
|
||||
Setting::set('maintenance_mode', $this->maintenance_mode ? 'true' : 'false');
|
||||
Setting::set('registration_open', $this->registration_open ? 'true' : 'false');
|
||||
|
||||
// Handle Upload Logo
|
||||
if ($this->logo) {
|
||||
if ($this->existing_logo) Storage::disk('public')->delete(str_replace('/storage/', '', $this->existing_logo));
|
||||
Setting::set('site_logo', $this->logo->store('site', 'public'));
|
||||
}
|
||||
|
||||
// Handle Upload Favicon
|
||||
if ($this->favicon) {
|
||||
if ($this->existing_favicon) Storage::disk('public')->delete(str_replace('/storage/', '', $this->existing_favicon));
|
||||
Setting::set('site_favicon', $this->favicon->store('site', 'public'));
|
||||
}
|
||||
|
||||
Cache::forget('site_settings');
|
||||
|
||||
$this->dispatch('saved');
|
||||
|
||||
Toaster::success('Pengaturan klinik berhasil diperbarui!');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.site-settings');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class UserManager extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $userId, $name, $email, $password, $selectedRole;
|
||||
public $search = '';
|
||||
public $isModalOpen = false;
|
||||
public $filterRole = '';
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = User::query();
|
||||
|
||||
// Filter berdasarkan Pencarian (Nama/Email)
|
||||
if ($this->search) {
|
||||
$query->where(function ($q) {
|
||||
$q->where('name', 'like', '%' . $this->search . '%')
|
||||
->orWhere('email', 'like', '%' . $this->search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// Filter berdasarkan Role
|
||||
if ($this->filterRole) {
|
||||
$query->role($this->filterRole); // Scope dari Spatie Permission
|
||||
}
|
||||
|
||||
return view('livewire.admin.user-manager', [
|
||||
'users' => $query->latest()->paginate(10),
|
||||
'roles' => Role::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->reset(['userId', 'name', 'email', 'password', 'selectedRole']);
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function edit(User $user)
|
||||
{
|
||||
$this->userId = $user->id;
|
||||
$this->name = $user->name;
|
||||
$this->email = $user->email;
|
||||
$this->selectedRole = $user->roles->pluck('name')->first();
|
||||
$this->password = ''; // Kosongkan password saat edit
|
||||
$this->isModalOpen = true;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email,' . $this->userId,
|
||||
'selectedRole' => 'required',
|
||||
];
|
||||
|
||||
// Password hanya wajib jika user baru
|
||||
if (!$this->userId) {
|
||||
$rules['password'] = 'required|min:8';
|
||||
}
|
||||
|
||||
$this->validate($rules);
|
||||
|
||||
$data = [
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
];
|
||||
|
||||
if ($this->password) {
|
||||
$data['password'] = Hash::make($this->password);
|
||||
}
|
||||
|
||||
$user = User::updateOrCreate(
|
||||
['id' => $this->userId],
|
||||
$data
|
||||
);
|
||||
|
||||
// Sinkronisasi Role (Spatie)
|
||||
$user->syncRoles($this->selectedRole);
|
||||
|
||||
Toaster::success($this->userId ? 'User berhasil diperbarui!' : 'User berhasil dibuat!');
|
||||
$this->isModalOpen = false;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
if ($user->id === auth()->id()) {
|
||||
Toaster::error('Anda tidak bisa menghapus akun sendiri!');
|
||||
return;
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
Toaster::success('User telah dihapus.');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\Setting;
|
||||
|
||||
class AboutPage extends Component
|
||||
{
|
||||
public array $settings = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Ambil semua setting → key => value
|
||||
$this->settings = Setting::pluck('value', 'key')->toArray();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.about-page')
|
||||
->layout('components.guest-layout');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use App\Models\Patient;
|
||||
use Livewire\Component;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CompleteProfile extends Component
|
||||
{
|
||||
public function mount()
|
||||
{
|
||||
// Proteksi di sini agar user yang sudah jadi 'patient' tidak bisa akses halaman ini lagi
|
||||
if (auth()->user()->patient()->exists()) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
// Properties sesuai kolom database
|
||||
public $nik, $place_of_birth, $date_of_birth, $gender, $blood_type;
|
||||
public $phone, $address;
|
||||
public $emergency_contact_name, $emergency_contact_phone, $emergency_contact_relation;
|
||||
public $insurance_type = 'Umum'; // Default Umum
|
||||
public $insurance_number;
|
||||
|
||||
protected $rules = [
|
||||
'nik' => 'required|digits:16|unique:patients,nik',
|
||||
'place_of_birth' => 'required|string',
|
||||
'date_of_birth' => 'required|date',
|
||||
'gender' => 'required|in:L,P',
|
||||
'blood_type' => 'nullable|in:A,B,AB,O,-',
|
||||
'phone' => 'required|numeric|min_digits:10',
|
||||
'address' => 'required|min:10',
|
||||
'emergency_contact_name' => 'nullable|string',
|
||||
'emergency_contact_phone' => 'nullable|numeric',
|
||||
'emergency_contact_relation' => 'nullable|string',
|
||||
'insurance_type' => 'required|in:Umum,BPJS,Asuransi Swasta',
|
||||
'insurance_number' => 'required_if:insurance_type,BPJS,Asuransi Swasta',
|
||||
];
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
try {
|
||||
DB::transaction(function () {
|
||||
// 1. Buat data pasien
|
||||
Patient::create([
|
||||
'user_id' => auth()->id(),
|
||||
'nik' => $this->nik,
|
||||
'place_of_birth' => $this->place_of_birth,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'gender' => $this->gender,
|
||||
'blood_type' => $this->blood_type,
|
||||
'phone' => $this->phone,
|
||||
'address' => $this->address,
|
||||
'insurance_type' => $this->insurance_type,
|
||||
'insurance_number' => $this->insurance_number,
|
||||
]);
|
||||
|
||||
// 2. Berikan role 'patient'
|
||||
$user = auth()->user();
|
||||
$user->syncRoles(['patient']); // Gunakan assignRole atau syncRoles
|
||||
|
||||
// 3. Hapus role 'guest' jika ada
|
||||
$user->removeRole('guest');
|
||||
});
|
||||
|
||||
Toaster::success('Profil berhasil dilengkapi!');
|
||||
|
||||
// Redirect ke dashboard agar session di-refresh
|
||||
return redirect()->route('dashboard');
|
||||
} catch (\Exception $e) {
|
||||
// Tampilkan error asli agar kamu tahu apa yang salah (misal: kolom kurang)
|
||||
logger($e->getMessage());
|
||||
Toaster::error('Gagal simpan: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.complete-profile');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.dashboard');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use App\Models\Doctor;
|
||||
use Livewire\Component;
|
||||
|
||||
class DoctorPage extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.doctor-page', [
|
||||
'doctors' => Doctor::latest()->get()
|
||||
])->layout('components.guest-layout');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use App\Models\ServiceCategory;
|
||||
use Livewire\Component;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Service;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class LandingPage extends Component
|
||||
{
|
||||
public $settings = [];
|
||||
public $services = [];
|
||||
public $selectedService = null;
|
||||
public $showModal = false; // Properti pengontrol modal secara aman
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->settings = Setting::pluck('value', 'key')->toArray();
|
||||
$this->services = ServiceCategory::with('services')->get();
|
||||
}
|
||||
|
||||
public function showServiceDetail($id)
|
||||
{
|
||||
// Memuat service lengkap beserta kategori pendukungnya
|
||||
$this->selectedService = Service::with('category')->find($id);
|
||||
|
||||
if ($this->selectedService) {
|
||||
$this->showModal = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
{
|
||||
$this->selectedService = null;
|
||||
$this->showModal = false;
|
||||
}
|
||||
|
||||
public function copyAddress()
|
||||
{
|
||||
Toaster::success('Alamat berhasil disalin!');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.landing-page')
|
||||
->layout('components.guest-layout');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use App\Models\News;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class NewsIndex extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.news-index', [
|
||||
// Menggunakan with('category') untuk mencegah N+1 query dan error JSON
|
||||
'news' => News::where('is_published', true)
|
||||
->with('category')
|
||||
->latest()
|
||||
->paginate(9)
|
||||
])->layout('components.guest-layout', ['title' => 'Berita & Edukasi Kesehatan']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Guest;
|
||||
|
||||
use App\Models\News;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NewsShow extends Component
|
||||
{
|
||||
public News $news;
|
||||
|
||||
// Nama variabel di mount() harus sama dengan nama parameter di Route {news:slug}
|
||||
public function mount(News $news)
|
||||
{
|
||||
// Pastikan berita sudah dipublikasikan
|
||||
if (!$news->is_published) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$this->news = $news;
|
||||
|
||||
// Tambah view count
|
||||
$this->news->increment('view_count');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.guest.news-show')
|
||||
->layout('components.guest-layout', [
|
||||
'title' => $this->news->title,
|
||||
// SEO: Mengambil potongan konten untuk meta description
|
||||
'description' => Str::limit(strip_tags($this->news->content), 160)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use App\Models\Appointment;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class BookingAntrean extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $appointment_date;
|
||||
public $notes;
|
||||
public $showTicket = false;
|
||||
public $selectedAppointment = null;
|
||||
public $doctor_id;
|
||||
public $service_category_id;
|
||||
public $filter_doctor = '';
|
||||
|
||||
protected $messages = [
|
||||
'appointment_date.required' => 'Tanggal pendaftaran wajib diisi.',
|
||||
'appointment_date.after_or_equal' => 'Tanggal pendaftaran tidak boleh di masa lalu.',
|
||||
'service_category_id.required' => 'Poli / Layanan wajib dipilih.',
|
||||
'service_category_id.exists' => 'Poli yang dipilih tidak valid.',
|
||||
'doctor_id.required' => 'Dokter wajib dipilih.',
|
||||
'doctor_id.exists' => 'Dokter yang dipilih tidak valid.',
|
||||
'notes.required' => 'Keluhan singkat wajib diisi.',
|
||||
'notes.max' => 'Keluhan singkat tidak boleh lebih dari 255 karakter.',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->appointment_date = date('Y-m-d');
|
||||
|
||||
$this->service_category_id = \App\Models\ServiceCategory::first()?->id;
|
||||
$this->doctor_id = \App\Models\Doctor::first()?->id;
|
||||
}
|
||||
|
||||
// Fungsi untuk membatalkan antrean
|
||||
public function cancelAppointment($id)
|
||||
{
|
||||
$appointment = Appointment::where('patient_id', Auth::id())
|
||||
->where('status', 'waiting')
|
||||
->findOrFail($id);
|
||||
|
||||
$appointment->update(['status' => 'cancelled']);
|
||||
Toaster::success('Antrean berhasil dibatalkan.');
|
||||
}
|
||||
|
||||
// Fungsi untuk mengambil data tiket dan buka modal
|
||||
public function showTicketModal($id)
|
||||
{
|
||||
$this->selectedAppointment = Appointment::with('patient')->findOrFail($id);
|
||||
|
||||
// Pastikan variabel showTicket tetap true jika Anda masih menggunakannya untuk @if di blade
|
||||
$this->showTicket = true;
|
||||
|
||||
// Membuka modal menggunakan Flux Javascript API
|
||||
$this->js("Flux.modal('ticket-modal').show()");
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'appointment_date' => 'required|date|after_or_equal:today',
|
||||
'doctor_id' => 'required|exists:doctors,id',
|
||||
'service_category_id' => 'required|exists:service_categories,id',
|
||||
'notes' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
// Cek duplikasi: 1 pasien, 1 hari, 1 dokter
|
||||
$exists = Appointment::where('patient_id', Auth::id())
|
||||
->where('doctor_id', $this->doctor_id)
|
||||
->whereDate('appointment_date', $this->appointment_date)
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
Toaster::error('Anda sudah terdaftar untuk dokter ini di tanggal tersebut.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Nomor antrean spesifik per DOKTER dan per TANGGAL
|
||||
$lastQueue = Appointment::where('doctor_id', $this->doctor_id)
|
||||
->whereDate('appointment_date', $this->appointment_date)
|
||||
->max('queue_number') ?? 0;
|
||||
|
||||
$newApp = Appointment::create([
|
||||
'patient_id' => Auth::id(),
|
||||
'doctor_id' => $this->doctor_id,
|
||||
'service_category_id' => $this->service_category_id,
|
||||
'appointment_date' => $this->appointment_date,
|
||||
'queue_number' => $lastQueue + 1,
|
||||
'notes' => $this->notes,
|
||||
'status' => 'waiting',
|
||||
'created_by' => Auth::id(),
|
||||
]);
|
||||
|
||||
$this->reset(['notes', 'doctor_id', 'service_category_id']);
|
||||
$this->showTicketModal($newApp->id);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// Ambil nomor yang statusnya 'calling' hari ini
|
||||
$currentCalling = Appointment::whereDate('appointment_date', date('Y-m-d'))
|
||||
->where('status', 'calling')
|
||||
->when($this->filter_doctor, function ($query) {
|
||||
return $query->where('doctor_id', $this->filter_doctor);
|
||||
})
|
||||
->with(['patient', 'doctor', 'serviceCategory']) // Eager load agar tidak error
|
||||
->latest('updated_at') // Ambil yang paling baru dipanggil
|
||||
->first();
|
||||
|
||||
return view('livewire.patient.booking-antrean', [
|
||||
'myAppointments' => Appointment::where('patient_id', Auth::id())
|
||||
->latest()
|
||||
->paginate(5),
|
||||
'currentCalling' => $currentCalling, // Kirim ke view
|
||||
'categories' => \App\Models\ServiceCategory::all(), // Data Poli
|
||||
'doctors' => \App\Models\Doctor::all(), // Data Dokter
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use App\Models\Patient;
|
||||
use Livewire\Component;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CompleteProfile extends Component
|
||||
{
|
||||
// Properties sesuai kolom database
|
||||
public $nik, $place_of_birth, $date_of_birth, $gender, $blood_type;
|
||||
public $phone, $address;
|
||||
public $emergency_contact_name, $emergency_contact_phone, $emergency_contact_relation;
|
||||
public $insurance_type = 'Umum'; // Default Umum
|
||||
public $insurance_number;
|
||||
|
||||
protected $rules = [
|
||||
'nik' => 'required|digits:16|unique:patients,nik',
|
||||
'place_of_birth' => 'required|string',
|
||||
'date_of_birth' => 'required|date',
|
||||
'gender' => 'required|in:L,P',
|
||||
'blood_type' => 'nullable|in:A,B,AB,O,-',
|
||||
'phone' => 'required|numeric|min_digits:10',
|
||||
'address' => 'required|min:10',
|
||||
'emergency_contact_name' => 'nullable|string',
|
||||
'emergency_contact_phone' => 'nullable|numeric',
|
||||
'emergency_contact_relation' => 'nullable|string',
|
||||
'insurance_type' => 'required|in:Umum,BPJS,Asuransi Swasta',
|
||||
'insurance_number' => 'required_if:insurance_type,BPJS,Asuransi Swasta',
|
||||
];
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
try {
|
||||
DB::transaction(function () {
|
||||
// 1. Buat data pasien
|
||||
Patient::create([
|
||||
'user_id' => auth()->id(),
|
||||
'nik' => $this->nik,
|
||||
'place_of_birth' => $this->place_of_birth,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'gender' => $this->gender,
|
||||
'blood_type' => $this->blood_type,
|
||||
'phone' => $this->phone,
|
||||
'address' => $this->address,
|
||||
'insurance_type' => $this->insurance_type,
|
||||
'insurance_number' => $this->insurance_number,
|
||||
]);
|
||||
|
||||
// 2. Berikan role 'patient'
|
||||
$user = auth()->user();
|
||||
$user->syncRoles('patient'); // Gunakan assignRole atau syncRoles
|
||||
|
||||
// 3. Hapus role 'guest' jika ada
|
||||
$user->removeRole('guest');
|
||||
});
|
||||
|
||||
Toaster::success('Profil berhasil dilengkapi!');
|
||||
|
||||
// Redirect ke dashboard agar session di-refresh
|
||||
return redirect()->route('dashboard');
|
||||
} catch (\Exception $e) {
|
||||
// Tampilkan error asli agar kamu tahu apa yang salah (misal: kolom kurang)
|
||||
logger($e->getMessage());
|
||||
Toaster::error('Gagal simpan: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.patient.complete-profile');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use App\Models\Appointment;
|
||||
use App\Models\News;
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
$userId = auth()->id();
|
||||
$today = date('Y-m-d');
|
||||
|
||||
return view('livewire.patient.dashboard', [
|
||||
'currentAppointment' => Appointment::with(['serviceCategory', 'doctor'])
|
||||
->where('patient_id', $userId)
|
||||
->whereDate('appointment_date', $today)
|
||||
->whereIn('status', ['waiting', 'calling'])
|
||||
->first(),
|
||||
|
||||
'history' => Appointment::with(['serviceCategory'])
|
||||
->where('patient_id', $userId)
|
||||
->where('appointment_date', '<', $today)
|
||||
->orderBy('appointment_date', 'desc')
|
||||
->take(3)
|
||||
->get(),
|
||||
|
||||
'news' => News::where('is_published', true)
|
||||
->latest() // Sama dengan orderBy('created_at', 'desc')
|
||||
->take(3)
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use App\Models\News as NewsModel;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class News extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $search = '';
|
||||
|
||||
protected $queryString = [
|
||||
'search' => ['except' => ''],
|
||||
];
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.patient.news.news', [
|
||||
'news' => NewsModel::with('category')
|
||||
->where('is_published', true) // Pastikan hanya berita yang terbit
|
||||
->where('title', 'like', '%' . $this->search . '%')
|
||||
->latest()
|
||||
->paginate(12) // Gunakan kelipatan 3 atau 4 untuk grid yang pas
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use App\Models\News;
|
||||
use Livewire\Component;
|
||||
|
||||
class NewsDetail extends Component
|
||||
{
|
||||
public News $news;
|
||||
|
||||
public function mount(News $news)
|
||||
{
|
||||
$news->increment('view_count');
|
||||
|
||||
$this->news = $news->load('category');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.patient.news.news-detail')
|
||||
->layout('layouts.app'); // Sesuaikan dengan layout Anda
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Patient;
|
||||
|
||||
use Livewire\Component;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class PatientProfile extends Component
|
||||
{
|
||||
public $patient;
|
||||
|
||||
// Properti Form Lengkap
|
||||
public $name, $nik, $place_of_birth, $date_of_birth, $gender, $blood_type;
|
||||
public $phone, $address;
|
||||
public $insurance_type, $insurance_number;
|
||||
public $emergency_contact_name, $emergency_contact_phone, $emergency_contact_relation;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
// Ambil user yang login beserta relasi patient-nya
|
||||
$user = auth()->user()->load('patient');
|
||||
|
||||
if ($user->patient) {
|
||||
$this->patient = $user->patient;
|
||||
|
||||
// Mapping data dari database ke properti form
|
||||
$this->name = $user->name;
|
||||
$this->nik = $this->patient->nik;
|
||||
$this->place_of_birth = $this->patient->place_of_birth;
|
||||
$this->date_of_birth = $this->patient->date_of_birth;
|
||||
$this->gender = $this->patient->gender;
|
||||
$this->blood_type = $this->patient->blood_type;
|
||||
$this->phone = $this->patient->phone;
|
||||
$this->address = $this->patient->address;
|
||||
$this->insurance_type = $this->patient->insurance_type;
|
||||
$this->insurance_number = $this->patient->insurance_number;
|
||||
$this->emergency_contact_name = $this->patient->emergency_contact_name;
|
||||
$this->emergency_contact_phone = $this->patient->emergency_contact_phone;
|
||||
$this->emergency_contact_relation = $this->patient->emergency_contact_relation;
|
||||
} else {
|
||||
// Jika user punya role patient tapi data di tabel patients hilang
|
||||
return redirect()->route('patient.complete-profile')->with('error', 'Data profil Anda tidak ditemukan. Silakan lengkapi profil Anda terlebih dahulu.');
|
||||
}
|
||||
}
|
||||
|
||||
public function updateProfile()
|
||||
{
|
||||
// Validasi data
|
||||
$this->validate([
|
||||
'phone' => 'required|numeric',
|
||||
'address' => 'required|min:10',
|
||||
'place_of_birth' => 'required',
|
||||
'date_of_birth' => 'required|date',
|
||||
'insurance_type' => 'required',
|
||||
'insurance_number' => 'required_if:insurance_type,BPJS,Asuransi Swasta',
|
||||
]);
|
||||
|
||||
// Update data di tabel patients
|
||||
$this->patient->update([
|
||||
'place_of_birth' => $this->place_of_birth,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'gender' => $this->gender,
|
||||
'blood_type' => $this->blood_type,
|
||||
'phone' => $this->phone,
|
||||
'address' => $this->address,
|
||||
'insurance_type' => $this->insurance_type,
|
||||
'insurance_number' => $this->insurance_number,
|
||||
'emergency_contact_name' => $this->emergency_contact_name,
|
||||
'emergency_contact_phone' => $this->emergency_contact_phone,
|
||||
'emergency_contact_relation' => $this->emergency_contact_relation,
|
||||
]);
|
||||
|
||||
Toaster::success('Profil berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.patient.patient-profile');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Settings;
|
||||
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Title('Appearance settings')]
|
||||
class Appearance extends Component
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Settings;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use App\Livewire\Actions\Logout;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeleteUserForm extends Component
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
public string $password = '';
|
||||
|
||||
/**
|
||||
* Delete the currently authenticated user.
|
||||
*/
|
||||
public function deleteUser(Logout $logout): void
|
||||
{
|
||||
$this->validate([
|
||||
'password' => $this->currentPasswordRules(),
|
||||
]);
|
||||
|
||||
tap(Auth::user(), $logout(...))->delete();
|
||||
|
||||
$this->redirect('/', navigate: true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Settings;
|
||||
|
||||
use App\Concerns\ProfileValidationRules;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Title('Profile settings')]
|
||||
class Profile extends Component
|
||||
{
|
||||
use ProfileValidationRules;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(): void
|
||||
{
|
||||
$this->name = Auth::user()->name;
|
||||
$this->email = Auth::user()->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the profile information for the currently authenticated user.
|
||||
*/
|
||||
public function updateProfileInformation(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$validated = $this->validate($this->profileRules($user->id));
|
||||
|
||||
$user->fill($validated);
|
||||
|
||||
if ($user->isDirty('email')) {
|
||||
$user->email_verified_at = null;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
$this->dispatch('profile-updated', name: $user->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email verification notification to the current user.
|
||||
*/
|
||||
public function resendVerificationNotification(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->hasVerifiedEmail()) {
|
||||
$this->redirectIntended(default: route('dashboard', absolute: false));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->sendEmailVerificationNotification();
|
||||
|
||||
Session::flash('status', 'verification-link-sent');
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function hasUnverifiedEmail(): bool
|
||||
{
|
||||
return Auth::user() instanceof MustVerifyEmail && ! Auth::user()->hasVerifiedEmail();
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function showDeleteUser(): bool
|
||||
{
|
||||
return ! Auth::user() instanceof MustVerifyEmail
|
||||
|| (Auth::user() instanceof MustVerifyEmail && Auth::user()->hasVerifiedEmail());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Settings;
|
||||
|
||||
use App\Concerns\PasswordValidationRules;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Actions\ConfirmTwoFactorAuthentication;
|
||||
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
|
||||
use Laravel\Fortify\Actions\EnableTwoFactorAuthentication;
|
||||
use Laravel\Fortify\Features;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Title('Security settings')]
|
||||
class Security extends Component
|
||||
{
|
||||
use PasswordValidationRules;
|
||||
|
||||
public string $current_password = '';
|
||||
|
||||
public string $password = '';
|
||||
|
||||
public string $password_confirmation = '';
|
||||
|
||||
#[Locked]
|
||||
public bool $canManageTwoFactor;
|
||||
|
||||
#[Locked]
|
||||
public bool $twoFactorEnabled;
|
||||
|
||||
#[Locked]
|
||||
public bool $requiresConfirmation;
|
||||
|
||||
#[Locked]
|
||||
public string $qrCodeSvg = '';
|
||||
|
||||
#[Locked]
|
||||
public string $manualSetupKey = '';
|
||||
|
||||
public bool $showModal = false;
|
||||
|
||||
public bool $showVerificationStep = false;
|
||||
|
||||
#[Validate('required|string|size:6', onUpdate: false)]
|
||||
public string $code = '';
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(DisableTwoFactorAuthentication $disableTwoFactorAuthentication): void
|
||||
{
|
||||
$this->canManageTwoFactor = Features::canManageTwoFactorAuthentication();
|
||||
|
||||
if ($this->canManageTwoFactor) {
|
||||
if (Fortify::confirmsTwoFactorAuthentication() && is_null(auth()->user()->two_factor_confirmed_at)) {
|
||||
$disableTwoFactorAuthentication(auth()->user());
|
||||
}
|
||||
|
||||
$this->twoFactorEnabled = auth()->user()->hasEnabledTwoFactorAuthentication();
|
||||
$this->requiresConfirmation = Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the password for the currently authenticated user.
|
||||
*/
|
||||
public function updatePassword(): void
|
||||
{
|
||||
try {
|
||||
$validated = $this->validate([
|
||||
'current_password' => $this->currentPasswordRules(),
|
||||
'password' => $this->passwordRules(),
|
||||
]);
|
||||
} catch (ValidationException $e) {
|
||||
$this->reset('current_password', 'password', 'password_confirmation');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Auth::user()->update([
|
||||
'password' => $validated['password'],
|
||||
]);
|
||||
|
||||
$this->reset('current_password', 'password', 'password_confirmation');
|
||||
|
||||
$this->dispatch('password-updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable two-factor authentication for the user.
|
||||
*/
|
||||
public function enable(EnableTwoFactorAuthentication $enableTwoFactorAuthentication): void
|
||||
{
|
||||
$enableTwoFactorAuthentication(auth()->user());
|
||||
|
||||
if (! $this->requiresConfirmation) {
|
||||
$this->twoFactorEnabled = auth()->user()->hasEnabledTwoFactorAuthentication();
|
||||
}
|
||||
|
||||
$this->loadSetupData();
|
||||
|
||||
$this->showModal = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the two-factor authentication setup data for the user.
|
||||
*/
|
||||
private function loadSetupData(): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
try {
|
||||
$this->qrCodeSvg = $user?->twoFactorQrCodeSvg();
|
||||
$this->manualSetupKey = decrypt($user->two_factor_secret);
|
||||
} catch (Exception) {
|
||||
$this->addError('setupData', 'Failed to fetch setup data.');
|
||||
|
||||
$this->reset('qrCodeSvg', 'manualSetupKey');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the two-factor verification step if necessary.
|
||||
*/
|
||||
public function showVerificationIfNecessary(): void
|
||||
{
|
||||
if ($this->requiresConfirmation) {
|
||||
$this->showVerificationStep = true;
|
||||
|
||||
$this->resetErrorBag();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->closeModal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm two-factor authentication for the user.
|
||||
*/
|
||||
public function confirmTwoFactor(ConfirmTwoFactorAuthentication $confirmTwoFactorAuthentication): void
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$confirmTwoFactorAuthentication(auth()->user(), $this->code);
|
||||
|
||||
$this->closeModal();
|
||||
|
||||
$this->twoFactorEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset two-factor verification state.
|
||||
*/
|
||||
public function resetVerification(): void
|
||||
{
|
||||
$this->reset('code', 'showVerificationStep');
|
||||
|
||||
$this->resetErrorBag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable two-factor authentication for the user.
|
||||
*/
|
||||
public function disable(DisableTwoFactorAuthentication $disableTwoFactorAuthentication): void
|
||||
{
|
||||
$disableTwoFactorAuthentication(auth()->user());
|
||||
|
||||
$this->twoFactorEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the two-factor authentication modal.
|
||||
*/
|
||||
public function closeModal(): void
|
||||
{
|
||||
$this->reset(
|
||||
'code',
|
||||
'manualSetupKey',
|
||||
'qrCodeSvg',
|
||||
'showModal',
|
||||
'showVerificationStep',
|
||||
);
|
||||
|
||||
$this->resetErrorBag();
|
||||
|
||||
if (! $this->requiresConfirmation) {
|
||||
$this->twoFactorEnabled = auth()->user()->hasEnabledTwoFactorAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current modal configuration state.
|
||||
*/
|
||||
public function getModalConfigProperty(): array
|
||||
{
|
||||
if ($this->twoFactorEnabled) {
|
||||
return [
|
||||
'title' => __('Two-factor authentication enabled'),
|
||||
'description' => __('Two-factor authentication is now enabled. Scan the QR code or enter the setup key in your authenticator app.'),
|
||||
'buttonText' => __('Close'),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->showVerificationStep) {
|
||||
return [
|
||||
'title' => __('Verify authentication code'),
|
||||
'description' => __('Enter the 6-digit code from your authenticator app.'),
|
||||
'buttonText' => __('Continue'),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => __('Enable two-factor authentication'),
|
||||
'description' => __('To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app.'),
|
||||
'buttonText' => __('Continue'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Settings\TwoFactor;
|
||||
|
||||
use Exception;
|
||||
use Laravel\Fortify\Actions\GenerateNewRecoveryCodes;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
|
||||
class RecoveryCodes extends Component
|
||||
{
|
||||
#[Locked]
|
||||
public array $recoveryCodes = [];
|
||||
|
||||
/**
|
||||
* Mount the component.
|
||||
*/
|
||||
public function mount(): void
|
||||
{
|
||||
$this->loadRecoveryCodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new recovery codes for the user.
|
||||
*/
|
||||
public function regenerateRecoveryCodes(GenerateNewRecoveryCodes $generateNewRecoveryCodes): void
|
||||
{
|
||||
$generateNewRecoveryCodes(auth()->user());
|
||||
|
||||
$this->loadRecoveryCodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the recovery codes for the user.
|
||||
*/
|
||||
private function loadRecoveryCodes(): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->hasEnabledTwoFactorAuthentication() && $user->two_factor_recovery_codes) {
|
||||
try {
|
||||
$this->recoveryCodes = json_decode(decrypt($user->two_factor_recovery_codes), true);
|
||||
} catch (Exception) {
|
||||
$this->addError('recoveryCodes', 'Failed to load recovery codes');
|
||||
|
||||
$this->recoveryCodes = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
//use Illuminate\Database\Eloquent\SoftDeletes; // Tambahkan ini jika pakai softDeletes di migrasi
|
||||
|
||||
class Appointment extends Model
|
||||
{
|
||||
// use HasFactory, SoftDeletes;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Kolom yang boleh diisi secara massal.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
'service_category_id',
|
||||
'appointment_date',
|
||||
'queue_number',
|
||||
'status',
|
||||
'notes',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* Casting tipe data agar Carbon (Date) otomatis terformat.
|
||||
*/
|
||||
protected $casts = [
|
||||
'appointment_date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relasi ke User (sebagai Pasien).
|
||||
*/
|
||||
public function patient()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'patient_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Dokter (Tabel Doctors).
|
||||
*/
|
||||
public function doctor()
|
||||
{
|
||||
// Diarahkan ke model Doctor, bukan User
|
||||
return $this->belongsTo(Doctor::class, 'doctor_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Kategori Layanan (Poli).
|
||||
*/
|
||||
public function serviceCategory()
|
||||
{
|
||||
return $this->belongsTo(ServiceCategory::class, 'service_category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke MedicalRecord (jika sudah ada rekam medis untuk appointment ini).
|
||||
*/
|
||||
public function medicalRecord()
|
||||
{
|
||||
return $this->hasOne(MedicalRecord::class, 'appointment_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke User (siapa yang membuat data ini, Admin atau Pasien sendiri).
|
||||
*/
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope untuk mempermudah filter antrean hari ini.
|
||||
*/
|
||||
public function scopeToday($query)
|
||||
{
|
||||
return $query->whereDate('appointment_date', today());
|
||||
}
|
||||
|
||||
public static function generateNextQueue($date)
|
||||
{
|
||||
return self::whereDate('appointment_date', $date)->count() + 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'slug'];
|
||||
|
||||
public function news()
|
||||
{
|
||||
return $this->hasMany(News::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Doctor extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'specialization',
|
||||
'phone',
|
||||
'email',
|
||||
'schedule',
|
||||
'photo',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'schedule' => 'array',
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MedicalRecord extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function patient()
|
||||
{
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->belongsTo(Doctor::class);
|
||||
}
|
||||
|
||||
public function appointment()
|
||||
{
|
||||
return $this->belongsTo(Appointment::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
||||
class News extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'title',
|
||||
'slug',
|
||||
'image',
|
||||
'content',
|
||||
'user_id',
|
||||
'is_published'
|
||||
];
|
||||
|
||||
// Otomatis buat slug saat title diisi
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating(function ($news) {
|
||||
$news->slug = Str::slug($news->title);
|
||||
});
|
||||
}
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor untuk URL Gambar
|
||||
* Cara panggil di Blade: {{ $item->image_url }}
|
||||
*/
|
||||
public function getImageUrlAttribute()
|
||||
{
|
||||
if ($this->image && Storage::disk('public')->exists($this->image)) {
|
||||
return asset('storage/' . $this->image);
|
||||
}
|
||||
|
||||
// Placeholder jika gambar tidak ada
|
||||
return 'https://placehold.co/600x400/f4f4f5/10b981?text=Klinik+News';
|
||||
}
|
||||
|
||||
protected function readTime(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function () {
|
||||
$words = str_word_count(strip_tags($this->content));
|
||||
$minutes = ceil($words / 200); // 200 kata per menit
|
||||
return $minutes < 1 ? 1 : $minutes;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Patient extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'medical_record_number',
|
||||
'user_id',
|
||||
'nik',
|
||||
'place_of_birth',
|
||||
'date_of_birth',
|
||||
'gender',
|
||||
'blood_type',
|
||||
'phone',
|
||||
'address',
|
||||
'emergency_contact_name',
|
||||
'emergency_contact_phone',
|
||||
'emergency_contact_relation',
|
||||
'insurance_type',
|
||||
'insurance_number',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function medicalRecords()
|
||||
{
|
||||
return $this->hasMany(MedicalRecord::class);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::deleting(function ($patient) {
|
||||
// Hapus user yang terhubung dengan patient ini
|
||||
if ($patient->user) {
|
||||
$patient->user->delete();
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($patient) {
|
||||
if (empty($patient->medical_record_number)) {
|
||||
$prefix = 'RM' . now()->format('ym');
|
||||
|
||||
$latestNumber = static::where('medical_record_number', 'like', $prefix . '%')
|
||||
->orderByDesc('medical_record_number')
|
||||
->value('medical_record_number');
|
||||
|
||||
if ($latestNumber) {
|
||||
$nextNumber = ((int) substr($latestNumber, -4)) + 1;
|
||||
} else {
|
||||
$nextNumber = 1;
|
||||
}
|
||||
|
||||
$patient->medical_record_number = $prefix . str_pad($nextNumber, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'name',
|
||||
'description',
|
||||
'photo',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'photo' => 'array',
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ServiceCategory::class, 'category_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServiceCategory extends Model
|
||||
{
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function services()
|
||||
{
|
||||
return $this->hasMany(Service::class, 'category_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value'];
|
||||
|
||||
// Helper untuk mengambil value berdasarkan key
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
$setting = self::where('key', $key)->first();
|
||||
|
||||
$defaults = [
|
||||
'site_name' => 'Si Klinik',
|
||||
'site_description' => 'Sistem Informasi Klinik.',
|
||||
'accent_color' => 'indigo',
|
||||
'base_color' => 'zinc',
|
||||
];
|
||||
|
||||
if (!$setting) return $defaults[$key] ?? $default;
|
||||
|
||||
if (in_array($key, ['site_logo', 'site_favicon']) && $setting->value) {
|
||||
return Storage::url($setting->value);
|
||||
}
|
||||
|
||||
return $setting->value;
|
||||
}
|
||||
|
||||
// Helper untuk update atau create
|
||||
public static function set($key, $value)
|
||||
{
|
||||
return self::updateOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, TwoFactorAuthenticatable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's initials
|
||||
*/
|
||||
public function initials(): string
|
||||
{
|
||||
return Str::of($this->name)
|
||||
->explode(' ')
|
||||
->take(2)
|
||||
->map(fn($word) => Str::substr($word, 0, 1))
|
||||
->implode('');
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($user) {
|
||||
// Cari role guest, jika tidak ada maka buat otomatis
|
||||
$role = Role::firstOrCreate(['name' => 'guest', 'guard_name' => 'web']);
|
||||
|
||||
// Berikan role tersebut ke user baru
|
||||
$user->assignRole($role);
|
||||
});
|
||||
}
|
||||
|
||||
public function patient()
|
||||
{
|
||||
return $this->hasOne(Patient::class, 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
use Illuminate\Support\Facades\View;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureDefaults();
|
||||
|
||||
$settings = Cache::rememberForever('site_settings', function () {
|
||||
return [
|
||||
'name' => Setting::get('site_name', 'Nama Default'),
|
||||
'description' => Setting::get('site_description', 'Deskripsi Default'),
|
||||
'keywords' => Setting::get('meta_keywords', 'keyword1, keyword2'),
|
||||
'favicon' => Setting::get('site_favicon', ''),
|
||||
'logo' => Setting::get('site_logo', ''),
|
||||
'accent' => Setting::get('accent_color', 'indigo'),
|
||||
'base' => Setting::get('base_color', 'zinc'),
|
||||
'registration_open' => Setting::get('registration_open', 'true'),
|
||||
];
|
||||
});
|
||||
|
||||
$shades = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
|
||||
|
||||
// Share satu variabel $site agar rapi
|
||||
View::share('site', (object) $settings);
|
||||
View::share('themeShades', $shades);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure default behaviors for production-ready applications.
|
||||
*/
|
||||
protected function configureDefaults(): void
|
||||
{
|
||||
Date::use(CarbonImmutable::class);
|
||||
|
||||
DB::prohibitDestructiveCommands(
|
||||
app()->isProduction(),
|
||||
);
|
||||
|
||||
Password::defaults(
|
||||
fn(): ?Password => app()->isProduction()
|
||||
? Password::min(12)
|
||||
->mixedCase()
|
||||
->letters()
|
||||
->numbers()
|
||||
->symbols()
|
||||
->uncompromised()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Actions\Fortify\CreateNewUser;
|
||||
use App\Actions\Fortify\ResetUserPassword;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class FortifyServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureActions();
|
||||
$this->configureViews();
|
||||
$this->configureRateLimiting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Fortify actions.
|
||||
*/
|
||||
private function configureActions(): void
|
||||
{
|
||||
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
|
||||
Fortify::createUsersUsing(CreateNewUser::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Fortify views.
|
||||
*/
|
||||
private function configureViews(): void
|
||||
{
|
||||
Fortify::loginView(fn() => view('livewire.auth.login'));
|
||||
Fortify::verifyEmailView(fn() => view('livewire.auth.verify-email'));
|
||||
Fortify::twoFactorChallengeView(fn() => view('livewire.auth.two-factor-challenge'));
|
||||
Fortify::confirmPasswordView(fn() => view('livewire.auth.confirm-password'));
|
||||
// Fortify::registerView(fn () => view('livewire.auth.register'));
|
||||
|
||||
Fortify::registerView(function () {
|
||||
if (\App\Models\Setting::get('registration_open') === 'false') {
|
||||
\Masmerise\Toaster\Toaster::error('Pendaftaran pasien baru sedang ditutup.');
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
return view('livewire.auth.register');
|
||||
});
|
||||
|
||||
Fortify::resetPasswordView(fn() => view('livewire.auth.reset-password'));
|
||||
Fortify::requestPasswordResetLinkView(fn() => view('livewire.auth.forgot-password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure rate limiting.
|
||||
*/
|
||||
private function configureRateLimiting(): void
|
||||
{
|
||||
RateLimiter::for('two-factor', function (Request $request) {
|
||||
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
||||
});
|
||||
|
||||
RateLimiter::for('login', function (Request $request) {
|
||||
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())) . '|' . $request->ip());
|
||||
|
||||
return Limit::perMinute(5)->by($throttleKey);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class GuestLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.guest-layout');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->append(\App\Http\Middleware\CheckMaintenanceMode::class);
|
||||
|
||||
$middleware->alias([
|
||||
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
use App\Providers\FortifyServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
FortifyServiceProvider::class,
|
||||
];
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/livewire-starter-kit",
|
||||
"type": "project",
|
||||
"description": "The official Laravel starter kit for Livewire.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"framework"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"laravel-lang/common": "^6.7",
|
||||
"laravel-lang/locales": "^2.10",
|
||||
"laravel/fortify": "^1.30",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"livewire/blaze": "^1.0",
|
||||
"livewire/flux": "^2.9.0",
|
||||
"livewire/livewire": "^4.0",
|
||||
"masmerise/livewire-toaster": "^2.9",
|
||||
"spatie/laravel-permission": "^6.24"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^11.5.50"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"npm run dev\" --names='server,queue,vite'"
|
||||
],
|
||||
"lint": [
|
||||
"pint --parallel"
|
||||
],
|
||||
"lint:check": [
|
||||
"pint --parallel --test"
|
||||
],
|
||||
"ci:check": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"@test"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@lint:check",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'id'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'id_ID'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', '')),
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pdo\Mysql;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Fortify\Features;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which authentication guard Fortify will use while
|
||||
| authenticating users. This value should correspond with one of your
|
||||
| guards that is already present in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => 'web',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Password Broker
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which password broker Fortify can use when a user
|
||||
| is resetting their password. This configured value should match one
|
||||
| of your password brokers setup in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => 'users',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Username / Email
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value defines which model attribute should be considered as your
|
||||
| application's "username" field. Typically, this might be the email
|
||||
| address of the users but you are free to change this value here.
|
||||
|
|
||||
| Out of the box, Fortify expects forgot password and reset password
|
||||
| requests to have a field named 'email'. If the application uses
|
||||
| another name for the field you may define it below as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'username' => 'email',
|
||||
|
||||
'email' => 'email',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Lowercase Usernames
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value defines whether usernames should be lowercased before saving
|
||||
| them in the database, as some database system string fields are case
|
||||
| sensitive. You may disable this for your application if necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'lowercase_usernames' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Home Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the path where users will get redirected during
|
||||
| authentication or password reset when the operations are successful
|
||||
| and the user is authenticated. You are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'home' => '/dashboard',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Prefix / Subdomain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which prefix Fortify will assign to all the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| subdomain under which all of the Fortify routes will be available.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => '',
|
||||
|
||||
'domain' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which middleware Fortify will assign to the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| these middleware but typically this provided default is preferred.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Rate Limiting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default, Fortify will throttle logins to five requests per minute for
|
||||
| every email and IP address combination. However, if you would like to
|
||||
| specify a custom rate limiter to call then you may specify it here.
|
||||
|
|
||||
*/
|
||||
|
||||
'limiters' => [
|
||||
'login' => 'login',
|
||||
'two-factor' => 'two-factor',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register View Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify if the routes returning views should be disabled as
|
||||
| you may not need them when building your own application. This may be
|
||||
| especially true if you're writing a custom single-page application.
|
||||
|
|
||||
*/
|
||||
|
||||
'views' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Features
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some of the Fortify features are optional. You may disable the features
|
||||
| by removing them from this array. You're free to only remove some of
|
||||
| these features, or you can even remove all of these if you need to.
|
||||
|
|
||||
*/
|
||||
|
||||
'features' => [
|
||||
Features::registration(),
|
||||
Features::resetPasswords(),
|
||||
Features::emailVerification(),
|
||||
Features::twoFactorAuthentication([
|
||||
'confirm' => true,
|
||||
'confirmPassword' => true,
|
||||
// 'window' => 0
|
||||
]),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, // default 'role_id',
|
||||
'permission_pivot_key' => null, // default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||
*/
|
||||
'register_octane_reset_listener' => false,
|
||||
|
||||
/*
|
||||
* Events will fire when a role or permission is assigned/unassigned:
|
||||
* \Spatie\Permission\Events\RoleAttached
|
||||
* \Spatie\Permission\Events\RoleDetached
|
||||
* \Spatie\Permission\Events\PermissionAttached
|
||||
* \Spatie\Permission\Events\PermissionDetached
|
||||
*
|
||||
* To enable, set to true, and then create listeners to watch these events.
|
||||
*/
|
||||
'events_enabled' => false,
|
||||
|
||||
/*
|
||||
* Teams Feature.
|
||||
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||
* If you want the migrations to register the 'team_foreign_key', you must
|
||||
* set this to true before doing the migration.
|
||||
* If you already did the migration then you must make a new migration to also
|
||||
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||
* (view the latest version of this package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* The class to use to resolve the permissions team id
|
||||
*/
|
||||
'team_resolver' => \Spatie\Permission\DefaultTeamResolver::class,
|
||||
|
||||
/*
|
||||
* Passport Client Credentials Grant
|
||||
* When set to true the package will use Passports Client to check permissions
|
||||
*/
|
||||
|
||||
'use_passport_client_credentials' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to exception messages.
|
||||
* This could be considered an information leak in some contexts, so the default
|
||||
* setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
* See documentation to understand supported syntax.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
/*
|
||||
* The class to use for interpreting wildcard permissions.
|
||||
* If you need to modify delimiters, override the class and specify its name here.
|
||||
*/
|
||||
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||
|
||||
/* Cache-specific settings */
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session',
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* Add an additional second for every 100th word of the toast messages.
|
||||
*
|
||||
* Supported: true | false
|
||||
*/
|
||||
'accessibility' => true,
|
||||
|
||||
/**
|
||||
* The vertical alignment of the toast container.
|
||||
*
|
||||
* Supported: "bottom", "middle" or "top"
|
||||
*/
|
||||
'alignment' => 'top',
|
||||
|
||||
/**
|
||||
* Allow users to close toast messages prematurely.
|
||||
*
|
||||
* Supported: true | false
|
||||
*/
|
||||
'closeable' => true,
|
||||
|
||||
/**
|
||||
* The on-screen duration of each toast.
|
||||
*
|
||||
* Minimum: 3000 (in milliseconds)
|
||||
*/
|
||||
'duration' => 3000,
|
||||
|
||||
/**
|
||||
* The horizontal position of each toast.
|
||||
*
|
||||
* Supported: "center", "left" or "right"
|
||||
*/
|
||||
'position' => 'right',
|
||||
|
||||
/**
|
||||
* New toasts immediately replace similar ones, ensuring only one toast of a kind is visible at any time.
|
||||
* Takes precedence over the "suppress" option.
|
||||
*
|
||||
* Supported: true | false
|
||||
*/
|
||||
'replace' => false,
|
||||
|
||||
/**
|
||||
* Prevent the display of duplicate toast messages.
|
||||
*
|
||||
* Supported: true | false
|
||||
*/
|
||||
'suppress' => false,
|
||||
|
||||
/**
|
||||
* Whether messages passed as translation keys should be translated automatically.
|
||||
*
|
||||
* Supported: true | false
|
||||
*/
|
||||
'translate' => true,
|
||||
];
|
||||
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
*.sqlite*
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<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),
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
'two_factor_confirmed_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model has two-factor authentication configured.
|
||||
*/
|
||||
public function withTwoFactor(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'two_factor_secret' => encrypt('secret'),
|
||||
'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1'])),
|
||||
'two_factor_confirmed_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?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');
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
|
||||
$table->index(['queue', 'reserved_at', 'available_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,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::table('users', function (Blueprint $table) {
|
||||
$table->text('two_factor_secret')->after('password')->nullable();
|
||||
$table->text('two_factor_recovery_codes')->after('two_factor_secret')->nullable();
|
||||
$table->timestamp('two_factor_confirmed_at')->after('two_factor_recovery_codes')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_confirmed_at',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
<?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
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?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('patients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('nik', 16)->unique();
|
||||
$table->string('place_of_birth');
|
||||
$table->date('date_of_birth');
|
||||
|
||||
$table->enum('gender', ['L', 'P']);
|
||||
$table->enum('blood_type', ['A', 'B', 'AB', 'O', '-'])->nullable();
|
||||
|
||||
$table->string('phone');
|
||||
$table->text('address');
|
||||
|
||||
// Kontak Darurat
|
||||
$table->string('emergency_contact_name')->nullable();
|
||||
$table->string('emergency_contact_phone')->nullable();
|
||||
$table->string('emergency_contact_relation')->nullable();
|
||||
|
||||
$table->string('insurance_type')->default('Umum'); // Umum, BPJS, Asuransi Swasta
|
||||
$table->string('insurance_number')->nullable();
|
||||
|
||||
//$table->text('allergies')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('patients');
|
||||
}
|
||||
};
|
||||
|
|
@ -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('news', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')
|
||||
->nullable()
|
||||
->constrained()
|
||||
->onDelete('set null');
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('image')->nullable(); // Path untuk thumbnail berita
|
||||
$table->longText('content'); // Isi berita (bisa HTML dari Editor)
|
||||
$table->foreignId('user_id')->constrained(); // Siapa admin yang menulis
|
||||
$table->boolean('is_published')->default(false);
|
||||
$table->integer('view_count')->default(0); // Untuk statistik berita populer
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('news');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?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('appointments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Relasi Utama
|
||||
$table->foreignId('patient_id')->constrained('users')->onDelete('cascade');
|
||||
|
||||
$table->foreignId('doctor_id')->nullable()->constrained('doctors')->onDelete('set null');
|
||||
|
||||
$table->foreignId('service_category_id')->constrained('service_categories');
|
||||
|
||||
// Data Antrean
|
||||
$table->date('appointment_date');
|
||||
$table->integer('queue_number');
|
||||
|
||||
// Status & Keterangan
|
||||
$table->enum('status', ['waiting', 'calling', 'finished', 'cancelled','skipped'])->default('waiting');
|
||||
$table->text('notes')->nullable(); // Keluhan awal pasien
|
||||
|
||||
// Audit Trail
|
||||
$table->foreignId('created_by')->nullable()->constrained('users'); // Admin atau Pasien
|
||||
|
||||
$table->timestamps();
|
||||
//$table->softDeletes(); // Disarankan agar data tidak benar-benar hilang jika dihapus
|
||||
|
||||
// Constraint Unik
|
||||
$table->unique(['patient_id', 'appointment_date'], 'one_appointment_per_day');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('appointments');
|
||||
}
|
||||
};
|
||||
|
|
@ -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('doctors', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('name');
|
||||
$table->string('specialization'); // Spesialis
|
||||
$table->string('phone');
|
||||
$table->string('email')->nullable();
|
||||
$table->text('schedule')->nullable(); // Jadwal praktik
|
||||
$table->string('photo')->nullable(); // Foto dokter
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('doctors');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('service_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('service_categories');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('category_id')
|
||||
->constrained('service_categories')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->json('photo')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('patients', function (Blueprint $table) {
|
||||
$table->string('medical_record_number', 20)->nullable()->unique()->after('id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('patients', function (Blueprint $table) {
|
||||
$table->dropColumn('medical_record_number');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('medical_records', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('patient_id')->constrained('patients')->onDelete('cascade');
|
||||
$table->foreignId('appointment_id')->nullable()->constrained('appointments')->onDelete('set null');
|
||||
$table->foreignId('doctor_id')->nullable()->constrained('doctors')->onDelete('set null');
|
||||
|
||||
$table->text('symptoms'); // Keluhan Utama / Anamnesis
|
||||
$table->text('diagnosis'); // Hasil Diagnosa Dokter
|
||||
$table->text('treatment')->nullable(); // Tindakan / Resep Obat
|
||||
$table->text('notes')->nullable(); // Catatan Tambahan Dokter
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('medical_records');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
// User::factory()->create([
|
||||
// 'name' => 'Test User',
|
||||
// 'email' => 'test@example.com',
|
||||
// ]);
|
||||
|
||||
$this->call([
|
||||
SettingSeeder::class,
|
||||
RoleSeeder::class,
|
||||
PermissionSeeder::class,
|
||||
UserSeeder::class,
|
||||
ServiceCategorySeeder::class,
|
||||
ServiceSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue