Compare commits
No commits in common. "main" and "master" have entirely different histories.
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
62
.env.example
Normal file
62
.env.example
Normal file
@ -0,0 +1,62 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
DB_DATABASE=/var/www/physiotherapy-clinic/database/database.sqlite
|
||||
|
||||
#DB_CONNECTION=mysql
|
||||
#DB_HOST=127.0.0.1
|
||||
#DB_PORT=3306
|
||||
#DB_DATABASE=laravel
|
||||
#DB_USERNAME=root
|
||||
#DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailpit
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=443
|
||||
PUSHER_SCHEME=https
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
348
README.md
348
README.md
@ -1,3 +1,347 @@
|
||||
# physiotherapy-clinic
|
||||
# Physiotherapy Clinic Management System
|
||||
|
||||
Physiotherapy Clinic Management System
|
||||
A complete API-first physiotherapy clinic management system built with Laravel 10, SQLite, AdminLTE (Bootstrap 5), and Sanctum authentication.
|
||||
|
||||
## Features
|
||||
|
||||
- **API-First Architecture**: All business logic exposed via RESTful JSON APIs
|
||||
- **Multi-language Support**: Arabic and English with RTL support
|
||||
- **Role-based Access Control**: Admin, Manager, Therapist, Receptionist
|
||||
- **Two-Factor Authentication**: Optional TOTP-based 2FA with recovery codes
|
||||
- **Patient Management**: Full CRUD with demographics, medical history, referral tracking
|
||||
- **Appointment System**: Conflict checking, calendar view, reminders
|
||||
- **Multi-currency**: BHD, SAR, AED, QAR, KWD, OMR (Gulf currencies)
|
||||
- **Invoicing & Payments**: Partial payments, outstanding balances
|
||||
- **Packages**: Session packages with validity periods
|
||||
- **Ledger**: Income/expense tracking with automatic entries
|
||||
- **Wage Management**: Therapist productivity tracking and wage calculation
|
||||
- **Dashboards**: Role-specific dashboards with key metrics
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **Backend**: Laravel 10, PHP 8.1+
|
||||
- **Database**: SQLite (auto-creates database file)
|
||||
- **Authentication**: Laravel Sanctum (API tokens)
|
||||
- **2FA**: pragmarx/google2fa-laravel with Bacon QR Code
|
||||
- **Admin Panel**: AdminLTE 3 (Bootstrap 4/5)
|
||||
- **Frontend**: Blade views with JavaScript API consumption via Axios/Fetch
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Clone and Install Dependencies
|
||||
|
||||
```bash
|
||||
cd physiotherapy-clinic
|
||||
composer install
|
||||
npm install && npm run build
|
||||
```
|
||||
|
||||
### 2. Environment Setup
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
The `.env` file is pre-configured for SQLite:
|
||||
```
|
||||
DB_CONNECTION=sqlite
|
||||
DB_DATABASE=/full/path/to/physiotherapy-clinic/database/database.sqlite
|
||||
```
|
||||
|
||||
### 3. Create SQLite Database
|
||||
|
||||
```bash
|
||||
mkdir -p database
|
||||
touch database/database.sqlite
|
||||
```
|
||||
|
||||
### 4. Run Migrations and Seeders
|
||||
|
||||
```bash
|
||||
php artisan migrate --force
|
||||
php artisan db:seed --force
|
||||
```
|
||||
|
||||
This creates:
|
||||
- Default admin user (admin@clinic.com / password)
|
||||
- Default therapist user (therapist@clinic.com / password)
|
||||
- Gulf currencies (BHD base currency)
|
||||
- Chart of accounts (income/expense)
|
||||
|
||||
### 5. Serve the Application
|
||||
|
||||
```bash
|
||||
php artisan serve
|
||||
```
|
||||
|
||||
Access at: http://localhost:8000
|
||||
|
||||
## Default Login Credentials
|
||||
|
||||
| Role | Email | Password |
|
||||
|------|-------|----------|
|
||||
| Admin | admin@clinic.com | password |
|
||||
| Therapist | therapist@clinic.com | password |
|
||||
|
||||
## API Documentation
|
||||
|
||||
### Authentication
|
||||
|
||||
#### Login
|
||||
```http
|
||||
POST /api/login
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"email": "admin@clinic.com",
|
||||
"password": "password"
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"message": "Logged in successfully",
|
||||
"user": { ... },
|
||||
"token": "1|xxxxxxxxxxxxxxxx"
|
||||
}
|
||||
```
|
||||
|
||||
#### Register
|
||||
```http
|
||||
POST /api/register
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "New User",
|
||||
"email": "user@clinic.com",
|
||||
"password": "password",
|
||||
"password_confirmation": "password"
|
||||
}
|
||||
```
|
||||
|
||||
#### Logout
|
||||
```http
|
||||
POST /api/logout
|
||||
Authorization: Bearer {token}
|
||||
```
|
||||
|
||||
### 2FA Endpoints
|
||||
|
||||
```http
|
||||
# Get 2FA status
|
||||
GET /api/2fa/status
|
||||
|
||||
# Enable 2FA (returns QR code)
|
||||
GET /api/2fa/enable
|
||||
|
||||
# Confirm 2FA with TOTP code
|
||||
POST /api/2fa/confirm
|
||||
{ "code": "123456" }
|
||||
|
||||
# Disable 2FA
|
||||
POST /api/2fa/disable
|
||||
{ "password": "password", "code": "123456" }
|
||||
|
||||
# Regenerate recovery codes
|
||||
GET /api/2fa/recovery-codes
|
||||
```
|
||||
|
||||
### Patients
|
||||
|
||||
```http
|
||||
GET /api/patients # List (paginated)
|
||||
POST /api/patients # Create
|
||||
GET /api/patients/{id} # Show
|
||||
PUT /api/patients/{id} # Update
|
||||
DELETE /api/patients/{id} # Delete
|
||||
GET /api/patients/{id}/profile # Full profile
|
||||
```
|
||||
|
||||
Query parameters for list:
|
||||
- `search` - Search by name, email, phone, code
|
||||
- `status` - Filter by active/inactive
|
||||
- `page`, `per_page` - Pagination
|
||||
|
||||
### Appointments
|
||||
|
||||
```http
|
||||
GET /api/appointments
|
||||
POST /api/appointments
|
||||
GET /api/appointments/{id}
|
||||
PUT /api/appointments/{id}
|
||||
DELETE /api/appointments/{id}
|
||||
|
||||
# Calendar feed
|
||||
GET /api/appointments/calendar/feed?start=2024-01-01&end=2024-01-31
|
||||
|
||||
# Available time slots
|
||||
GET /api/appointments/available-slots?therapist_id=1&date=2024-01-15&duration=60
|
||||
```
|
||||
|
||||
### Invoices & Payments
|
||||
|
||||
```http
|
||||
# Invoices
|
||||
GET /api/invoices
|
||||
POST /api/invoices
|
||||
GET /api/invoices/{id}
|
||||
PUT /api/invoices/{id}
|
||||
DELETE /api/invoices/{id}
|
||||
GET /api/invoices/summary/report
|
||||
|
||||
# Payments
|
||||
GET /api/payments
|
||||
POST /api/payments
|
||||
GET /api/payments/{id}
|
||||
DELETE /api/payments/{id}
|
||||
GET /api/payments/summary/report
|
||||
```
|
||||
|
||||
### Ledger
|
||||
|
||||
```http
|
||||
GET /api/ledger
|
||||
POST /api/ledger
|
||||
|
||||
# Reports
|
||||
GET /api/ledger/summary/pl?date_from=2024-01-01&date_to=2024-01-31
|
||||
GET /api/ledger/summary/income?date_from=2024-01-01&date_to=2024-01-31
|
||||
GET /api/ledger/summary/expenses?date_from=2024-01-01&date_to=2024-01-31
|
||||
```
|
||||
|
||||
### Therapists & Wages
|
||||
|
||||
```http
|
||||
GET /api/therapists
|
||||
GET /api/therapists/{id}
|
||||
PUT /api/therapists/{id}
|
||||
|
||||
# Performance
|
||||
GET /api/therapists/{id}/performance?period_start=2024-01-01&period_end=2024-01-31
|
||||
|
||||
# Wages
|
||||
GET /api/therapists/{id}/wage-calculate?period_start=2024-01-01&period_end=2024-01-31
|
||||
POST /api/therapists/{id}/wage
|
||||
```
|
||||
|
||||
### Dashboard
|
||||
|
||||
```http
|
||||
GET /api/dashboard
|
||||
```
|
||||
|
||||
Response includes stats, recent appointments, charts data.
|
||||
|
||||
## Role-Based Access
|
||||
|
||||
| Feature | Admin | Manager | Therapist | Receptionist |
|
||||
|---------|-------|---------|-----------|--------------|
|
||||
| Patients | All | All | Own only | All |
|
||||
| Appointments | All | All | Own only | All |
|
||||
| Invoices | All | All | View | All |
|
||||
| Payments | All | All | - | Create |
|
||||
| Ledger | All | View | - | - |
|
||||
| Wages | All | Manage | View own | - |
|
||||
| Settings | All | Limited | - | - |
|
||||
|
||||
## Two-Factor Authentication
|
||||
|
||||
1. After first login, go to Security settings
|
||||
2. Click "Enable 2FA"
|
||||
3. Scan QR code with Google Authenticator or similar app
|
||||
4. Enter the 6-digit code to confirm
|
||||
5. Save recovery codes in a secure location
|
||||
|
||||
To login with 2FA:
|
||||
1. Enter email and password
|
||||
2. When prompted, enter TOTP code from authenticator app
|
||||
3. Or use a recovery code if you lost access to your device
|
||||
|
||||
## Web UI (AdminLTE)
|
||||
|
||||
The web interface consumes the same API endpoints via JavaScript:
|
||||
|
||||
- **Dashboard**: `/dashboard` - Overview stats and recent appointments
|
||||
- **Patients**: `/patients` - Patient list with search and filters
|
||||
- **Appointments**: `/appointments` - Calendar and list views
|
||||
- **Security**: `/2fa` - 2FA management
|
||||
|
||||
### JavaScript API Helper
|
||||
|
||||
The included `public/js/api.js` provides a centralized API client:
|
||||
|
||||
```javascript
|
||||
// Get patients with search
|
||||
const patients = await api.getPatients({ search: 'John', page: 1 });
|
||||
|
||||
// Create patient
|
||||
const newPatient = await api.createPatient({
|
||||
first_name: 'John',
|
||||
last_name: 'Doe',
|
||||
phone: '12345678'
|
||||
});
|
||||
|
||||
// Get dashboard data
|
||||
const dashboard = await api.getDashboard();
|
||||
```
|
||||
|
||||
## Localization
|
||||
|
||||
The system supports English and Arabic:
|
||||
|
||||
- Translation files: `resources/lang/en/`, `resources/lang/ar/`
|
||||
- Switch language: Click globe icon in navbar
|
||||
- RTL support: Automatic for Arabic locale
|
||||
|
||||
## Folder Structure
|
||||
|
||||
```
|
||||
app/
|
||||
Http/
|
||||
Controllers/
|
||||
Api/ # API controllers (business logic)
|
||||
Auth/ # Web auth controllers
|
||||
Requests/ # Form validation classes
|
||||
Resources/ # API Resources (JSON formatting)
|
||||
Models/ # Eloquent models
|
||||
Policies/ # Authorization policies
|
||||
Services/ # Business logic services
|
||||
AppointmentService.php
|
||||
LedgerService.php
|
||||
WageService.php
|
||||
ReminderService.php
|
||||
|
||||
resources/
|
||||
views/
|
||||
layouts/ # AdminLTE layout
|
||||
auth/ # Login, register, 2FA pages
|
||||
patients/ # Patient list page
|
||||
lang/ # Translations (en, ar)
|
||||
|
||||
routes/
|
||||
api.php # API routes
|
||||
web.php # Web routes (views only)
|
||||
```
|
||||
|
||||
## Console Commands
|
||||
|
||||
```bash
|
||||
# Send due reminders
|
||||
php artisan reminders:send
|
||||
|
||||
# Calculate wages for period
|
||||
php artisan wages:calculate --period-start=2024-01-01 --period-end=2024-01-31
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Run PHPUnit tests:
|
||||
```bash
|
||||
php artisan test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
||||
27
app/Console/Kernel.php
Normal file
27
app/Console/Kernel.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
30
app/Exceptions/Handler.php
Normal file
30
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
170
app/Http/Controllers/Api/AppointmentController.php
Normal file
170
app/Http/Controllers/Api/AppointmentController.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreAppointmentRequest;
|
||||
use App\Http\Requests\UpdateAppointmentRequest;
|
||||
use App\Http\Resources\AppointmentResource;
|
||||
use App\Models\Appointment;
|
||||
use App\Services\AppointmentService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AppointmentController extends Controller
|
||||
{
|
||||
protected $appointmentService;
|
||||
|
||||
public function __construct(AppointmentService $appointmentService)
|
||||
{
|
||||
$this->appointmentService = $appointmentService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Appointment::with(['patient', 'user']);
|
||||
|
||||
if ($request->has('patient_id')) {
|
||||
$query->where('patient_id', $request->patient_id);
|
||||
}
|
||||
|
||||
if ($request->has('therapist_id')) {
|
||||
$query->where('user_id', $request->therapist_id);
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$query->where('status', $request->status);
|
||||
}
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('appointment_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('appointment_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
if ($request->has('date')) {
|
||||
$query->whereDate('appointment_date', $request->date);
|
||||
}
|
||||
|
||||
$appointments = $query->orderBy('appointment_date')->paginate($request->per_page ?? 20);
|
||||
|
||||
return AppointmentResource::collection($appointments);
|
||||
}
|
||||
|
||||
public function store(StoreAppointmentRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
// Check for conflicts
|
||||
$appointmentDate = \Carbon\Carbon::parse($data['appointment_date']);
|
||||
|
||||
if ($this->appointmentService->hasConflict($data['therapist_id'], $appointmentDate, $data['duration_minutes'])) {
|
||||
return response()->json([
|
||||
'message' => 'Therapist has a conflicting appointment at this time',
|
||||
], 422);
|
||||
}
|
||||
|
||||
if ($this->appointmentService->hasPatientConflict($data['patient_id'], $appointmentDate, $data['duration_minutes'])) {
|
||||
return response()->json([
|
||||
'message' => 'Patient has a conflicting appointment at this time',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$appointment = Appointment::create([
|
||||
'patient_id' => $data['patient_id'],
|
||||
'user_id' => $data['therapist_id'],
|
||||
'appointment_date' => $data['appointment_date'],
|
||||
'duration_minutes' => $data['duration_minutes'],
|
||||
'notes' => $data['notes'] ?? null,
|
||||
]);
|
||||
|
||||
// Generate reminders
|
||||
$reminderService = new \App\Services\ReminderService();
|
||||
$reminderService->generateReminders($appointment);
|
||||
|
||||
return new AppointmentResource($appointment);
|
||||
}
|
||||
|
||||
public function show(Appointment $appointment)
|
||||
{
|
||||
return new AppointmentResource($appointment);
|
||||
}
|
||||
|
||||
public function update(UpdateAppointmentRequest $request, Appointment $appointment)
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
||||
// Check for conflicts if date/therapist changed
|
||||
if (isset($data['appointment_date']) || isset($data['therapist_id'])) {
|
||||
$newDate = isset($data['appointment_date'])
|
||||
? \Carbon\Carbon::parse($data['appointment_date'])
|
||||
: $appointment->appointment_date;
|
||||
$newTherapistId = $data['therapist_id'] ?? $appointment->user_id;
|
||||
$duration = $data['duration_minutes'] ?? $appointment->duration_minutes;
|
||||
|
||||
if ($this->appointmentService->hasConflict($newTherapistId, $newDate, $duration, $appointment->id)) {
|
||||
return response()->json([
|
||||
'message' => 'Therapist has a conflicting appointment at this time',
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
|
||||
$appointment->update([
|
||||
'patient_id' => $data['patient_id'],
|
||||
'user_id' => $data['therapist_id'],
|
||||
'appointment_date' => $data['appointment_date'],
|
||||
'duration_minutes' => $data['duration_minutes'],
|
||||
'status' => $data['status'],
|
||||
'notes' => $data['notes'] ?? null,
|
||||
'cancellation_reason' => $data['cancellation_reason'] ?? null,
|
||||
]);
|
||||
|
||||
if ($data['status'] === 'cancelled') {
|
||||
$appointment->cancelled_by = auth()->id();
|
||||
$appointment->cancelled_at = now();
|
||||
$appointment->save();
|
||||
}
|
||||
|
||||
return new AppointmentResource($appointment);
|
||||
}
|
||||
|
||||
public function destroy(Appointment $appointment)
|
||||
{
|
||||
$appointment->delete();
|
||||
return response()->json(['message' => 'Appointment deleted successfully']);
|
||||
}
|
||||
|
||||
public function calendar(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'start' => 'required|date',
|
||||
'end' => 'required|date|after_or_equal:start',
|
||||
]);
|
||||
|
||||
$feed = $this->appointmentService->getCalendarFeed(
|
||||
$request->start,
|
||||
$request->end,
|
||||
$request->therapist_id
|
||||
);
|
||||
|
||||
return response()->json($feed);
|
||||
}
|
||||
|
||||
public function availableSlots(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'therapist_id' => 'required|exists:users,id',
|
||||
'date' => 'required|date',
|
||||
'duration' => 'nullable|integer|min:15',
|
||||
]);
|
||||
|
||||
$slots = $this->appointmentService->getAvailableSlots(
|
||||
$request->therapist_id,
|
||||
$request->date,
|
||||
$request->duration ?? 60
|
||||
);
|
||||
|
||||
return response()->json(['slots' => $slots]);
|
||||
}
|
||||
}
|
||||
139
app/Http/Controllers/Api/AuthController.php
Normal file
139
app/Http/Controllers/Api/AuthController.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function register(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'confirmed', Password::defaults()],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
$token = $user->createToken('auth_token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.registered'),
|
||||
'user' => $user,
|
||||
'token' => $token,
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
return response()->json([
|
||||
'message' => __('auth.failed'),
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Check if 2FA is enabled
|
||||
if ($user->isTwoFactorEnabled()) {
|
||||
return response()->json([
|
||||
'requires_2fa' => true,
|
||||
'user_id' => $user->id,
|
||||
'message' => __('auth.2fa_required'),
|
||||
]);
|
||||
}
|
||||
|
||||
$token = $user->createToken('auth_token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.logged_in'),
|
||||
'user' => $user,
|
||||
'token' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
public function verify2FA(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'user_id' => ['required', 'integer', 'exists:users,id'],
|
||||
'code' => ['required', 'string', 'size:6'],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$user = User::find($request->user_id);
|
||||
|
||||
if (!$user || !$user->isTwoFactorEnabled()) {
|
||||
return response()->json(['message' => __('auth.2fa_not_enabled')], 400);
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $user->getTwoFactorSecret();
|
||||
|
||||
$valid = $google2fa->verifyKey($secret, $request->code);
|
||||
|
||||
if (!$valid) {
|
||||
// Check recovery codes
|
||||
$recoveryCodes = $user->two_factor_recovery_codes ?? [];
|
||||
if (in_array($request->code, $recoveryCodes)) {
|
||||
// Remove used recovery code
|
||||
$user->two_factor_recovery_codes = array_diff($recoveryCodes, [$request->code]);
|
||||
$user->save();
|
||||
$valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$valid) {
|
||||
return response()->json(['message' => __('auth.2fa_invalid')], 401);
|
||||
}
|
||||
|
||||
$token = $user->createToken('auth_token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.logged_in'),
|
||||
'user' => $user,
|
||||
'token' => $token,
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.logged_out'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function user(Request $request)
|
||||
{
|
||||
return response()->json([
|
||||
'user' => $request->user(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
54
app/Http/Controllers/Api/DashboardController.php
Normal file
54
app/Http/Controllers/Api/DashboardController.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Patient;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$today = Carbon::today();
|
||||
$monthStart = $today->copy()->startOfMonth();
|
||||
$monthEnd = $today->copy()->endOfMonth();
|
||||
|
||||
return response()->json([
|
||||
'stats' => [
|
||||
'total_patients' => Patient::count(),
|
||||
'active_patients' => Patient::where('status', 'active')->count(),
|
||||
'today_appointments' => Appointment::whereDate('appointment_date', $today)->count(),
|
||||
'pending_appointments' => Appointment::whereIn('status', ['scheduled', 'confirmed'])
|
||||
->whereDate('appointment_date', '>=', $today)
|
||||
->count(),
|
||||
'month_invoices' => Invoice::whereBetween('invoice_date', [$monthStart, $monthEnd])->count(),
|
||||
'month_revenue' => Payment::whereBetween('payment_date', [$monthStart, $monthEnd])->sum('amount'),
|
||||
'outstanding_balance' => Invoice::sum('balance'),
|
||||
],
|
||||
'recent_appointments' => Appointment::with(['patient', 'user'])
|
||||
->whereDate('appointment_date', '>=', $today)
|
||||
->orderBy('appointment_date')
|
||||
->limit(5)
|
||||
->get()
|
||||
->map(fn($a) => [
|
||||
'id' => $a->id,
|
||||
'patient_name' => $a->patient->fullName(),
|
||||
'therapist_name' => $a->user->name,
|
||||
'date' => $a->appointment_date->format('Y-m-d'),
|
||||
'time' => $a->appointment_date->format('H:i'),
|
||||
'status' => $a->status,
|
||||
]),
|
||||
'appointments_by_status' => Appointment::selectRaw('status, count(*) as count')
|
||||
->whereDate('appointment_date', '>=', $today->copy()->subDays(30))
|
||||
->groupBy('status')
|
||||
->get(),
|
||||
'invoices_by_status' => Invoice::selectRaw('status, count(*) as count, sum(total_amount) as total')
|
||||
->groupBy('status')
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
134
app/Http/Controllers/Api/InvoiceController.php
Normal file
134
app/Http/Controllers/Api/InvoiceController.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Services\LedgerService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Invoice::with(['patient', 'currency']);
|
||||
|
||||
if ($request->has('patient_id')) {
|
||||
$query->where('patient_id', $request->patient_id);
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$query->where('status', $request->status);
|
||||
}
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('invoice_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('invoice_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
$invoices = $query->orderByDesc('invoice_date')->paginate($request->per_page ?? 20);
|
||||
|
||||
return InvoiceResource::collection($invoices);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'patient_id' => 'required|exists:patients,id',
|
||||
'invoice_date' => 'required|date',
|
||||
'due_date' => 'required|date|after_or_equal:invoice_date',
|
||||
'subtotal' => 'required|numeric|min:0',
|
||||
'tax_amount' => 'nullable|numeric|min:0',
|
||||
'discount_amount' => 'nullable|numeric|min:0',
|
||||
'currency_id' => 'required|exists:currencies,id',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$data['created_by'] = auth()->id();
|
||||
|
||||
// Calculate total
|
||||
$data['total_amount'] = $data['subtotal']
|
||||
+ ($data['tax_amount'] ?? 0)
|
||||
- ($data['discount_amount'] ?? 0);
|
||||
$data['paid_amount'] = 0;
|
||||
|
||||
// Generate invoice number
|
||||
$lastId = Invoice::max('id') ?? 0;
|
||||
$data['invoice_number'] = 'INV-' . date('Y') . '-' . str_pad($lastId + 1, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
$invoice = Invoice::create($data);
|
||||
|
||||
return new InvoiceResource($invoice);
|
||||
}
|
||||
|
||||
public function show(Invoice $invoice)
|
||||
{
|
||||
return new InvoiceResource($invoice);
|
||||
}
|
||||
|
||||
public function update(Request $request, Invoice $invoice)
|
||||
{
|
||||
if (in_array($invoice->status, ['paid', 'cancelled'])) {
|
||||
return response()->json(['message' => 'Cannot update paid or cancelled invoice'], 422);
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'invoice_date' => 'sometimes|date',
|
||||
'due_date' => 'sometimes|date',
|
||||
'subtotal' => 'sometimes|numeric|min:0',
|
||||
'tax_amount' => 'nullable|numeric|min:0',
|
||||
'discount_amount' => 'nullable|numeric|min:0',
|
||||
'notes' => 'nullable|string',
|
||||
'status' => ['sometimes', Rule::in(['draft', 'sent', 'paid', 'partial', 'overdue', 'cancelled'])],
|
||||
]);
|
||||
|
||||
if (isset($data['subtotal'])) {
|
||||
$data['total_amount'] = $data['subtotal']
|
||||
+ ($data['tax_amount'] ?? $invoice->tax_amount)
|
||||
- ($data['discount_amount'] ?? $invoice->discount_amount);
|
||||
}
|
||||
|
||||
$invoice->update($data);
|
||||
|
||||
return new InvoiceResource($invoice);
|
||||
}
|
||||
|
||||
public function destroy(Invoice $invoice)
|
||||
{
|
||||
if ($invoice->payments()->exists()) {
|
||||
return response()->json(['message' => 'Cannot delete invoice with payments'], 422);
|
||||
}
|
||||
|
||||
$invoice->delete();
|
||||
return response()->json(['message' => 'Invoice deleted successfully']);
|
||||
}
|
||||
|
||||
public function summary(Request $request)
|
||||
{
|
||||
$query = Invoice::query();
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('invoice_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('invoice_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total_invoices' => $query->count(),
|
||||
'total_amount' => $query->sum('total_amount'),
|
||||
'total_paid' => $query->sum('paid_amount'),
|
||||
'total_outstanding' => $query->sum('balance'),
|
||||
'by_status' => $query->selectRaw('status, count(*) as count, sum(total_amount) as amount')
|
||||
->groupBy('status')
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
109
app/Http/Controllers/Api/LedgerController.php
Normal file
109
app/Http/Controllers/Api/LedgerController.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\LedgerEntryResource;
|
||||
use App\Models\LedgerEntry;
|
||||
use App\Services\LedgerService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LedgerController extends Controller
|
||||
{
|
||||
protected $ledgerService;
|
||||
|
||||
public function __construct(LedgerService $ledgerService)
|
||||
{
|
||||
$this->ledgerService = $ledgerService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = LedgerEntry::with(['chartOfAccount', 'currency', 'creator']);
|
||||
|
||||
if ($request->has('account_id')) {
|
||||
$query->where('chart_of_account_id', $request->account_id);
|
||||
}
|
||||
|
||||
if ($request->has('type')) {
|
||||
$query->whereHas('chartOfAccount', function ($q) use ($request) {
|
||||
$q->where('type', $request->type);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('entry_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('entry_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
$entries = $query->orderByDesc('entry_date')->paginate($request->per_page ?? 20);
|
||||
|
||||
return LedgerEntryResource::collection($entries);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'entry_date' => 'required|date',
|
||||
'chart_of_account_id' => 'required|exists:chart_of_accounts,id',
|
||||
'currency_id' => 'required|exists:currencies,id',
|
||||
'amount' => 'required|numeric',
|
||||
'description' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$data['created_by'] = auth()->id();
|
||||
$data['source_type'] = 'manual';
|
||||
|
||||
$entry = LedgerEntry::create($data);
|
||||
|
||||
return new LedgerEntryResource($entry);
|
||||
}
|
||||
|
||||
public function summary(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'date_from' => 'required|date',
|
||||
'date_to' => 'required|date|after_or_equal:date_from',
|
||||
]);
|
||||
|
||||
$report = $this->ledgerService->getProfitLossReport(
|
||||
$request->date_from,
|
||||
$request->date_to
|
||||
);
|
||||
|
||||
return response()->json($report);
|
||||
}
|
||||
|
||||
public function incomeSummary(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'date_from' => 'required|date',
|
||||
'date_to' => 'required|date|after_or_equal:date_from',
|
||||
]);
|
||||
|
||||
$summary = $this->ledgerService->getIncomeSummary(
|
||||
$request->date_from,
|
||||
$request->date_to
|
||||
);
|
||||
|
||||
return response()->json($summary);
|
||||
}
|
||||
|
||||
public function expenseSummary(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'date_from' => 'required|date',
|
||||
'date_to' => 'required|date|after_or_equal:date_from',
|
||||
]);
|
||||
|
||||
$summary = $this->ledgerService->getExpenseSummary(
|
||||
$request->date_from,
|
||||
$request->date_to
|
||||
);
|
||||
|
||||
return response()->json($summary);
|
||||
}
|
||||
}
|
||||
111
app/Http/Controllers/Api/PackageController.php
Normal file
111
app/Http/Controllers/Api/PackageController.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PackageResource;
|
||||
use App\Http\Resources\PatientPackageResource;
|
||||
use App\Models\Package;
|
||||
use App\Models\PatientPackage;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PackageController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Package::with('currency')->where('is_active', true);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$query->where('name', 'like', "%{$request->search}%");
|
||||
}
|
||||
|
||||
$packages = $query->orderBy('name')->paginate($request->per_page ?? 20);
|
||||
|
||||
return PackageResource::collection($packages);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'number_of_sessions' => 'required|integer|min:1',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'currency_id' => 'required|exists:currencies,id',
|
||||
'validity_days' => 'required|integer|min:1',
|
||||
'description' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$package = Package::create($data);
|
||||
|
||||
return new PackageResource($package);
|
||||
}
|
||||
|
||||
public function show(Package $package)
|
||||
{
|
||||
return new PackageResource($package);
|
||||
}
|
||||
|
||||
public function update(Request $request, Package $package)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'sometimes|string|max:255',
|
||||
'number_of_sessions' => 'sometimes|integer|min:1',
|
||||
'price' => 'sometimes|numeric|min:0',
|
||||
'currency_id' => 'sometimes|exists:currencies,id',
|
||||
'validity_days' => 'sometimes|integer|min:1',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'sometimes|boolean',
|
||||
]);
|
||||
|
||||
$package->update($data);
|
||||
|
||||
return new PackageResource($package);
|
||||
}
|
||||
|
||||
public function destroy(Package $package)
|
||||
{
|
||||
$package->delete();
|
||||
return response()->json(['message' => 'Package deleted successfully']);
|
||||
}
|
||||
|
||||
// Patient Package Assignment
|
||||
public function assignToPatient(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'patient_id' => 'required|exists:patients,id',
|
||||
'package_id' => 'required|exists:packages,id',
|
||||
'start_date' => 'required|date',
|
||||
]);
|
||||
|
||||
$package = Package::findOrFail($data['package_id']);
|
||||
|
||||
$patientPackage = PatientPackage::create([
|
||||
'patient_id' => $data['patient_id'],
|
||||
'package_id' => $data['package_id'],
|
||||
'total_sessions' => $package->number_of_sessions,
|
||||
'remaining_sessions' => $package->number_of_sessions,
|
||||
'start_date' => $data['start_date'],
|
||||
'end_date' => \Carbon\Carbon::parse($data['start_date'])->addDays($package->validity_days),
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
return new PatientPackageResource($patientPackage);
|
||||
}
|
||||
|
||||
public function patientPackages(Request $request)
|
||||
{
|
||||
$query = PatientPackage::with(['patient', 'package']);
|
||||
|
||||
if ($request->has('patient_id')) {
|
||||
$query->where('patient_id', $request->patient_id);
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$query->where('status', $request->status);
|
||||
}
|
||||
|
||||
$packages = $query->orderByDesc('created_at')->paginate($request->per_page ?? 20);
|
||||
|
||||
return PatientPackageResource::collection($packages);
|
||||
}
|
||||
}
|
||||
74
app/Http/Controllers/Api/PatientController.php
Normal file
74
app/Http/Controllers/Api/PatientController.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StorePatientRequest;
|
||||
use App\Http\Requests\UpdatePatientRequest;
|
||||
use App\Http\Resources\PatientResource;
|
||||
use App\Http\Resources\PatientProfileResource;
|
||||
use App\Models\Patient;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PatientController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Patient::query();
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('first_name', 'like', "%{$search}%")
|
||||
->orWhere('last_name', 'like', "%{$search}%")
|
||||
->orWhere('email', 'like', "%{$search}%")
|
||||
->orWhere('phone', 'like', "%{$search}%")
|
||||
->orWhere('patient_code', 'like', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('status')) {
|
||||
$query->where('status', $request->status);
|
||||
}
|
||||
|
||||
$patients = $query->orderBy('created_at', 'desc')->paginate($request->per_page ?? 20);
|
||||
|
||||
return PatientResource::collection($patients);
|
||||
}
|
||||
|
||||
public function store(StorePatientRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data['created_by'] = auth()->id();
|
||||
|
||||
// Generate patient code
|
||||
$lastId = Patient::max('id') ?? 0;
|
||||
$data['patient_code'] = 'P' . str_pad($lastId + 1, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
$patient = Patient::create($data);
|
||||
|
||||
return new PatientResource($patient);
|
||||
}
|
||||
|
||||
public function show(Patient $patient)
|
||||
{
|
||||
return new PatientResource($patient);
|
||||
}
|
||||
|
||||
public function profile(Patient $patient)
|
||||
{
|
||||
return new PatientProfileResource($patient);
|
||||
}
|
||||
|
||||
public function update(UpdatePatientRequest $request, Patient $patient)
|
||||
{
|
||||
$patient->update($request->validated());
|
||||
return new PatientResource($patient);
|
||||
}
|
||||
|
||||
public function destroy(Patient $patient)
|
||||
{
|
||||
$patient->delete();
|
||||
return response()->json(['message' => 'Patient deleted successfully']);
|
||||
}
|
||||
}
|
||||
120
app/Http/Controllers/Api/PaymentController.php
Normal file
120
app/Http/Controllers/Api/PaymentController.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PaymentResource;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Services\LedgerService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Payment::with(['invoice.patient', 'receivedBy']);
|
||||
|
||||
if ($request->has('invoice_id')) {
|
||||
$query->where('invoice_id', $request->invoice_id);
|
||||
}
|
||||
|
||||
if ($request->has('patient_id')) {
|
||||
$query->whereHas('invoice', function ($q) use ($request) {
|
||||
$q->where('patient_id', $request->patient_id);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('payment_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('payment_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
$payments = $query->orderByDesc('payment_date')->paginate($request->per_page ?? 20);
|
||||
|
||||
return PaymentResource::collection($payments);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'invoice_id' => 'required|exists:invoices,id',
|
||||
'payment_date' => 'required|date',
|
||||
'amount' => 'required|numeric|min:0.01',
|
||||
'payment_method' => 'required|in:cash,card,bank_transfer,check,insurance,other',
|
||||
'reference_number' => 'nullable|string|max:255',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$invoice = Invoice::findOrFail($data['invoice_id']);
|
||||
|
||||
// Check if payment exceeds balance
|
||||
if ($data['amount'] > $invoice->balance) {
|
||||
return response()->json([
|
||||
'message' => 'Payment amount exceeds invoice balance',
|
||||
'balance' => $invoice->balance,
|
||||
], 422);
|
||||
}
|
||||
|
||||
$data['received_by'] = auth()->id();
|
||||
|
||||
// Generate payment number
|
||||
$lastId = Payment::max('id') ?? 0;
|
||||
$data['payment_number'] = 'PAY-' . date('Y') . '-' . str_pad($lastId + 1, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
$payment = Payment::create($data);
|
||||
|
||||
// Update invoice
|
||||
$invoice->paid_amount += $data['amount'];
|
||||
$invoice->status = $invoice->paid_amount >= $invoice->total_amount ? 'paid' : 'partial';
|
||||
$invoice->save();
|
||||
|
||||
// Create ledger entry
|
||||
$ledgerService = new LedgerService();
|
||||
$ledgerService->recordPayment($payment);
|
||||
|
||||
return new PaymentResource($payment);
|
||||
}
|
||||
|
||||
public function show(Payment $payment)
|
||||
{
|
||||
return new PaymentResource($payment);
|
||||
}
|
||||
|
||||
public function destroy(Payment $payment)
|
||||
{
|
||||
// Revert invoice payment
|
||||
$invoice = $payment->invoice;
|
||||
$invoice->paid_amount -= $payment->amount;
|
||||
$invoice->status = $invoice->paid_amount <= 0 ? 'sent' : 'partial';
|
||||
$invoice->save();
|
||||
|
||||
$payment->delete();
|
||||
|
||||
return response()->json(['message' => 'Payment deleted successfully']);
|
||||
}
|
||||
|
||||
public function summary(Request $request)
|
||||
{
|
||||
$query = Payment::query();
|
||||
|
||||
if ($request->has('date_from')) {
|
||||
$query->whereDate('payment_date', '>=', $request->date_from);
|
||||
}
|
||||
|
||||
if ($request->has('date_to')) {
|
||||
$query->whereDate('payment_date', '<=', $request->date_to);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'total_payments' => $query->count(),
|
||||
'total_amount' => $query->sum('amount'),
|
||||
'by_method' => $query->selectRaw('payment_method, count(*) as count, sum(amount) as amount')
|
||||
->groupBy('payment_method')
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
120
app/Http/Controllers/Api/TherapistController.php
Normal file
120
app/Http/Controllers/Api/TherapistController.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\LedgerEntryResource;
|
||||
use App\Http\Resources\TherapistResource;
|
||||
use App\Models\User;
|
||||
use App\Services\LedgerService;
|
||||
use App\Services\WageService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TherapistController extends Controller
|
||||
{
|
||||
protected $ledgerService;
|
||||
protected $wageService;
|
||||
|
||||
public function __construct(LedgerService $ledgerService, WageService $wageService)
|
||||
{
|
||||
$this->ledgerService = $ledgerService;
|
||||
$this->wageService = $wageService;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = User::whereIn('role', ['therapist', 'admin', 'manager']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$search = $request->search;
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('name', 'like', "%{$search}%")
|
||||
->orWhere('email', 'like', "%{$search}%")
|
||||
->orWhere('specialization', 'like', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
$therapists = $query->orderBy('name')->paginate($request->per_page ?? 20);
|
||||
|
||||
return TherapistResource::collection($therapists);
|
||||
}
|
||||
|
||||
public function show(User $user)
|
||||
{
|
||||
return new TherapistResource($user);
|
||||
}
|
||||
|
||||
public function update(Request $request, User $user)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => 'sometimes|string|max:255',
|
||||
'specialization' => 'nullable|string|max:255',
|
||||
'hourly_rate' => 'nullable|numeric|min:0',
|
||||
'session_rate' => 'nullable|numeric|min:0',
|
||||
'target_sessions_per_day' => 'nullable|integer|min:0',
|
||||
'target_sessions_per_month' => 'nullable|integer|min:0',
|
||||
'working_schedule' => 'nullable|array',
|
||||
]);
|
||||
|
||||
$user->update($data);
|
||||
|
||||
return new TherapistResource($user);
|
||||
}
|
||||
|
||||
public function performance(Request $request, User $user)
|
||||
{
|
||||
$request->validate([
|
||||
'period_start' => 'required|date',
|
||||
'period_end' => 'required|date|after_or_equal:period_start',
|
||||
]);
|
||||
|
||||
$metrics = $this->wageService->getPerformanceMetrics(
|
||||
$user->id,
|
||||
$request->period_start,
|
||||
$request->period_end
|
||||
);
|
||||
|
||||
return response()->json($metrics);
|
||||
}
|
||||
|
||||
public function calculateWage(Request $request, User $user)
|
||||
{
|
||||
$request->validate([
|
||||
'period_start' => 'required|date',
|
||||
'period_end' => 'required|date|after_or_equal:period_start',
|
||||
]);
|
||||
|
||||
$wage = $this->wageService->calculateWage(
|
||||
$user->id,
|
||||
$request->period_start,
|
||||
$request->period_end
|
||||
);
|
||||
|
||||
return response()->json($wage);
|
||||
}
|
||||
|
||||
public function storeWage(Request $request, User $user)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'period_start' => 'required|date',
|
||||
'period_end' => 'required|date|after_or_equal:period_start',
|
||||
'sessions_count' => 'required|integer|min:0',
|
||||
'hours_worked' => 'required|numeric|min:0',
|
||||
'base_amount' => 'required|numeric|min:0',
|
||||
'bonus' => 'nullable|numeric|min:0',
|
||||
'deductions' => 'nullable|numeric|min:0',
|
||||
'total_amount' => 'required|numeric|min:0',
|
||||
'currency_id' => 'required|exists:currencies,id',
|
||||
'notes' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$data['user_id'] = $user->id;
|
||||
|
||||
$wage = $this->wageService->createWage($data, auth()->id());
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Wage record created successfully',
|
||||
'wage' => $wage,
|
||||
]);
|
||||
}
|
||||
}
|
||||
153
app/Http/Controllers/Api/TwoFactorController.php
Normal file
153
app/Http/Controllers/Api/TwoFactorController.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class TwoFactorController extends Controller
|
||||
{
|
||||
public function status(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
return response()->json([
|
||||
'enabled' => $user->isTwoFactorEnabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function enable(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->isTwoFactorEnabled()) {
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_already_enabled'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $google2fa->generateSecretKey();
|
||||
|
||||
// Generate QR code URL
|
||||
$qrCodeUrl = $google2fa->getQRCodeUrl(
|
||||
config('app.name'),
|
||||
$user->email,
|
||||
$secret
|
||||
);
|
||||
|
||||
// Store secret temporarily (not enabled until confirmed)
|
||||
session(['2fa_secret' => $secret]);
|
||||
|
||||
return response()->json([
|
||||
'secret' => $secret,
|
||||
'qr_code_url' => $qrCodeUrl,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'code' => ['required', 'string', 'size:6'],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
$secret = session('2fa_secret');
|
||||
|
||||
if (!$secret) {
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_session_expired'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
|
||||
if (!$google2fa->verifyKey($secret, $request->code)) {
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_invalid'),
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Enable 2FA
|
||||
$recoveryCodes = $user->generateRecoveryCodes();
|
||||
$user->setTwoFactorSecret($secret);
|
||||
$user->two_factor_recovery_codes = $recoveryCodes;
|
||||
$user->two_factor_enabled = true;
|
||||
$user->save();
|
||||
|
||||
session()->forget('2fa_secret');
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_enabled'),
|
||||
'recovery_codes' => $recoveryCodes,
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'password' => ['required', 'string'],
|
||||
'code' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
// Verify password
|
||||
if (!\Hash::check($request->password, $user->password)) {
|
||||
return response()->json([
|
||||
'message' => __('auth.password_incorrect'),
|
||||
], 401);
|
||||
}
|
||||
|
||||
// If 2FA is enabled, verify the code
|
||||
if ($user->isTwoFactorEnabled() && $request->code) {
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $user->getTwoFactorSecret();
|
||||
|
||||
if (!$google2fa->verifyKey($secret, $request->code)) {
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_invalid'),
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable 2FA
|
||||
$user->two_factor_secret = null;
|
||||
$user->two_factor_recovery_codes = null;
|
||||
$user->two_factor_enabled = false;
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_disabled'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function regenerateRecoveryCodes(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if (!$user->isTwoFactorEnabled()) {
|
||||
return response()->json([
|
||||
'message' => __('auth.2fa_not_enabled'),
|
||||
], 400);
|
||||
}
|
||||
|
||||
$recoveryCodes = $user->generateRecoveryCodes();
|
||||
$user->two_factor_recovery_codes = $recoveryCodes;
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('auth.recovery_codes_regenerated'),
|
||||
'recovery_codes' => $recoveryCodes,
|
||||
]);
|
||||
}
|
||||
}
|
||||
130
app/Http/Controllers/Auth/TwoFactorController.php
Normal file
130
app/Http/Controllers/Auth/TwoFactorController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class TwoFactorController extends Controller
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
$user = auth()->user();
|
||||
return view('auth.2fa-settings', compact('user'));
|
||||
}
|
||||
|
||||
public function enable(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isTwoFactorEnabled()) {
|
||||
return redirect()->route('2fa.settings')->with('error', __('auth.2fa_already_enabled'));
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $google2fa->generateSecretKey();
|
||||
|
||||
$qrCodeUrl = $google2fa->getQRCodeUrl(
|
||||
config('app.name'),
|
||||
$user->email,
|
||||
$secret
|
||||
);
|
||||
|
||||
// Generate QR code image
|
||||
$qrCode = \BaconQrCode\Renderer\ImageRenderer::class;
|
||||
$writer = new \BaconQrCode\Writer(new \BaconQrCode\Renderer\ImageRenderer(
|
||||
new \BaconQrCode\Renderer\RendererStyle\RendererStyle(400),
|
||||
new \BaconQrCode\Renderer\Image\SvgImageBackEnd()
|
||||
));
|
||||
$qrCodeSvg = $writer->writeString($qrCodeUrl);
|
||||
|
||||
session(['2fa_secret' => $secret]);
|
||||
|
||||
return view('auth.2fa-enable', [
|
||||
'secret' => $secret,
|
||||
'qrCodeSvg' => $qrCodeSvg,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'code' => ['required', 'string', 'size:6'],
|
||||
]);
|
||||
|
||||
$user = auth()->user();
|
||||
$secret = session('2fa_secret');
|
||||
|
||||
if (!$secret) {
|
||||
return redirect()->route('2fa.settings')->with('error', __('auth.2fa_session_expired'));
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
|
||||
if (!$google2fa->verifyKey($secret, $request->code)) {
|
||||
return back()->withErrors(['code' => __('auth.2fa_invalid')]);
|
||||
}
|
||||
|
||||
// Enable 2FA
|
||||
$recoveryCodes = $user->generateRecoveryCodes();
|
||||
$user->setTwoFactorSecret($secret);
|
||||
$user->two_factor_recovery_codes = $recoveryCodes;
|
||||
$user->two_factor_enabled = true;
|
||||
$user->save();
|
||||
|
||||
session()->forget('2fa_secret');
|
||||
|
||||
return view('auth.2fa-recovery-codes', [
|
||||
'recoveryCodes' => $recoveryCodes,
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'password' => ['required', 'string'],
|
||||
'code' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
if (!Hash::check($request->password, $user->password)) {
|
||||
return back()->withErrors(['password' => __('auth.password_incorrect')]);
|
||||
}
|
||||
|
||||
// If 2FA is enabled, verify the code
|
||||
if ($user->isTwoFactorEnabled() && $request->code) {
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $user->getTwoFactorSecret();
|
||||
|
||||
if (!$google2fa->verifyKey($secret, $request->code)) {
|
||||
return back()->withErrors(['code' => __('auth.2fa_invalid')]);
|
||||
}
|
||||
}
|
||||
|
||||
$user->two_factor_secret = null;
|
||||
$user->two_factor_recovery_codes = null;
|
||||
$user->two_factor_enabled = false;
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('2fa.settings')->with('success', __('auth.2fa_disabled'));
|
||||
}
|
||||
|
||||
public function regenerateRecoveryCodes()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (!$user->isTwoFactorEnabled()) {
|
||||
return redirect()->route('2fa.settings')->with('error', __('auth.2fa_not_enabled'));
|
||||
}
|
||||
|
||||
$recoveryCodes = $user->generateRecoveryCodes();
|
||||
$user->two_factor_recovery_codes = $recoveryCodes;
|
||||
$user->save();
|
||||
|
||||
return view('auth.2fa-recovery-codes', [
|
||||
'recoveryCodes' => $recoveryCodes,
|
||||
]);
|
||||
}
|
||||
}
|
||||
130
app/Http/Controllers/Auth/WebAuthController.php
Normal file
130
app/Http/Controllers/Auth/WebAuthController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class WebAuthController extends Controller
|
||||
{
|
||||
public function showLogin()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
return back()->withErrors([
|
||||
'email' => __('auth.failed'),
|
||||
])->onlyInput('email');
|
||||
}
|
||||
|
||||
// Check if 2FA is enabled
|
||||
if ($user->isTwoFactorEnabled()) {
|
||||
session(['2fa_user_id' => $user->id]);
|
||||
return redirect()->route('2fa.challenge');
|
||||
}
|
||||
|
||||
Auth::login($user, $request->boolean('remember'));
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('dashboard'));
|
||||
}
|
||||
|
||||
public function show2FAChallenge()
|
||||
{
|
||||
if (!session()->has('2fa_user_id')) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
return view('auth.2fa-challenge');
|
||||
}
|
||||
|
||||
public function verify2FA(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'code' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
$userId = session('2fa_user_id');
|
||||
if (!$userId) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$user = User::find($userId);
|
||||
if (!$user) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$google2fa = app('pragmarx.google2fa');
|
||||
$secret = $user->getTwoFactorSecret();
|
||||
|
||||
$valid = $google2fa->verifyKey($secret, $request->code);
|
||||
|
||||
// Check recovery codes if TOTP is invalid
|
||||
if (!$valid) {
|
||||
$recoveryCodes = $user->two_factor_recovery_codes ?? [];
|
||||
if (in_array($request->code, $recoveryCodes)) {
|
||||
$user->two_factor_recovery_codes = array_diff($recoveryCodes, [$request->code]);
|
||||
$user->save();
|
||||
$valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$valid) {
|
||||
return back()->withErrors([
|
||||
'code' => __('auth.2fa_invalid'),
|
||||
]);
|
||||
}
|
||||
|
||||
session()->forget('2fa_user_id');
|
||||
Auth::login($user);
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('dashboard'));
|
||||
}
|
||||
|
||||
public function showRegister()
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'confirmed', Password::defaults()],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
}
|
||||
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
||||
33
app/Http/Controllers/DashboardController.php
Normal file
33
app/Http/Controllers/DashboardController.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Patient;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Invoice;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$today = Carbon::today();
|
||||
|
||||
$stats = [
|
||||
'total_patients' => Patient::count(),
|
||||
'today_appointments' => Appointment::whereDate('appointment_date', $today)->count(),
|
||||
'pending_invoices' => Invoice::where('status', 'sent')->orWhere('status', 'partial')->count(),
|
||||
'month_revenue' => Invoice::whereMonth('invoice_date', $today->month)
|
||||
->whereYear('invoice_date', $today->year)
|
||||
->sum('paid_amount'),
|
||||
];
|
||||
|
||||
$recent_appointments = Appointment::with('patient', 'user')
|
||||
->whereDate('appointment_date', '>=', $today)
|
||||
->orderBy('appointment_date')
|
||||
->limit(5)
|
||||
->get();
|
||||
|
||||
return view('dashboard', compact('stats', 'recent_appointments'));
|
||||
}
|
||||
}
|
||||
68
app/Http/Kernel.php
Normal file
68
app/Http/Kernel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/Authenticate.php
Normal file
17
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
26
app/Http/Requests/StoreAppointmentRequest.php
Normal file
26
app/Http/Requests/StoreAppointmentRequest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreAppointmentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'patient_id' => ['required', 'exists:patients,id'],
|
||||
'therapist_id' => ['required', 'exists:users,id'],
|
||||
'appointment_date' => ['required', 'date'],
|
||||
'duration_minutes' => ['required', 'integer', 'min:15'],
|
||||
'type' => ['nullable', 'in:session,assessment,follow-up'],
|
||||
'room' => ['nullable', 'string', 'max:50'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/StorePatientRequest.php
Normal file
35
app/Http/Requests/StorePatientRequest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StorePatientRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255', 'unique:patients'],
|
||||
'phone' => ['nullable', 'string', 'max:50'],
|
||||
'whatsapp' => ['nullable', 'string', 'max:50'],
|
||||
'national_id' => ['nullable', 'string', 'max:50'],
|
||||
'date_of_birth' => ['nullable', 'date'],
|
||||
'gender' => ['nullable', 'in:male,female,other'],
|
||||
'address' => ['nullable', 'string'],
|
||||
'referral_source' => ['nullable', 'string', 'max:255'],
|
||||
'emergency_contact_name' => ['nullable', 'string', 'max:255'],
|
||||
'emergency_contact_phone' => ['nullable', 'string', 'max:50'],
|
||||
'medical_history' => ['nullable', 'string'],
|
||||
'allergies' => ['nullable', 'string'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'status' => ['nullable', 'in:active,inactive'],
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/UpdateAppointmentRequest.php
Normal file
28
app/Http/Requests/UpdateAppointmentRequest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateAppointmentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'patient_id' => ['required', 'exists:patients,id'],
|
||||
'therapist_id' => ['required', 'exists:users,id'],
|
||||
'appointment_date' => ['required', 'date'],
|
||||
'duration_minutes' => ['required', 'integer', 'min:15'],
|
||||
'type' => ['nullable', 'in:session,assessment,follow-up'],
|
||||
'room' => ['nullable', 'string', 'max:50'],
|
||||
'status' => ['required', 'in:scheduled,confirmed,in_progress,completed,cancelled,no_show'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'cancellation_reason' => ['nullable', 'string', 'required_if:status,cancelled'],
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/UpdatePatientRequest.php
Normal file
37
app/Http/Requests/UpdatePatientRequest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdatePatientRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$patientId = $this->route('patient');
|
||||
|
||||
return [
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255', 'unique:patients,email,' . $patientId],
|
||||
'phone' => ['nullable', 'string', 'max:50'],
|
||||
'whatsapp' => ['nullable', 'string', 'max:50'],
|
||||
'national_id' => ['nullable', 'string', 'max:50'],
|
||||
'date_of_birth' => ['nullable', 'date'],
|
||||
'gender' => ['nullable', 'in:male,female,other'],
|
||||
'address' => ['nullable', 'string'],
|
||||
'referral_source' => ['nullable', 'string', 'max:255'],
|
||||
'emergency_contact_name' => ['nullable', 'string', 'max:255'],
|
||||
'emergency_contact_phone' => ['nullable', 'string', 'max:50'],
|
||||
'medical_history' => ['nullable', 'string'],
|
||||
'allergies' => ['nullable', 'string'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'status' => ['nullable', 'in:active,inactive'],
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/AppointmentResource.php
Normal file
32
app/Http/Resources/AppointmentResource.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AppointmentResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patient' => [
|
||||
'id' => $this->patient->id,
|
||||
'name' => $this->patient->fullName(),
|
||||
'phone' => $this->patient->phone,
|
||||
],
|
||||
'therapist' => [
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
],
|
||||
'appointment_date' => $this->appointment_date->format('Y-m-d'),
|
||||
'appointment_time' => $this->appointment_date->format('H:i'),
|
||||
'duration_minutes' => $this->duration_minutes,
|
||||
'end_time' => $this->appointment_date->copy()->addMinutes($this->duration_minutes)->format('H:i'),
|
||||
'status' => $this->status,
|
||||
'notes' => $this->notes,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
23
app/Http/Resources/CurrencyResource.php
Normal file
23
app/Http/Resources/CurrencyResource.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CurrencyResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'code' => $this->code,
|
||||
'name' => $this->name,
|
||||
'symbol' => $this->symbol,
|
||||
'decimal_places' => $this->decimal_places,
|
||||
'exchange_rate_to_base' => $this->exchange_rate_to_base,
|
||||
'is_base' => $this->is_base,
|
||||
'is_active' => $this->is_active,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/InvoiceResource.php
Normal file
33
app/Http/Resources/InvoiceResource.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'invoice_number' => $this->invoice_number,
|
||||
'patient' => [
|
||||
'id' => $this->patient->id,
|
||||
'name' => $this->patient->fullName(),
|
||||
],
|
||||
'invoice_date' => $this->invoice_date->format('Y-m-d'),
|
||||
'due_date' => $this->due_date->format('Y-m-d'),
|
||||
'subtotal' => $this->subtotal,
|
||||
'tax_amount' => $this->tax_amount,
|
||||
'discount_amount' => $this->discount_amount,
|
||||
'total_amount' => $this->total_amount,
|
||||
'paid_amount' => $this->paid_amount,
|
||||
'balance' => $this->balance,
|
||||
'status' => $this->status,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'notes' => $this->notes,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/LedgerEntryResource.php
Normal file
33
app/Http/Resources/LedgerEntryResource.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class LedgerEntryResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'entry_date' => $this->entry_date->format('Y-m-d'),
|
||||
'account' => [
|
||||
'id' => $this->chartOfAccount->id,
|
||||
'code' => $this->chartOfAccount->code,
|
||||
'name' => $this->chartOfAccount->name,
|
||||
'type' => $this->chartOfAccount->type,
|
||||
],
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'amount' => $this->amount,
|
||||
'description' => $this->description,
|
||||
'source_type' => $this->source_type,
|
||||
'source_id' => $this->source_id,
|
||||
'created_by' => [
|
||||
'id' => $this->creator->id,
|
||||
'name' => $this->creator->name,
|
||||
],
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Resources/PackageResource.php
Normal file
24
app/Http/Resources/PackageResource.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PackageResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'number_of_sessions' => $this->number_of_sessions,
|
||||
'price' => $this->price,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'validity_days' => $this->validity_days,
|
||||
'description' => $this->description,
|
||||
'is_active' => $this->is_active,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
25
app/Http/Resources/PatientPackageResource.php
Normal file
25
app/Http/Resources/PatientPackageResource.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PatientPackageResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patient_id' => $this->patient_id,
|
||||
'package' => new PackageResource($this->package),
|
||||
'total_sessions' => $this->total_sessions,
|
||||
'remaining_sessions' => $this->remaining_sessions,
|
||||
'used_sessions' => $this->total_sessions - $this->remaining_sessions,
|
||||
'start_date' => $this->start_date->format('Y-m-d'),
|
||||
'end_date' => $this->end_date->format('Y-m-d'),
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Resources/PatientProfileResource.php
Normal file
36
app/Http/Resources/PatientProfileResource.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PatientProfileResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patient_code' => $this->patient_code,
|
||||
'full_name' => $this->fullName(),
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'whatsapp' => $this->whatsapp,
|
||||
'status' => $this->status,
|
||||
'upcoming_appointments' => AppointmentResource::collection(
|
||||
$this->appointments()->where('appointment_date', '>=', now())->orderBy('appointment_date')->limit(5)->get()
|
||||
),
|
||||
'past_appointments' => AppointmentResource::collection(
|
||||
$this->appointments()->where('appointment_date', '<', now())->orderByDesc('appointment_date')->limit(5)->get()
|
||||
),
|
||||
'invoices' => InvoiceResource::collection($this->invoices()->orderByDesc('invoice_date')->limit(10)->get()),
|
||||
'payments' => PaymentResource::collection(
|
||||
Payment::whereIn('invoice_id', $this->invoices->pluck('id'))->orderByDesc('payment_date')->limit(10)->get()
|
||||
),
|
||||
'balance' => $this->invoices->sum('balance'),
|
||||
'active_packages' => PatientPackageResource::collection(
|
||||
$this->packages()->where('status', 'active')->get()
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
app/Http/Resources/PatientResource.php
Normal file
38
app/Http/Resources/PatientResource.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PatientResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'patient_code' => $this->patient_code,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'full_name' => $this->fullName(),
|
||||
'email' => $this->email,
|
||||
'phone' => $this->phone,
|
||||
'whatsapp' => $this->whatsapp,
|
||||
'national_id' => $this->national_id,
|
||||
'date_of_birth' => $this->date_of_birth?->format('Y-m-d'),
|
||||
'gender' => $this->gender,
|
||||
'address' => $this->address,
|
||||
'referral_source' => $this->referral_source,
|
||||
'status' => $this->status,
|
||||
'emergency_contact' => [
|
||||
'name' => $this->emergency_contact_name,
|
||||
'phone' => $this->emergency_contact_phone,
|
||||
],
|
||||
'medical_history' => $this->medical_history,
|
||||
'allergies' => $this->allergies,
|
||||
'notes' => $this->notes,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/PaymentResource.php
Normal file
35
app/Http/Resources/PaymentResource.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PaymentResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'payment_number' => $this->payment_number,
|
||||
'invoice' => [
|
||||
'id' => $this->invoice->id,
|
||||
'number' => $this->invoice->invoice_number,
|
||||
],
|
||||
'patient' => [
|
||||
'id' => $this->invoice->patient->id,
|
||||
'name' => $this->invoice->patient->fullName(),
|
||||
],
|
||||
'payment_date' => $this->payment_date->format('Y-m-d'),
|
||||
'amount' => $this->amount,
|
||||
'payment_method' => $this->payment_method,
|
||||
'reference_number' => $this->reference_number,
|
||||
'notes' => $this->notes,
|
||||
'received_by' => [
|
||||
'id' => $this->receivedBy->id,
|
||||
'name' => $this->receivedBy->name,
|
||||
],
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Resources/ReminderResource.php
Normal file
29
app/Http/Resources/ReminderResource.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ReminderResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'appointment_id' => $this->appointment_id,
|
||||
'patient' => [
|
||||
'id' => $this->appointment->patient->id,
|
||||
'name' => $this->appointment->patient->fullName(),
|
||||
],
|
||||
'channel' => $this->channel,
|
||||
'content' => $this->content,
|
||||
'send_at' => $this->send_at?->format('Y-m-d H:i:s'),
|
||||
'sent_at' => $this->sent_at?->format('Y-m-d H:i:s'),
|
||||
'status' => $this->status,
|
||||
'error_message' => $this->error_message,
|
||||
'response' => $this->response,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Resources/TherapistResource.php
Normal file
26
app/Http/Resources/TherapistResource.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TherapistResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'role' => $this->role,
|
||||
'specialization' => $this->specialization,
|
||||
'hourly_rate' => $this->hourly_rate,
|
||||
'session_rate' => $this->session_rate,
|
||||
'target_sessions_per_day' => $this->target_sessions_per_day,
|
||||
'target_sessions_per_month' => $this->target_sessions_per_month,
|
||||
'working_schedule' => $this->working_schedule,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Resources/WageResource.php
Normal file
32
app/Http/Resources/WageResource.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class WageResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'therapist' => [
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
],
|
||||
'period_start' => $this->period_start->format('Y-m-d'),
|
||||
'period_end' => $this->period_end->format('Y-m-d'),
|
||||
'sessions_count' => $this->sessions_count,
|
||||
'hours_worked' => $this->hours_worked,
|
||||
'base_amount' => $this->base_amount,
|
||||
'bonus' => $this->bonus,
|
||||
'deductions' => $this->deductions,
|
||||
'total_amount' => $this->total_amount,
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'status' => $this->status,
|
||||
'notes' => $this->notes,
|
||||
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
50
app/Models/Appointment.php
Normal file
50
app/Models/Appointment.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Appointment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'user_id',
|
||||
'appointment_date',
|
||||
'duration_minutes',
|
||||
'status',
|
||||
'notes',
|
||||
'cancellation_reason',
|
||||
'cancelled_by',
|
||||
'cancelled_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'appointment_date' => 'datetime',
|
||||
'cancelled_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function patient(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function cancelledBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'cancelled_by');
|
||||
}
|
||||
|
||||
public function treatments()
|
||||
{
|
||||
return $this->hasMany(Treatment::class);
|
||||
}
|
||||
}
|
||||
24
app/Models/ChartOfAccount.php
Normal file
24
app/Models/ChartOfAccount.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ChartOfAccount extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'type',
|
||||
'category',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
29
app/Models/Currency.php
Normal file
29
app/Models/Currency.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
'symbol',
|
||||
'decimal_places',
|
||||
'exchange_rate_to_base',
|
||||
'is_base',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'decimal_places' => 'integer',
|
||||
'exchange_rate_to_base' => 'decimal:6',
|
||||
'is_base' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
71
app/Models/Invoice.php
Normal file
71
app/Models/Invoice.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'invoice_number',
|
||||
'patient_id',
|
||||
'treatment_id',
|
||||
'invoice_date',
|
||||
'due_date',
|
||||
'subtotal',
|
||||
'tax_amount',
|
||||
'discount_amount',
|
||||
'total_amount',
|
||||
'paid_amount',
|
||||
'status',
|
||||
'currency_id',
|
||||
'notes',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'invoice_date' => 'date',
|
||||
'due_date' => 'date',
|
||||
'subtotal' => 'decimal:2',
|
||||
'tax_amount' => 'decimal:2',
|
||||
'discount_amount' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
'paid_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function patient(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
|
||||
public function treatment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Treatment::class);
|
||||
}
|
||||
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function createdBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class);
|
||||
}
|
||||
|
||||
public function getBalanceAttribute(): float
|
||||
{
|
||||
return $this->total_amount - $this->paid_amount;
|
||||
}
|
||||
}
|
||||
58
app/Models/LedgerEntry.php
Normal file
58
app/Models/LedgerEntry.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class LedgerEntry extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'entry_date',
|
||||
'chart_of_account_id',
|
||||
'currency_id',
|
||||
'amount',
|
||||
'description',
|
||||
'source_type',
|
||||
'source_id',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'entry_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function chartOfAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ChartOfAccount::class);
|
||||
}
|
||||
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function scopeIncome($query)
|
||||
{
|
||||
return $query->whereHas('chartOfAccount', function ($q) {
|
||||
$q->where('type', 'income');
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeExpense($query)
|
||||
{
|
||||
return $query->whereHas('chartOfAccount', function ($q) {
|
||||
$q->where('type', 'expense');
|
||||
});
|
||||
}
|
||||
}
|
||||
41
app/Models/Package.php
Normal file
41
app/Models/Package.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Package extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'number_of_sessions',
|
||||
'price',
|
||||
'currency_id',
|
||||
'validity_days',
|
||||
'description',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'number_of_sessions' => 'integer',
|
||||
'price' => 'decimal:2',
|
||||
'validity_days' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function patientPackages(): HasMany
|
||||
{
|
||||
return $this->hasMany(PatientPackage::class);
|
||||
}
|
||||
}
|
||||
54
app/Models/Patient.php
Normal file
54
app/Models/Patient.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Patient extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'patient_code',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'phone',
|
||||
'date_of_birth',
|
||||
'gender',
|
||||
'address',
|
||||
'emergency_contact_name',
|
||||
'emergency_contact_phone',
|
||||
'medical_history',
|
||||
'allergies',
|
||||
'notes',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date_of_birth' => 'date',
|
||||
];
|
||||
|
||||
public function appointments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Appointment::class);
|
||||
}
|
||||
|
||||
public function treatments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Treatment::class);
|
||||
}
|
||||
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
public function fullName(): string
|
||||
{
|
||||
return "{$this->first_name} {$this->last_name}";
|
||||
}
|
||||
}
|
||||
53
app/Models/PatientPackage.php
Normal file
53
app/Models/PatientPackage.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PatientPackage extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'package_id',
|
||||
'total_sessions',
|
||||
'remaining_sessions',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'total_sessions' => 'integer',
|
||||
'remaining_sessions' => 'integer',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
public function patient(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
|
||||
public function package(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Package::class);
|
||||
}
|
||||
|
||||
public function consumeSession(): bool
|
||||
{
|
||||
if ($this->remaining_sessions > 0 && $this->status === 'active') {
|
||||
$this->remaining_sessions--;
|
||||
if ($this->remaining_sessions === 0) {
|
||||
$this->status = 'completed';
|
||||
}
|
||||
$this->save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
39
app/Models/Payment.php
Normal file
39
app/Models/Payment.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Payment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'payment_number',
|
||||
'invoice_id',
|
||||
'payment_date',
|
||||
'amount',
|
||||
'payment_method',
|
||||
'reference_number',
|
||||
'notes',
|
||||
'received_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payment_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function invoice(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function receivedBy(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'received_by');
|
||||
}
|
||||
}
|
||||
54
app/Models/Reminder.php
Normal file
54
app/Models/Reminder.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Reminder extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'appointment_id',
|
||||
'template_id',
|
||||
'channel',
|
||||
'content',
|
||||
'send_at',
|
||||
'sent_at',
|
||||
'status',
|
||||
'error_message',
|
||||
'response',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'send_at' => 'datetime',
|
||||
'sent_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function appointment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Appointment::class);
|
||||
}
|
||||
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ReminderTemplate::class, 'template_id');
|
||||
}
|
||||
|
||||
public function markAsSent(string $response = null): void
|
||||
{
|
||||
$this->status = 'sent';
|
||||
$this->sent_at = now();
|
||||
$this->response = $response;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function markAsFailed(string $errorMessage): void
|
||||
{
|
||||
$this->status = 'failed';
|
||||
$this->error_message = $errorMessage;
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
39
app/Models/ReminderTemplate.php
Normal file
39
app/Models/ReminderTemplate.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ReminderTemplate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'content',
|
||||
'channel',
|
||||
'hours_before',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'hours_before' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function reminders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Reminder::class, 'template_id');
|
||||
}
|
||||
|
||||
public function parseContent(array $placeholders): string
|
||||
{
|
||||
$content = $this->content;
|
||||
foreach ($placeholders as $key => $value) {
|
||||
$content = str_replace('{' . $key . '}', $value, $content);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
64
app/Models/Treatment.php
Normal file
64
app/Models/Treatment.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Treatment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'appointment_id',
|
||||
'user_id',
|
||||
'treatment_code',
|
||||
'name',
|
||||
'description',
|
||||
'sessions_count',
|
||||
'sessions_completed',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
'total_cost',
|
||||
'currency_id',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'sessions_count' => 'integer',
|
||||
'sessions_completed' => 'integer',
|
||||
'total_cost' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function patient(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
|
||||
public function appointment(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Appointment::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function invoices(): HasMany
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
}
|
||||
68
app/Models/User.php
Normal file
68
app/Models/User.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
'specialization',
|
||||
'hourly_rate',
|
||||
'session_rate',
|
||||
'target_sessions_per_day',
|
||||
'target_sessions_per_month',
|
||||
'working_schedule',
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_enabled',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'two_factor_enabled' => 'boolean',
|
||||
'two_factor_recovery_codes' => 'array',
|
||||
];
|
||||
|
||||
public function isTwoFactorEnabled(): bool
|
||||
{
|
||||
return $this->two_factor_enabled === true;
|
||||
}
|
||||
|
||||
public function getTwoFactorSecret(): ?string
|
||||
{
|
||||
return $this->two_factor_secret ? decrypt($this->two_factor_secret) : null;
|
||||
}
|
||||
|
||||
public function setTwoFactorSecret(string $secret): void
|
||||
{
|
||||
$this->two_factor_secret = encrypt($secret);
|
||||
}
|
||||
|
||||
public function generateRecoveryCodes(): array
|
||||
{
|
||||
$codes = [];
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$codes[] = bin2hex(random_bytes(4));
|
||||
}
|
||||
return $codes;
|
||||
}
|
||||
}
|
||||
55
app/Models/Wage.php
Normal file
55
app/Models/Wage.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Wage extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'period_start',
|
||||
'period_end',
|
||||
'sessions_count',
|
||||
'hours_worked',
|
||||
'base_amount',
|
||||
'bonus',
|
||||
'deductions',
|
||||
'total_amount',
|
||||
'currency_id',
|
||||
'status',
|
||||
'notes',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'period_start' => 'date',
|
||||
'period_end' => 'date',
|
||||
'sessions_count' => 'integer',
|
||||
'hours_worked' => 'integer',
|
||||
'base_amount' => 'decimal:2',
|
||||
'bonus' => 'decimal:2',
|
||||
'deductions' => 'decimal:2',
|
||||
'total_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function currency(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Currency::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
||||
42
app/Policies/AppointmentPolicy.php
Normal file
42
app/Policies/AppointmentPolicy.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Appointment;
|
||||
|
||||
class AppointmentPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Appointment $appointment): bool
|
||||
{
|
||||
if (in_array($user->role, ['admin', 'manager', 'receptionist'])) {
|
||||
return true;
|
||||
}
|
||||
// Therapists can see their own appointments
|
||||
return $appointment->user_id === $user->id;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function update(User $user, Appointment $appointment): bool
|
||||
{
|
||||
if (in_array($user->role, ['admin', 'manager', 'receptionist'])) {
|
||||
return true;
|
||||
}
|
||||
// Therapists can update their own appointments
|
||||
return $appointment->user_id === $user->id;
|
||||
}
|
||||
|
||||
public function delete(User $user, Appointment $appointment): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
}
|
||||
33
app/Policies/InvoicePolicy.php
Normal file
33
app/Policies/InvoicePolicy.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class InvoicePolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function view(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function update(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function delete(User $user): bool
|
||||
{
|
||||
return $user->role === 'admin';
|
||||
}
|
||||
}
|
||||
28
app/Policies/LedgerPolicy.php
Normal file
28
app/Policies/LedgerPolicy.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class LedgerPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function view(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function viewReports(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
}
|
||||
41
app/Policies/PatientPolicy.php
Normal file
41
app/Policies/PatientPolicy.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Patient;
|
||||
|
||||
class PatientPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist', 'therapist']);
|
||||
}
|
||||
|
||||
public function view(User $user, Patient $patient): bool
|
||||
{
|
||||
if (in_array($user->role, ['admin', 'manager', 'receptionist'])) {
|
||||
return true;
|
||||
}
|
||||
// Therapists can only see their own patients
|
||||
if ($user->role === 'therapist') {
|
||||
return $patient->appointments()->where('user_id', $user->id)->exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function update(User $user, Patient $patient): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager', 'receptionist']);
|
||||
}
|
||||
|
||||
public function delete(User $user, Patient $patient): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
}
|
||||
32
app/Policies/WagePolicy.php
Normal file
32
app/Policies/WagePolicy.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class WagePolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function view(User $user, $wage): bool
|
||||
{
|
||||
if (in_array($user->role, ['admin', 'manager'])) {
|
||||
return true;
|
||||
}
|
||||
// Therapists can only see their own wages
|
||||
return $wage->user_id === $user->id;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
|
||||
public function approve(User $user): bool
|
||||
{
|
||||
return in_array($user->role, ['admin', 'manager']);
|
||||
}
|
||||
}
|
||||
24
app/Providers/AppServiceProvider.php
Normal file
24
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
43
app/Providers/AuthServiceProvider.php
Normal file
43
app/Providers/AuthServiceProvider.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use App\Models\Patient;
|
||||
use App\Models\Appointment;
|
||||
use App\Policies\PatientPolicy;
|
||||
use App\Policies\AppointmentPolicy;
|
||||
use App\Policies\InvoicePolicy;
|
||||
use App\Policies\LedgerPolicy;
|
||||
use App\Policies\WagePolicy;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $policies = [
|
||||
Patient::class => PatientPolicy::class,
|
||||
Appointment::class => AppointmentPolicy::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
// Gates for invoices
|
||||
Gate::define('view-invoices', [InvoicePolicy::class, 'viewAny']);
|
||||
Gate::define('create-invoices', [InvoicePolicy::class, 'create']);
|
||||
|
||||
// Gates for ledger
|
||||
Gate::define('view-ledger', [LedgerPolicy::class, 'viewAny']);
|
||||
Gate::define('create-ledger', [LedgerPolicy::class, 'create']);
|
||||
Gate::define('view-reports', [LedgerPolicy::class, 'viewReports']);
|
||||
|
||||
// Gates for wages
|
||||
Gate::define('view-wages', [WagePolicy::class, 'viewAny']);
|
||||
Gate::define('approve-wages', [WagePolicy::class, 'approve']);
|
||||
|
||||
// Role-based gates
|
||||
Gate::define('is-admin', fn($user) => $user->role === 'admin');
|
||||
Gate::define('is-manager', fn($user) => in_array($user->role, ['admin', 'manager']));
|
||||
Gate::define('is-therapist', fn($user) => $user->role === 'therapist');
|
||||
Gate::define('is-receptionist', fn($user) => $user->role === 'receptionist');
|
||||
}
|
||||
}
|
||||
19
app/Providers/BroadcastServiceProvider.php
Normal file
19
app/Providers/BroadcastServiceProvider.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
38
app/Providers/EventServiceProvider.php
Normal file
38
app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
40
app/Providers/RouteServiceProvider.php
Normal file
40
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
||||
105
app/Services/AppointmentService.php
Normal file
105
app/Services/AppointmentService.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Patient;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class AppointmentService
|
||||
{
|
||||
/**
|
||||
* Check for conflicting appointments for a therapist
|
||||
*/
|
||||
public function hasConflict(int $therapistId, Carbon $startTime, int $duration, ?int $excludeId = null): bool
|
||||
{
|
||||
$endTime = $startTime->copy()->addMinutes($duration);
|
||||
|
||||
$query = Appointment::where('user_id', $therapistId)
|
||||
->whereIn('status', ['scheduled', 'confirmed', 'in_progress'])
|
||||
->where(function ($q) use ($startTime, $endTime) {
|
||||
// Check if any appointment overlaps with the requested time
|
||||
$q->whereBetween('appointment_date', [$startTime, $endTime->copy()->subSecond()])
|
||||
->orWhereRaw("datetime(appointment_date, '+' || duration_minutes || ' minutes') BETWEEN ? AND ?", [$startTime, $endTime]);
|
||||
});
|
||||
|
||||
if ($excludeId) {
|
||||
$query->where('id', '!=', $excludeId);
|
||||
}
|
||||
|
||||
return $query->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for patient double-booking
|
||||
*/
|
||||
public function hasPatientConflict(int $patientId, Carbon $startTime, int $duration, ?int $excludeId = null): bool
|
||||
{
|
||||
$endTime = $startTime->copy()->addMinutes($duration);
|
||||
|
||||
$query = Appointment::where('patient_id', $patientId)
|
||||
->whereIn('status', ['scheduled', 'confirmed', 'in_progress'])
|
||||
->whereBetween('appointment_date', [$startTime, $endTime->copy()->subSecond()]);
|
||||
|
||||
if ($excludeId) {
|
||||
$query->where('id', '!=', $excludeId);
|
||||
}
|
||||
|
||||
return $query->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available time slots for a therapist on a given date
|
||||
*/
|
||||
public function getAvailableSlots(int $therapistId, string $date, int $duration = 60): array
|
||||
{
|
||||
$workingHours = ['09:00', '17:00']; // 9 AM to 5 PM
|
||||
$slotInterval = 30; // minutes
|
||||
|
||||
$slots = [];
|
||||
$start = Carbon::parse("$date {$workingHours[0]}");
|
||||
$end = Carbon::parse("$date {$workingHours[1]}");
|
||||
|
||||
while ($start->lt($end)) {
|
||||
$slotEnd = $start->copy()->addMinutes($duration);
|
||||
|
||||
if ($slotEnd->lte($end) && !$this->hasConflict($therapistId, $start, $duration)) {
|
||||
$slots[] = $start->format('H:i');
|
||||
}
|
||||
|
||||
$start->addMinutes($slotInterval);
|
||||
}
|
||||
|
||||
return $slots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calendar feed for a date range
|
||||
*/
|
||||
public function getCalendarFeed(string $startDate, string $endDate, ?int $therapistId = null): array
|
||||
{
|
||||
$query = Appointment::with(['patient', 'user'])
|
||||
->whereBetween('appointment_date', [$startDate, $endDate]);
|
||||
|
||||
if ($therapistId) {
|
||||
$query->where('user_id', $therapistId);
|
||||
}
|
||||
|
||||
return $query->orderBy('appointment_date')->get()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume a package session for an appointment
|
||||
*/
|
||||
public function consumePackageSession(Appointment $appointment, int $patientPackageId): bool
|
||||
{
|
||||
$patientPackage = \App\Models\PatientPackage::find($patientPackageId);
|
||||
|
||||
if (!$patientPackage || $patientPackage->patient_id !== $appointment->patient_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $patientPackage->consumeSession();
|
||||
}
|
||||
}
|
||||
130
app/Services/LedgerService.php
Normal file
130
app/Services/LedgerService.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\LedgerEntry;
|
||||
use App\Models\ChartOfAccount;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Wage;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LedgerService
|
||||
{
|
||||
/**
|
||||
* Create a ledger entry from a payment (income)
|
||||
*/
|
||||
public function recordPayment(Payment $payment): LedgerEntry
|
||||
{
|
||||
$incomeAccount = ChartOfAccount::where('type', 'income')
|
||||
->where('category', 'revenue')
|
||||
->first();
|
||||
|
||||
return LedgerEntry::create([
|
||||
'entry_date' => $payment->payment_date,
|
||||
'chart_of_account_id' => $incomeAccount?->id,
|
||||
'currency_id' => $payment->invoice->currency_id,
|
||||
'amount' => $payment->amount,
|
||||
'description' => "Payment received - {$payment->payment_number}",
|
||||
'source_type' => 'payment',
|
||||
'source_id' => $payment->id,
|
||||
'created_by' => $payment->received_by,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ledger entry for a wage (expense)
|
||||
*/
|
||||
public function recordWage(Wage $wage): LedgerEntry
|
||||
{
|
||||
$expenseAccount = ChartOfAccount::where('type', 'expense')
|
||||
->where('category', 'operating_expense')
|
||||
->first();
|
||||
|
||||
return LedgerEntry::create([
|
||||
'entry_date' => $wage->period_end,
|
||||
'chart_of_account_id' => $expenseAccount?->id,
|
||||
'currency_id' => $wage->currency_id,
|
||||
'amount' => -$wage->total_amount, // negative for expense
|
||||
'description' => "Wage payment - {$wage->user->name} ({$wage->period_start} to {$wage->period_end})",
|
||||
'source_type' => 'wage',
|
||||
'source_id' => $wage->id,
|
||||
'created_by' => $wage->created_by,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get income summary for a period
|
||||
*/
|
||||
public function getIncomeSummary(string $startDate, string $endDate): array
|
||||
{
|
||||
$entries = LedgerEntry::income()
|
||||
->whereBetween('entry_date', [$startDate, $endDate])
|
||||
->with('chartOfAccount')
|
||||
->get();
|
||||
|
||||
$byAccount = $entries->groupBy('chart_of_account_id')
|
||||
->map(fn($group) => [
|
||||
'account_name' => $group->first()->chartOfAccount->name,
|
||||
'total' => $group->sum('amount'),
|
||||
])
|
||||
->values();
|
||||
|
||||
return [
|
||||
'total_income' => $entries->sum('amount'),
|
||||
'by_account' => $byAccount,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get expense summary for a period
|
||||
*/
|
||||
public function getExpenseSummary(string $startDate, string $endDate): array
|
||||
{
|
||||
$entries = LedgerEntry::expense()
|
||||
->whereBetween('entry_date', [$startDate, $endDate])
|
||||
->with('chartOfAccount')
|
||||
->get();
|
||||
|
||||
$byAccount = $entries->groupBy('chart_of_account_id')
|
||||
->map(fn($group) => [
|
||||
'account_name' => $group->first()->chartOfAccount->name,
|
||||
'total' => abs($group->sum('amount')),
|
||||
])
|
||||
->values();
|
||||
|
||||
return [
|
||||
'total_expenses' => abs($entries->sum('amount')),
|
||||
'by_account' => $byAccount,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get net profit for a period
|
||||
*/
|
||||
public function getNetProfit(string $startDate, string $endDate): float
|
||||
{
|
||||
$income = $this->getIncomeSummary($startDate, $endDate)['total_income'];
|
||||
$expenses = $this->getExpenseSummary($startDate, $endDate)['total_expenses'];
|
||||
|
||||
return $income - $expenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full P&L report
|
||||
*/
|
||||
public function getProfitLossReport(string $startDate, string $endDate): array
|
||||
{
|
||||
$income = $this->getIncomeSummary($startDate, $endDate);
|
||||
$expenses = $this->getExpenseSummary($startDate, $endDate);
|
||||
|
||||
return [
|
||||
'period' => [
|
||||
'start' => $startDate,
|
||||
'end' => $endDate,
|
||||
],
|
||||
'income' => $income,
|
||||
'expenses' => $expenses,
|
||||
'net_profit' => $income['total_income'] - $expenses['total_expenses'],
|
||||
];
|
||||
}
|
||||
}
|
||||
137
app/Services/ReminderService.php
Normal file
137
app/Services/ReminderService.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Reminder;
|
||||
use App\Models\ReminderTemplate;
|
||||
use App\Models\Appointment;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ReminderService
|
||||
{
|
||||
/**
|
||||
* Generate reminders for an appointment
|
||||
*/
|
||||
public function generateReminders(Appointment $appointment): void
|
||||
{
|
||||
$templates = ReminderTemplate::where('is_active', true)->get();
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$sendAt = $appointment->appointment_date->copy()->subHours($template->hours_before);
|
||||
|
||||
// Don't create if send time is in the past
|
||||
if ($sendAt->isPast()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$placeholders = [
|
||||
'patient_name' => $appointment->patient->fullName(),
|
||||
'date' => $appointment->appointment_date->format('Y-m-d'),
|
||||
'time' => $appointment->appointment_date->format('H:i'),
|
||||
'therapist_name' => $appointment->user->name,
|
||||
];
|
||||
|
||||
Reminder::create([
|
||||
'appointment_id' => $appointment->id,
|
||||
'template_id' => $template->id,
|
||||
'channel' => $template->channel,
|
||||
'content' => $template->parseContent($placeholders),
|
||||
'send_at' => $sendAt,
|
||||
'status' => 'queued',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get due reminders
|
||||
*/
|
||||
public function getDueReminders(int $limit = 50): array
|
||||
{
|
||||
return Reminder::with('appointment.patient')
|
||||
->where('status', 'queued')
|
||||
->where('send_at', '<=', now())
|
||||
->limit($limit)
|
||||
->get()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process and send reminders
|
||||
*/
|
||||
public function processReminders(): array
|
||||
{
|
||||
$reminders = Reminder::with('appointment.patient')
|
||||
->where('status', 'queued')
|
||||
->where('send_at', '<=', now())
|
||||
->get();
|
||||
|
||||
$results = [
|
||||
'sent' => 0,
|
||||
'failed' => 0,
|
||||
];
|
||||
|
||||
foreach ($reminders as $reminder) {
|
||||
try {
|
||||
$this->sendReminder($reminder);
|
||||
$reminder->markAsSent();
|
||||
$results['sent']++;
|
||||
} catch (\Exception $e) {
|
||||
$reminder->markAsFailed($e->getMessage());
|
||||
$results['failed']++;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a single reminder (stub - implement with actual SMS/WhatsApp provider)
|
||||
*/
|
||||
public function sendReminder(Reminder $reminder): void
|
||||
{
|
||||
// Stub implementation - integrate with SMS/WhatsApp provider
|
||||
$channel = $reminder->channel;
|
||||
$content = $reminder->content;
|
||||
|
||||
switch ($channel) {
|
||||
case 'sms':
|
||||
// TODO: Integrate with SMS provider
|
||||
break;
|
||||
case 'whatsapp':
|
||||
// TODO: Integrate with WhatsApp Business API
|
||||
break;
|
||||
case 'email':
|
||||
// TODO: Send email
|
||||
break;
|
||||
case 'internal':
|
||||
// Internal notification - logged only
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reminder configuration
|
||||
*/
|
||||
public function getConfiguration(): array
|
||||
{
|
||||
return ReminderTemplate::where('is_active', true)
|
||||
->get()
|
||||
->map(fn($t) => [
|
||||
'id' => $t->id,
|
||||
'name' => $t->name,
|
||||
'channel' => $t->channel,
|
||||
'hours_before' => $t->hours_before,
|
||||
])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update reminder configuration
|
||||
*/
|
||||
public function updateConfiguration(int $templateId, array $data): ReminderTemplate
|
||||
{
|
||||
$template = ReminderTemplate::findOrFail($templateId);
|
||||
$template->update($data);
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
83
app/Services/WageService.php
Normal file
83
app/Services/WageService.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Wage;
|
||||
use App\Models\User;
|
||||
use App\Models\Appointment;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WageService
|
||||
{
|
||||
/**
|
||||
* Calculate wage for a therapist in a given period
|
||||
*/
|
||||
public function calculateWage(int $therapistId, string $periodStart, string $periodEnd): array
|
||||
{
|
||||
$therapist = User::find($therapistId);
|
||||
|
||||
$completedAppointments = Appointment::where('user_id', $therapistId)
|
||||
->where('status', 'completed')
|
||||
->whereBetween('appointment_date', [$periodStart, $periodEnd . ' 23:59:59'])
|
||||
->get();
|
||||
|
||||
$sessionsCount = $completedAppointments->count();
|
||||
$hoursWorked = $completedAppointments->sum('duration_minutes') / 60;
|
||||
|
||||
$baseAmount = 0;
|
||||
|
||||
if ($therapist->session_rate) {
|
||||
$baseAmount = $sessionsCount * $therapist->session_rate;
|
||||
} elseif ($therapist->hourly_rate) {
|
||||
$baseAmount = $hoursWorked * $therapist->hourly_rate;
|
||||
}
|
||||
|
||||
return [
|
||||
'therapist_id' => $therapistId,
|
||||
'period_start' => $periodStart,
|
||||
'period_end' => $periodEnd,
|
||||
'sessions_count' => $sessionsCount,
|
||||
'hours_worked' => round($hoursWorked, 2),
|
||||
'base_amount' => round($baseAmount, 2),
|
||||
'bonus' => 0,
|
||||
'deductions' => 0,
|
||||
'total_amount' => round($baseAmount, 2),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create wage record
|
||||
*/
|
||||
public function createWage(array $data, int $createdBy): Wage
|
||||
{
|
||||
$wage = Wage::create(array_merge($data, [
|
||||
'created_by' => $createdBy,
|
||||
]));
|
||||
|
||||
// Auto-create ledger entry
|
||||
$ledgerService = new LedgerService();
|
||||
$ledgerService->recordWage($wage);
|
||||
|
||||
return $wage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get therapist performance metrics
|
||||
*/
|
||||
public function getPerformanceMetrics(int $therapistId, string $periodStart, string $periodEnd): array
|
||||
{
|
||||
$wage = $this->calculateWage($therapistId, $periodStart, $periodEnd);
|
||||
$therapist = User::find($therapistId);
|
||||
|
||||
$targetSessions = $therapist->target_sessions_per_month ?? 0;
|
||||
$sessionsAchieved = $targetSessions > 0 ? ($wage['sessions_count'] / $targetSessions) * 100 : 0;
|
||||
|
||||
return [
|
||||
'sessions_count' => $wage['sessions_count'],
|
||||
'hours_worked' => $wage['hours_worked'],
|
||||
'target_sessions' => $targetSessions,
|
||||
'sessions_achieved_percentage' => round($sessionsAchieved, 2),
|
||||
'base_amount' => $wage['base_amount'],
|
||||
];
|
||||
}
|
||||
}
|
||||
53
artisan
Executable file
53
artisan
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Artisan Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When we run the console application, the current CLI command will be
|
||||
| executed in this console and the response sent back to a terminal
|
||||
| or another output device for the developers. Here goes nothing!
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
|
||||
$status = $kernel->handle(
|
||||
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||
new Symfony\Component\Console\Output\ConsoleOutput
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Shutdown The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once Artisan has finished running, we will fire off the shutdown events
|
||||
| so that any final work may be done by the application before we shut
|
||||
| down the process. This is the last thing to happen to the request.
|
||||
|
|
||||
*/
|
||||
|
||||
$kernel->terminate($input, $status);
|
||||
|
||||
exit($status);
|
||||
55
bootstrap/app.php
Normal file
55
bootstrap/app.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
69
composer.json
Normal file
69
composer.json
Normal file
@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"bacon/bacon-qr-code": "^3.0",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"jeroennoten/laravel-adminlte": "^3.15",
|
||||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.3",
|
||||
"laravel/tinker": "^2.8",
|
||||
"pragmarx/google2fa-laravel": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/pint": "^1.0",
|
||||
"laravel/sail": "^1.18",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpunit/phpunit": "^10.1",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
]
|
||||
},
|
||||
"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
|
||||
}
|
||||
8679
composer.lock
generated
Normal file
8679
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
550
config/adminlte.php
Normal file
550
config/adminlte.php
Normal file
@ -0,0 +1,550 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Title
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can change the default title of your admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the title section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'title' => 'AdminLTE 3',
|
||||
'title_prefix' => '',
|
||||
'title_postfix' => '',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Favicon
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can activate the favicon.
|
||||
|
|
||||
| For detailed instructions you can look the favicon section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'use_ico_only' => false,
|
||||
'use_full_favicon' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Google Fonts
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can allow or not the use of external google fonts. Disabling the
|
||||
| google fonts may be useful if your admin panel internet access is
|
||||
| restricted somehow.
|
||||
|
|
||||
| For detailed instructions you can look the google fonts section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'google_fonts' => [
|
||||
'allowed' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin Panel Logo
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can change the logo of your admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the logo section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'logo' => '<b>Admin</b>LTE',
|
||||
'logo_img' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'logo_img_class' => 'brand-image img-circle elevation-3',
|
||||
'logo_img_xl' => null,
|
||||
'logo_img_xl_class' => 'brand-image-xs',
|
||||
'logo_img_alt' => 'Admin Logo',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Logo
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can setup an alternative logo to use on your login and register
|
||||
| screens. When disabled, the admin panel logo will be used instead.
|
||||
|
|
||||
| For detailed instructions you can look the auth logo section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'auth_logo' => [
|
||||
'enabled' => false,
|
||||
'img' => [
|
||||
'path' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'alt' => 'Auth Logo',
|
||||
'class' => '',
|
||||
'width' => 50,
|
||||
'height' => 50,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Preloader Animation
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can change the preloader animation configuration. Currently, two
|
||||
| modes are supported: 'fullscreen' for a fullscreen preloader animation
|
||||
| and 'cwrapper' to attach the preloader animation into the content-wrapper
|
||||
| element and avoid overlapping it with the sidebars and the top navbar.
|
||||
|
|
||||
| For detailed instructions you can look the preloader section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'preloader' => [
|
||||
'enabled' => true,
|
||||
'mode' => 'fullscreen',
|
||||
'img' => [
|
||||
'path' => 'vendor/adminlte/dist/img/AdminLTELogo.png',
|
||||
'alt' => 'AdminLTE Preloader Image',
|
||||
'effect' => 'animation__shake',
|
||||
'width' => 60,
|
||||
'height' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Menu
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can activate and change the user menu.
|
||||
|
|
||||
| For detailed instructions you can look the user menu section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'usermenu_enabled' => true,
|
||||
'usermenu_header' => false,
|
||||
'usermenu_header_class' => 'bg-primary',
|
||||
'usermenu_image' => false,
|
||||
'usermenu_desc' => false,
|
||||
'usermenu_profile_url' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Layout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we change the layout of your admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the layout section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Layout-and-Styling-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'layout_topnav' => null,
|
||||
'layout_boxed' => null,
|
||||
'layout_fixed_sidebar' => null,
|
||||
'layout_fixed_navbar' => null,
|
||||
'layout_fixed_footer' => null,
|
||||
'layout_dark_mode' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Views Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can change the look and behavior of the authentication views.
|
||||
|
|
||||
| For detailed instructions you can look the auth classes section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Layout-and-Styling-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'classes_auth_card' => 'card-outline card-primary',
|
||||
'classes_auth_header' => '',
|
||||
'classes_auth_body' => '',
|
||||
'classes_auth_footer' => '',
|
||||
'classes_auth_icon' => '',
|
||||
'classes_auth_btn' => 'btn-flat btn-primary',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin Panel Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you can change the look and behavior of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the admin panel classes here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Layout-and-Styling-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'classes_body' => '',
|
||||
'classes_brand' => '',
|
||||
'classes_brand_text' => '',
|
||||
'classes_content_wrapper' => '',
|
||||
'classes_content_header' => '',
|
||||
'classes_content' => '',
|
||||
'classes_sidebar' => 'sidebar-dark-primary elevation-4',
|
||||
'classes_sidebar_nav' => '',
|
||||
'classes_topnav' => 'navbar-white navbar-light',
|
||||
'classes_topnav_nav' => 'navbar-expand',
|
||||
'classes_topnav_container' => 'container',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sidebar
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the sidebar of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the sidebar section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Layout-and-Styling-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'sidebar_mini' => 'lg',
|
||||
'sidebar_collapse' => false,
|
||||
'sidebar_collapse_auto_size' => false,
|
||||
'sidebar_collapse_remember' => false,
|
||||
'sidebar_collapse_remember_no_transition' => true,
|
||||
'sidebar_scrollbar_theme' => 'os-theme-light',
|
||||
'sidebar_scrollbar_auto_hide' => 'l',
|
||||
'sidebar_nav_accordion' => true,
|
||||
'sidebar_nav_animation_speed' => 300,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Control Sidebar (Right Sidebar)
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the right sidebar aka control sidebar of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the right sidebar section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Layout-and-Styling-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'right_sidebar' => false,
|
||||
'right_sidebar_icon' => 'fas fa-cogs',
|
||||
'right_sidebar_theme' => 'dark',
|
||||
'right_sidebar_slide' => true,
|
||||
'right_sidebar_push' => true,
|
||||
'right_sidebar_scrollbar_theme' => 'os-theme-light',
|
||||
'right_sidebar_scrollbar_auto_hide' => 'l',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| URLs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the url settings of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the urls section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Basic-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'use_route_url' => false,
|
||||
'dashboard_url' => 'home',
|
||||
'logout_url' => 'logout',
|
||||
'login_url' => 'login',
|
||||
'register_url' => 'register',
|
||||
'password_reset_url' => 'password/reset',
|
||||
'password_email_url' => 'password/email',
|
||||
'profile_url' => false,
|
||||
'disable_darkmode_routes' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laravel Asset Bundling
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can enable the Laravel Asset Bundling option for the admin panel.
|
||||
| Currently, the next modes are supported: 'mix', 'vite' and 'vite_js_only'.
|
||||
| When using 'vite_js_only', it's expected that your CSS is imported using
|
||||
| JavaScript. Typically, in your application's 'resources/js/app.js' file.
|
||||
| If you are not using any of these, leave it as 'false'.
|
||||
|
|
||||
| For detailed instructions you can look the asset bundling section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Other-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'laravel_asset_bundling' => false,
|
||||
'laravel_css_path' => 'css/app.css',
|
||||
'laravel_js_path' => 'js/app.js',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Menu Items
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the sidebar/top navigation of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Menu-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'menu' => [
|
||||
// Navbar items:
|
||||
[
|
||||
'type' => 'navbar-search',
|
||||
'text' => 'search',
|
||||
'topnav_right' => true,
|
||||
],
|
||||
[
|
||||
'type' => 'fullscreen-widget',
|
||||
'topnav_right' => true,
|
||||
],
|
||||
|
||||
// Sidebar items:
|
||||
[
|
||||
'type' => 'sidebar-menu-search',
|
||||
'text' => 'search',
|
||||
],
|
||||
[
|
||||
'text' => 'blog',
|
||||
'url' => 'admin/blog',
|
||||
'can' => 'manage-blog',
|
||||
],
|
||||
[
|
||||
'text' => 'pages',
|
||||
'url' => 'admin/pages',
|
||||
'icon' => 'far fa-fw fa-file',
|
||||
'label' => 4,
|
||||
'label_color' => 'success',
|
||||
],
|
||||
['header' => 'account_settings'],
|
||||
[
|
||||
'text' => 'profile',
|
||||
'url' => 'admin/settings',
|
||||
'icon' => 'fas fa-fw fa-user',
|
||||
],
|
||||
[
|
||||
'text' => 'change_password',
|
||||
'url' => 'admin/settings',
|
||||
'icon' => 'fas fa-fw fa-lock',
|
||||
],
|
||||
[
|
||||
'text' => 'multilevel',
|
||||
'icon' => 'fas fa-fw fa-share',
|
||||
'submenu' => [
|
||||
[
|
||||
'text' => 'level_one',
|
||||
'url' => '#',
|
||||
],
|
||||
[
|
||||
'text' => 'level_one',
|
||||
'url' => '#',
|
||||
'submenu' => [
|
||||
[
|
||||
'text' => 'level_two',
|
||||
'url' => '#',
|
||||
],
|
||||
[
|
||||
'text' => 'level_two',
|
||||
'url' => '#',
|
||||
'submenu' => [
|
||||
[
|
||||
'text' => 'level_three',
|
||||
'url' => '#',
|
||||
],
|
||||
[
|
||||
'text' => 'level_three',
|
||||
'url' => '#',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'text' => 'level_one',
|
||||
'url' => '#',
|
||||
],
|
||||
],
|
||||
],
|
||||
['header' => 'labels'],
|
||||
[
|
||||
'text' => 'important',
|
||||
'icon_color' => 'red',
|
||||
'url' => '#',
|
||||
],
|
||||
[
|
||||
'text' => 'warning',
|
||||
'icon_color' => 'yellow',
|
||||
'url' => '#',
|
||||
],
|
||||
[
|
||||
'text' => 'information',
|
||||
'icon_color' => 'cyan',
|
||||
'url' => '#',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Menu Filters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the menu filters of the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the menu filters section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Menu-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'filters' => [
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\GateFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\HrefFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\SearchFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\ActiveFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\ClassesFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\LangFilter::class,
|
||||
JeroenNoten\LaravelAdminLte\Menu\Filters\DataFilter::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Plugins Initialization
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can modify the plugins used inside the admin panel.
|
||||
|
|
||||
| For detailed instructions you can look the plugins section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Plugins-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'plugins' => [
|
||||
'Datatables' => [
|
||||
'active' => false,
|
||||
'files' => [
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js',
|
||||
],
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js',
|
||||
],
|
||||
[
|
||||
'type' => 'css',
|
||||
'asset' => false,
|
||||
'location' => '//cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css',
|
||||
],
|
||||
],
|
||||
],
|
||||
'Select2' => [
|
||||
'active' => false,
|
||||
'files' => [
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js',
|
||||
],
|
||||
[
|
||||
'type' => 'css',
|
||||
'asset' => false,
|
||||
'location' => '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.css',
|
||||
],
|
||||
],
|
||||
],
|
||||
'Chartjs' => [
|
||||
'active' => false,
|
||||
'files' => [
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.bundle.min.js',
|
||||
],
|
||||
],
|
||||
],
|
||||
'Sweetalert2' => [
|
||||
'active' => false,
|
||||
'files' => [
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdn.jsdelivr.net/npm/sweetalert2@8',
|
||||
],
|
||||
],
|
||||
],
|
||||
'Pace' => [
|
||||
'active' => false,
|
||||
'files' => [
|
||||
[
|
||||
'type' => 'css',
|
||||
'asset' => false,
|
||||
'location' => '//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-center-radar.min.css',
|
||||
],
|
||||
[
|
||||
'type' => 'js',
|
||||
'asset' => false,
|
||||
'location' => '//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| IFrame
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we change the IFrame mode configuration. Note these changes will
|
||||
| only apply to the view that extends and enable the IFrame mode.
|
||||
|
|
||||
| For detailed instructions you can look the iframe mode section here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/IFrame-Mode-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'iframe' => [
|
||||
'default_tab' => [
|
||||
'url' => null,
|
||||
'title' => null,
|
||||
],
|
||||
'buttons' => [
|
||||
'close' => true,
|
||||
'close_all' => true,
|
||||
'close_all_other' => true,
|
||||
'scroll_left' => true,
|
||||
'scroll_right' => true,
|
||||
'fullscreen' => true,
|
||||
],
|
||||
'options' => [
|
||||
'loading_screen' => 1000,
|
||||
'auto_show_new_tab' => true,
|
||||
'use_navbar_items' => true,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Livewire
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here we can enable the Livewire support.
|
||||
|
|
||||
| For detailed instructions you can look the livewire here:
|
||||
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Other-Configuration
|
||||
|
|
||||
*/
|
||||
|
||||
'livewire' => false,
|
||||
];
|
||||
188
config/app.php
Normal file
188
config/app.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application. This value is used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| any other location as required by the application or its packages.
|
||||
|
|
||||
*/
|
||||
|
||||
'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
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Faker Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This locale will be used by the Faker PHP library when generating fake
|
||||
| data for your database seeds. For example, this will be used to get
|
||||
| localized telephone numbers, street address information and more.
|
||||
|
|
||||
*/
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => 'file',
|
||||
// 'store' => 'redis',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => ServiceProvider::defaultProviders()->merge([
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
])->toArray(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'Example' => App\Facades\Example::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
115
config/auth.php
Normal file
115
config/auth.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default authentication "guard" and password
|
||||
| reset options for your application. You may change these defaults
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| here which uses session storage and the Eloquent user provider.
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication drivers have a user provider. This defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| mechanisms used by this application to persist your user's data.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| sources which represent each model / table. These sources may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may specify multiple password reset configurations if you have more
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => 'password_reset_tokens',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the amount of seconds before a password confirmation
|
||||
| times out and the user is prompted to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
||||
71
config/broadcasting.php
Normal file
71
config/broadcasting.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Broadcaster
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default broadcaster that will be used by the
|
||||
| framework when an event needs to be broadcast. You may set this to
|
||||
| any of the connections defined in the "connections" array below.
|
||||
|
|
||||
| Supported: "pusher", "ably", "redis", "log", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('BROADCAST_DRIVER', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the broadcast connections that will be used
|
||||
| to broadcast events to other systems or over websockets. Samples of
|
||||
| each available type of connection are provided inside this array.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
111
config/cache.php
Normal file
111
config/cache.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache connection that gets used while
|
||||
| using this caching library. This connection is used when another is
|
||||
| not explicitly specified when executing a given caching function.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'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' => 'cache',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
||||
34
config/cors.php
Normal file
34
config/cors.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure your settings for cross-origin resource sharing
|
||||
| or "CORS". This determines what cross-origin operations may execute
|
||||
| in web browsers. You are free to adjust these settings as needed.
|
||||
|
|
||||
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
||||
152
config/database.php
Normal file
152
config/database.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for all database work. Of course
|
||||
| you may use many connections at once using the Database library.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'mysql'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here are each of the database connections setup for your application.
|
||||
| Of course, examples of configuring each database platform that is
|
||||
| supported by Laravel is shown below to make development simple.
|
||||
|
|
||||
|
|
||||
| All database work in Laravel is done through the PHP PDO facilities
|
||||
| so make sure you have the driver for your particular database of
|
||||
| choice installed on your machine before you begin development.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'create_database_if_missing' => true,
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DATABASE_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'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 in the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => 'migrations',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 APC or Memcached. Laravel makes it easy to dig right in.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
76
config/filesystems.php
Normal file
76
config/filesystems.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application. Just store away!
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||
| may even configure multiple disks of the same driver. Defaults have
|
||||
| been set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
83
config/google2fa.php
Normal file
83
config/google2fa.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
* Enable / disable Google2FA.
|
||||
*/
|
||||
'enabled' => env('OTP_ENABLED', true),
|
||||
|
||||
/*
|
||||
* Lifetime in minutes.
|
||||
*
|
||||
* In case you need your users to be asked for a new one time passwords from time to time.
|
||||
*/
|
||||
'lifetime' => env('OTP_LIFETIME', 0), // 0 = eternal
|
||||
|
||||
/*
|
||||
* Renew lifetime at every new request.
|
||||
*/
|
||||
'keep_alive' => env('OTP_KEEP_ALIVE', true),
|
||||
|
||||
/*
|
||||
* Auth container binding.
|
||||
*/
|
||||
'auth' => 'auth',
|
||||
|
||||
/*
|
||||
* Guard.
|
||||
*/
|
||||
'guard' => '',
|
||||
|
||||
/*
|
||||
* 2FA verified session var.
|
||||
*/
|
||||
'session_var' => 'google2fa',
|
||||
|
||||
/*
|
||||
* One Time Password request input name.
|
||||
*/
|
||||
'otp_input' => 'one_time_password',
|
||||
|
||||
/*
|
||||
* One Time Password Window.
|
||||
*/
|
||||
'window' => 1,
|
||||
|
||||
/*
|
||||
* Forbid user to reuse One Time Passwords.
|
||||
*/
|
||||
'forbid_old_passwords' => false,
|
||||
|
||||
/*
|
||||
* User's table column for google2fa secret.
|
||||
*/
|
||||
'otp_secret_column' => 'google2fa_secret',
|
||||
|
||||
/*
|
||||
* One Time Password View.
|
||||
*/
|
||||
'view' => 'google2fa.index',
|
||||
|
||||
/*
|
||||
* One Time Password error message.
|
||||
*/
|
||||
'error_messages' => [
|
||||
'wrong_otp' => "The 'One Time Password' typed was wrong.",
|
||||
'cannot_be_empty' => 'One Time Password cannot be empty.',
|
||||
'unknown' => 'An unknown error has occurred. Please try again.',
|
||||
],
|
||||
|
||||
/*
|
||||
* Throw exceptions or just fire events?
|
||||
*/
|
||||
'throw_exceptions' => env('OTP_THROW_EXCEPTION', true),
|
||||
|
||||
/*
|
||||
* Which image backend to use for generating QR codes?
|
||||
*
|
||||
* Supports imagemagick, svg and eps
|
||||
*/
|
||||
'qrcode_image_backend' => \PragmaRX\Google2FALaravel\Support\Constants::QRCODE_IMAGE_BACKEND_SVG,
|
||||
|
||||
];
|
||||
54
config/hashing.php
Normal file
54
config/hashing.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Hash Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default hash driver that will be used to hash
|
||||
| passwords for your application. By default, the bcrypt algorithm is
|
||||
| used; however, you remain free to modify this option if you wish.
|
||||
|
|
||||
| Supported: "bcrypt", "argon", "argon2id"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'bcrypt',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bcrypt Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Bcrypt algorithm. This will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'bcrypt' => [
|
||||
'rounds' => env('BCRYPT_ROUNDS', 12),
|
||||
'verify' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Argon Options
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the configuration options that should be used when
|
||||
| passwords are hashed using the Argon algorithm. These will allow you
|
||||
| to control the amount of time it takes to hash the given password.
|
||||
|
|
||||
*/
|
||||
|
||||
'argon' => [
|
||||
'memory' => 65536,
|
||||
'threads' => 1,
|
||||
'time' => 4,
|
||||
'verify' => true,
|
||||
],
|
||||
|
||||
];
|
||||
131
config/logging.php
Normal file
131
config/logging.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?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 gets used when writing
|
||||
| messages to the logs. The name specified in this option should match
|
||||
| one of the channels defined in the "channels" configuration array.
|
||||
|
|
||||
*/
|
||||
|
||||
'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' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog",
|
||||
| "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['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' => 14,
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => 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'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
134
config/mail.php
Normal file
134
config/mail.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send any email
|
||||
| messages sent by your application. Alternative mailers may be setup
|
||||
| and used as needed; however, this mailer will be used by default.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'smtp'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 to be used while
|
||||
| sending an e-mail. You will specify which one you are using for your
|
||||
| mailers below. You are free to add additional mailers as required.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "log", "array", "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => null,
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all e-mails 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 e-mails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Markdown Mail Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If you are using Markdown based email rendering, you may configure your
|
||||
| theme and component paths here, allowing you to customize the design
|
||||
| of the emails. Or, you may simply stick with the Laravel defaults!
|
||||
|
|
||||
*/
|
||||
|
||||
'markdown' => [
|
||||
'theme' => 'default',
|
||||
|
||||
'paths' => [
|
||||
resource_path('views/vendor/mail'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
109
config/queue.php
Normal file
109
config/queue.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue API supports an assortment of back-ends via a single
|
||||
| API, giving you convenient access to each back-end using the same
|
||||
| syntax for every one. Here you may define a default connection.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'sync'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection information for each server that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with Laravel. You are free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => 'localhost',
|
||||
'queue' => 'default',
|
||||
'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' => 'default',
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control which database and table are used to store the jobs that
|
||||
| have failed. You may change them to any database / table you wish.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'mysql'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
83
config/sanctum.php
Normal file
83
config/sanctum.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort()
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
|
||||
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
34
config/services.php
Normal file
34
config/services.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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.
|
||||
|
|
||||
*/
|
||||
|
||||
'mailgun' => [
|
||||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
'secret' => env('MAILGUN_SECRET'),
|
||||
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
];
|
||||
214
config/session.php
Normal file
214
config/session.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default session "driver" that will be used on
|
||||
| requests. By default, we will use the lightweight native driver but
|
||||
| you may specify any of the other wonderful drivers provided here.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "apc",
|
||||
| "memcached", "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'file'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 immediately expire on the browser closing, set that option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it is stored. All encryption will be run
|
||||
| automatically by Laravel and you can use the Session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the native session driver, we need a location where session
|
||||
| files may be stored. A default has been set for you but a different
|
||||
| location may be specified. This is only needed for file sessions.
|
||||
|
|
||||
*/
|
||||
|
||||
'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 we
|
||||
| should use to manage the sessions. Of course, a sensible default is
|
||||
| provided for you; however, you are free to change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => 'sessions',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While using one of the framework's cache driven session backends you may
|
||||
| list a cache store that should be used for these sessions. This value
|
||||
| must match with one of the application's configured cache "stores".
|
||||
|
|
||||
| Affects: "apc", "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the cookie used to identify a session
|
||||
| instance by ID. The name specified here will get used every time a
|
||||
| new session cookie is created by the framework for every driver.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application but you are free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => '/',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the domain of the cookie used to identify a session
|
||||
| in your application. This will determine which domains the cookie is
|
||||
| available to in your application. A sensible default has been set.
|
||||
|
|
||||
*/
|
||||
|
||||
'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. You are free to modify this option if needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'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" since this is a secure default value.
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'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' => false,
|
||||
|
||||
];
|
||||
36
config/view.php
Normal file
36
config/view.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Storage Paths
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Most templating systems load templates from disk. Here you may specify
|
||||
| an array of paths that should be checked for your views. Of course
|
||||
| the usual Laravel view path has already been registered for you.
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => [
|
||||
resource_path('views'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Compiled View Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines where all the compiled Blade templates will be
|
||||
| stored for your application. Typically, this is within the storage
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'compiled' => env(
|
||||
'VIEW_COMPILED_PATH',
|
||||
realpath(storage_path('framework/views'))
|
||||
),
|
||||
|
||||
];
|
||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
44
database/factories/UserFactory.php
Normal file
44
database/factories/UserFactory.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
35
database/migrations/2014_10_12_000000_create_users_table.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('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->text('two_factor_secret')->nullable();
|
||||
$table->text('two_factor_recovery_codes')->nullable();
|
||||
$table->boolean('two_factor_enabled')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user