Initaler Commit
This commit is contained in:
commit
4c27c53309
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
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
65
.env.example
Normal file
65
.env.example
Normal file
@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
11
.gitattributes
vendored
Normal file
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
|
||||
30
.github/copilot-instructions.md
vendored
Normal file
30
.github/copilot-instructions.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
- [x] Verify that the copilot-instructions.md file in the .github directory is created.
|
||||
Laravel-Anwendung für Snackautomaten-Verwaltung wird erstellt.
|
||||
|
||||
- [x] Clarify Project Requirements
|
||||
Laravel PHP-Anwendung für Snackautomaten-Verwaltung mit LMIV-Daten, Produktkatalog-Backend und Automatenverwaltung.
|
||||
|
||||
- [x] Scaffold the Project
|
||||
Laravel-Projekt erfolgreich erstellt mit Composer.
|
||||
|
||||
- [x] Customize the Project
|
||||
Vollständiges Snackautomaten-System mit LMIV-Konformität, Produktkatalog, Automatenverwaltung und öffentlicher Anzeige implementiert.
|
||||
|
||||
- [x] Install Required Extensions
|
||||
Keine zusätzlichen Extensions erforderlich.
|
||||
|
||||
- [x] Compile the Project
|
||||
Projekt erfolgreich kompiliert und Dependencies installiert. Migrationen ausgeführt und Beispieldaten geladen.
|
||||
|
||||
- [x] Create and Run Task
|
||||
<!--
|
||||
Verify that all previous steps have been completed.
|
||||
Check https://code.visualstudio.com/docs/debugtest/tasks to determine if the project needs a task. If so, use the create_and_run_task to create and launch a task based on package.json, README.md, and project structure.
|
||||
Skip this step otherwise.
|
||||
-->
|
||||
|
||||
- [x] Launch the Project
|
||||
Server läuft auf http://0.0.0.0:8001 mit Authentifizierung und MySQL-Support.
|
||||
|
||||
- [x] Ensure Documentation is Complete
|
||||
README.md und MYSQL_SETUP.md vollständig mit allen neuen Features dokumentiert.
|
||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
75
MYSQL_SETUP.md
Normal file
75
MYSQL_SETUP.md
Normal file
@ -0,0 +1,75 @@
|
||||
# MySQL Setup für LMIV Snackautomat
|
||||
|
||||
## Voraussetzungen
|
||||
- MySQL Server installiert und läuft
|
||||
- MySQL-Client (mysql-Kommandozeile oder phpMyAdmin)
|
||||
|
||||
## Datenbank und Benutzer erstellen
|
||||
|
||||
```sql
|
||||
-- 1. Als MySQL Root-User anmelden
|
||||
-- mysql -u root -p
|
||||
|
||||
-- 2. Datenbank erstellen
|
||||
CREATE DATABASE lmiv_snackautomat CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- 3. Benutzer erstellen (für lokale Entwicklung)
|
||||
CREATE USER 'lmiv_snackautomat'@'localhost' IDENTIFIED BY 'lmiv_snackautomat';
|
||||
|
||||
-- 4. Berechtigung gewähren
|
||||
GRANT ALL PRIVILEGES ON lmiv_snackautomat.* TO 'lmiv_snackautomat'@'localhost';
|
||||
|
||||
-- 5. Für Netzwerkzugriff (falls benötigt)
|
||||
CREATE USER 'lmiv_snackautomat'@'%' IDENTIFIED BY 'lmiv_snackautomat';
|
||||
GRANT ALL PRIVILEGES ON lmiv_snackautomat.* TO 'lmiv_snackautomat'@'%';
|
||||
|
||||
-- 6. Berechtigung aktualisieren
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
-- 7. Überprüfung
|
||||
SHOW DATABASES;
|
||||
SELECT User, Host FROM mysql.user WHERE User = 'lmiv_snackautomat';
|
||||
```
|
||||
|
||||
## .env Konfiguration anpassen
|
||||
|
||||
Nach der Datenbank-Erstellung passen Sie die .env-Datei an:
|
||||
|
||||
```
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=192.168.178.201 # MySQL-Server IP
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=lmiv_snackautomat
|
||||
DB_USERNAME=lmiv_snackautomat
|
||||
DB_PASSWORD=lmiv_snackautomat
|
||||
```
|
||||
|
||||
## Migration und Setup
|
||||
|
||||
```bash
|
||||
# Datenbank-Verbindung testen
|
||||
php artisan migrate:status
|
||||
|
||||
# Migrationen ausführen
|
||||
php artisan migrate
|
||||
|
||||
# Admin-User erstellen
|
||||
php artisan db:seed --class=AdminUserSeeder
|
||||
|
||||
# Beispieldaten laden
|
||||
php artisan db:seed --class=ProductSeeder
|
||||
```
|
||||
|
||||
## Für Produktionsumgebung
|
||||
|
||||
1. **Starke Passwörter verwenden**
|
||||
2. **Firewalls konfigurieren**
|
||||
3. **SSL/TLS aktivieren**
|
||||
4. **Backup-Strategie implementieren**
|
||||
|
||||
```sql
|
||||
-- Produktions-User mit stärkerem Passwort
|
||||
CREATE USER 'lmiv_prod'@'localhost' IDENTIFIED BY 'IhrStarkesPasswort2024!';
|
||||
GRANT ALL PRIVILEGES ON lmiv_snackautomat.* TO 'lmiv_prod'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
235
README.md
Normal file
235
README.md
Normal file
@ -0,0 +1,235 @@
|
||||
# LMIV Snackautomat Management System
|
||||
|
||||
Ein Laravel-basiertes Web-Management-System für Snackautomaten mit vollständiger LMIV-Konformität (Lebensmittelinformationsverordnung).
|
||||
|
||||
## Neue Features
|
||||
|
||||
### 🔐 Backend-Authentifizierung
|
||||
- Sicheres Admin-Backend mit Login-System
|
||||
- Benutzerregistrierung und -verwaltung
|
||||
- Session-basierte Authentifizierung
|
||||
|
||||
### 🔗 Direkte Automaten-URLs
|
||||
- Automaten können direkt über URL aufgerufen werden
|
||||
- Format: `http://ihre-domain/machine/{id}`
|
||||
- Ideal für QR-Codes oder Direktlinks
|
||||
|
||||
### 🗄️ MySQL-Unterstützung
|
||||
- Vollständige MySQL-Datenbankunterstützung
|
||||
- Einfache Migration von SQLite zu MySQL
|
||||
- Netzwerk-fähige Datenbank für mehrere Clients
|
||||
|
||||
## Features
|
||||
|
||||
### 🍫 Produktkatalog mit LMIV-Daten
|
||||
- Vollständige Nährwertangaben pro 100g
|
||||
- Zutatenlisten und Allergen-Informationen
|
||||
- Hersteller- und Herkunftsangaben
|
||||
- Aufbewahrungshinweise und Verwendungsempfehlungen
|
||||
- Produktbilder
|
||||
|
||||
### 🏪 Automatenverwaltung
|
||||
- Verwaltung mehrerer Snackautomaten
|
||||
- Standortinformationen
|
||||
- Status-Verwaltung (aktiv/inaktiv)
|
||||
|
||||
### 📦 Fachverwaltung
|
||||
- Konfiguration der Automatenfächer mit Fachnummern
|
||||
- Kapazitätsverwaltung
|
||||
- Produkt-zu-Fach-Zuordnung
|
||||
- Bestandsverwaltung
|
||||
|
||||
### 🖥️ Öffentliche Anzeige
|
||||
- Benutzerfreundliche Auswahl nach Fachnummer
|
||||
- Produktinformationen gemäß LMIV auf Knopfdruck
|
||||
- Responsive Design für Touch-Displays
|
||||
- Übersichtliche Darstellung verfügbarer Produkte
|
||||
|
||||
### 👨💼 Admin-Backend
|
||||
- Komplette Produktverwaltung
|
||||
- Automatenkonfiguration
|
||||
- Fach- und Bestandsverwaltung
|
||||
- Dashboard mit Übersicht
|
||||
|
||||
## Technische Anforderungen
|
||||
|
||||
- PHP 8.1 oder höher
|
||||
- Composer
|
||||
- SQLite/MySQL/PostgreSQL
|
||||
- Node.js (optional, für Asset-Kompilierung)
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Repository klonen/herunterladen
|
||||
```bash
|
||||
# Falls Git verwendet wird
|
||||
git clone <repository-url>
|
||||
cd LMIV-Snackautomat
|
||||
|
||||
# Oder das Projekt direkt verwenden wenn bereits vorhanden
|
||||
cd d:\Entwicklung\LMIV-Snackautomat
|
||||
```
|
||||
|
||||
### 2. Abhängigkeiten installieren
|
||||
```bash
|
||||
composer install
|
||||
```
|
||||
|
||||
### 3. Umgebung konfigurieren
|
||||
```bash
|
||||
# .env-Datei erstellen (falls nicht vorhanden)
|
||||
cp .env.example .env
|
||||
|
||||
# Application Key generieren (falls noch nicht geschehen)
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
### 4. Datenbank einrichten
|
||||
```bash
|
||||
# Migrationen ausführen
|
||||
php artisan migrate
|
||||
|
||||
# Beispieldaten laden (optional)
|
||||
php artisan db:seed --class=ProductSeeder
|
||||
|
||||
# Storage-Link erstellen für Produktbilder
|
||||
php artisan storage:link
|
||||
```
|
||||
|
||||
### 5. Server starten
|
||||
```bash
|
||||
# Für lokale Entwicklung
|
||||
php artisan serve
|
||||
|
||||
# Für Netzwerkzugriff (alle Geräte im Netzwerk)
|
||||
php artisan serve --host=0.0.0.0 --port=8001
|
||||
```
|
||||
|
||||
Die Anwendung ist dann unter `http://localhost:8000` (lokal) oder `http://ihre-ip:8001` (Netzwerk) erreichbar.
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Öffentliche Anzeige
|
||||
- Hauptseite: `http://localhost:8001`
|
||||
- Direkte Automatenwahl: `http://localhost:8001/machine/{id}`
|
||||
- Zeigt alle verfügbaren Produkte mit Fachnummern
|
||||
- Klick auf Produkt zeigt LMIV-Informationen
|
||||
|
||||
### Admin-Bereich (Login erforderlich)
|
||||
- Admin Login: `http://localhost:8001/login`
|
||||
- Admin Dashboard: `http://localhost:8001/admin`
|
||||
- Produktverwaltung: `http://localhost:8001/admin/products`
|
||||
- Automatenverwaltung: `http://localhost:8001/admin/vending-machines`
|
||||
- Fachverwaltung: `http://localhost:8001/admin/slots`
|
||||
|
||||
### Standard-Anmeldedaten
|
||||
- **Email**: admin@snackautomat.local
|
||||
- **Passwort**: admin123
|
||||
- **Zweiter Account**: verwalter@snackautomat.local / verwalter123
|
||||
|
||||
⚠️ **WICHTIG**: Ändern Sie diese Passwörter nach dem ersten Login!
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
app/
|
||||
├── Http/Controllers/
|
||||
│ ├── ProductController.php # Produktverwaltung
|
||||
│ ├── VendingMachineController.php # Automatenverwaltung
|
||||
│ ├── SlotController.php # Fachverwaltung
|
||||
│ └── VendingDisplayController.php # Öffentliche Anzeige
|
||||
├── Models/
|
||||
│ ├── Product.php # Produkt-Model mit LMIV-Daten
|
||||
│ ├── VendingMachine.php # Automat-Model
|
||||
│ ├── Slot.php # Fach-Model
|
||||
│ └── SlotProduct.php # Zuordnung Fach-Produkt
|
||||
database/
|
||||
├── migrations/ # Datenbankstruktur
|
||||
└── seeders/
|
||||
└── ProductSeeder.php # Beispieldaten
|
||||
resources/views/
|
||||
├── layouts/
|
||||
│ └── app.blade.php # Haupt-Layout
|
||||
├── vending/ # Öffentliche Anzeige
|
||||
│ ├── index.blade.php # Hauptseite
|
||||
│ └── product-details.blade.php # LMIV-Detailansicht
|
||||
└── admin/ # Admin-Bereich
|
||||
├── dashboard.blade.php # Admin-Dashboard
|
||||
└── products/ # Produktverwaltung
|
||||
```
|
||||
|
||||
## LMIV-Konformität
|
||||
|
||||
Das System unterstützt alle relevanten Angaben gemäß der EU-Lebensmittelinformationsverordnung:
|
||||
|
||||
- **Nährwerte**: Brennwert (kJ/kcal), Fett, gesättigte Fettsäuren, Kohlenhydrate, Zucker, Eiweiß, Salz
|
||||
- **Zutaten**: Vollständige Zutatenliste
|
||||
- **Allergene**: Kennzeichnung allergener Stoffe
|
||||
- **Herkunft**: Herkunftsangaben
|
||||
- **Hersteller**: Herstellerinformationen
|
||||
- **Aufbewahrung**: Lagerungshinweise
|
||||
- **Mindesthaltbarkeit**: Haltbarkeitsinformationen
|
||||
|
||||
## MySQL-Einrichtung
|
||||
|
||||
Für die Verwendung mit MySQL folgen Sie der Anleitung in `MYSQL_SETUP.md`:
|
||||
|
||||
1. **MySQL-Datenbank erstellen**
|
||||
2. **Benutzer anlegen**
|
||||
3. **.env für MySQL konfigurieren**
|
||||
4. **Migrationen ausführen**
|
||||
|
||||
```bash
|
||||
# Nach MySQL-Setup
|
||||
php artisan migrate
|
||||
php artisan db:seed --class=AdminUserSeeder
|
||||
php artisan db:seed --class=ProductSeeder
|
||||
```
|
||||
|
||||
### Design anpassen
|
||||
- CSS-Framework: Tailwind CSS
|
||||
- Layout-Datei: `resources/views/layouts/app.blade.php`
|
||||
- Farbschema in Tailwind-Klassen anpassbar
|
||||
|
||||
### Weitere Felder hinzufügen
|
||||
1. Migration erstellen: `php artisan make:migration add_field_to_products_table`
|
||||
2. Model erweitern: `app/Models/Product.php` - `$fillable` Array
|
||||
3. Controller anpassen: Validierung in `ProductController.php`
|
||||
4. Views erweitern: Formulare und Anzeigen
|
||||
|
||||
### Mehrsprachigkeit
|
||||
- Laravel Localization kann nachträglich integriert werden
|
||||
- Views sind bereits strukturiert für einfache Übersetzung
|
||||
|
||||
## Support & Wartung
|
||||
|
||||
### Backup
|
||||
```bash
|
||||
# Datenbank-Backup
|
||||
php artisan backup:run
|
||||
|
||||
# Produktbilder: storage/app/public/products/
|
||||
```
|
||||
|
||||
### Updates
|
||||
```bash
|
||||
# Abhängigkeiten aktualisieren
|
||||
composer update
|
||||
|
||||
# Cache leeren nach Updates
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan view:clear
|
||||
```
|
||||
|
||||
## Lizenz
|
||||
|
||||
Dieses Projekt steht unter der MIT-Lizenz. Weitere Details in der LICENSE-Datei.
|
||||
|
||||
## Entwickelt für
|
||||
|
||||
- Betreiber von Snackautomaten
|
||||
- Catering-Unternehmen
|
||||
- Büro- und Industriekomplexe
|
||||
- Bildungseinrichtungen
|
||||
- Jeder, der LMIV-konforme Produktinformationen bereitstellen muss
|
||||
78
app/Console/Commands/TestPublicDisplay.php
Normal file
78
app/Console/Commands/TestPublicDisplay.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Tenant;
|
||||
use App\Http\Controllers\VendingDisplayController;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TestPublicDisplay extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:public-display';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test public display with different tenant settings';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('=== Public Display Test ===');
|
||||
|
||||
$tenant = Tenant::first();
|
||||
if (!$tenant) {
|
||||
$this->error('Kein Mandant gefunden!');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info("Testing with Tenant: {$tenant->name}");
|
||||
|
||||
// Test 1: Beide Einstellungen aktiviert
|
||||
$tenant->update(['show_prices' => true, 'show_stock' => true]);
|
||||
$this->testDisplay($tenant, 'Beide aktiviert');
|
||||
|
||||
// Test 2: Nur Preise deaktiviert
|
||||
$tenant->update(['show_prices' => false, 'show_stock' => true]);
|
||||
$this->testDisplay($tenant, 'Preise deaktiviert');
|
||||
|
||||
// Test 3: Nur Stock deaktiviert
|
||||
$tenant->update(['show_prices' => true, 'show_stock' => false]);
|
||||
$this->testDisplay($tenant, 'Stock deaktiviert');
|
||||
|
||||
// Test 4: Beide deaktiviert
|
||||
$tenant->update(['show_prices' => false, 'show_stock' => false]);
|
||||
$this->testDisplay($tenant, 'Beide deaktiviert');
|
||||
|
||||
// Zurücksetzen
|
||||
$tenant->update(['show_prices' => true, 'show_stock' => true]);
|
||||
$this->info('✅ Einstellungen zurückgesetzt');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function testDisplay($tenant, $scenario)
|
||||
{
|
||||
$this->info("--- Test: {$scenario} ---");
|
||||
$this->info("show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
// Simuliere öffentliche Anzeige-Logik
|
||||
$showPrice = !isset($tenant) || $tenant->show_prices;
|
||||
$showStock = !isset($tenant) || $tenant->show_stock;
|
||||
|
||||
$this->info("Würde Preis anzeigen: " . ($showPrice ? 'JA' : 'NEIN'));
|
||||
$this->info("Würde Stock anzeigen: " . ($showStock ? 'JA' : 'NEIN'));
|
||||
$this->newLine();
|
||||
}
|
||||
}
|
||||
73
app/Console/Commands/TestTenantSettings.php
Normal file
73
app/Console/Commands/TestTenantSettings.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Tenant;
|
||||
|
||||
class TestTenantSettings extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:tenant-settings';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test tenant settings functionality';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('=== Mandanten-Einstellungen Test ===');
|
||||
|
||||
$tenant = Tenant::first();
|
||||
|
||||
if (!$tenant) {
|
||||
$this->error('Kein Mandant gefunden!');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info("Tenant ID: {$tenant->id}");
|
||||
$this->info("Tenant Name: {$tenant->name}");
|
||||
$this->info("show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
$this->newLine();
|
||||
|
||||
// Test: Einstellungen ändern
|
||||
$this->info('=== Test: Einstellungen ändern ===');
|
||||
$originalPrices = $tenant->show_prices;
|
||||
$originalStock = $tenant->show_stock;
|
||||
|
||||
// Ändere Einstellungen
|
||||
$tenant->show_prices = false;
|
||||
$tenant->show_stock = false;
|
||||
$tenant->save();
|
||||
|
||||
// Lade neu und prüfe
|
||||
$tenant->refresh();
|
||||
$this->info("Nach Änderung - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("Nach Änderung - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
// Zurücksetzen
|
||||
$tenant->show_prices = $originalPrices;
|
||||
$tenant->show_stock = $originalStock;
|
||||
$tenant->save();
|
||||
|
||||
$tenant->refresh();
|
||||
$this->info("Zurückgesetzt - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("Zurückgesetzt - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
$this->newLine();
|
||||
$this->info('✅ Test erfolgreich!');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
89
app/Console/Commands/TestTenantSettingsWeb.php
Normal file
89
app/Console/Commands/TestTenantSettingsWeb.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Tenant;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class TestTenantSettingsWeb extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:tenant-settings-web';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test tenant settings via web interface simulation';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('=== Web Interface Test ===');
|
||||
|
||||
$tenant = Tenant::first();
|
||||
if (!$tenant) {
|
||||
$this->error('Kein Mandant gefunden!');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info("Testing with Tenant: {$tenant->name}");
|
||||
$this->info("Original show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("Original show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
// Simuliere Session
|
||||
Session::put('current_tenant_id', $tenant->id);
|
||||
Session::put('current_tenant', $tenant);
|
||||
|
||||
// Simuliere Request mit deaktivierten Checkboxen
|
||||
$request = new Request();
|
||||
$request->merge([
|
||||
'_token' => csrf_token(),
|
||||
'_method' => 'PUT'
|
||||
// Checkboxes nicht gesetzt = deaktiviert
|
||||
]);
|
||||
|
||||
try {
|
||||
$controller = new SettingsController();
|
||||
$response = $controller->updateTenantSettings($request);
|
||||
|
||||
// Prüfe Ergebnis
|
||||
$tenant->refresh();
|
||||
$this->info("Nach Update - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("Nach Update - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
// Test mit aktivierten Checkboxen
|
||||
$request2 = new Request();
|
||||
$request2->merge([
|
||||
'_token' => csrf_token(),
|
||||
'_method' => 'PUT',
|
||||
'show_prices' => '1',
|
||||
'show_stock' => '1'
|
||||
]);
|
||||
|
||||
$controller->updateTenantSettings($request2);
|
||||
|
||||
$tenant->refresh();
|
||||
$this->info("Nach Reaktivierung - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
|
||||
$this->info("Nach Reaktivierung - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
|
||||
|
||||
$this->info('✅ Web Interface Test erfolgreich!');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Fehler: ' . $e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
30
app/Console/Commands/UpdateProductNutrition.php
Normal file
30
app/Console/Commands/UpdateProductNutrition.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class UpdateProductNutrition extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:update-product-nutrition';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
||||
40
app/Http/Controllers/Auth/LoginController.php
Normal file
40
app/Http/Controllers/Auth/LoginController.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/admin';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('auth')->only('logout');
|
||||
}
|
||||
}
|
||||
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
}
|
||||
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
||||
88
app/Http/Controllers/Concerns/HasTenantSecurity.php
Normal file
88
app/Http/Controllers/Concerns/HasTenantSecurity.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Concerns;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait HasTenantSecurity
|
||||
{
|
||||
/**
|
||||
* Gibt die Mandanten-ID zurück, auf die der aktuelle Benutzer zugreifen darf
|
||||
* - Super Admins: Session-basierte Mandantenauswahl oder null (alle Mandanten)
|
||||
* - Mandanten-Admins: Nur ihr eigener Mandant
|
||||
*/
|
||||
protected function getCurrentTenantId(): ?int
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Super Admins können über Session den Mandanten wechseln
|
||||
if ($user->isSuperAdmin()) {
|
||||
return session('current_tenant_id');
|
||||
}
|
||||
|
||||
// Mandanten-Admins sind auf ihren eigenen Mandanten beschränkt
|
||||
if ($user->isTenantAdmin()) {
|
||||
return $user->tenant_id;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob der aktuelle Benutzer auf den angegebenen Mandanten zugreifen darf
|
||||
*/
|
||||
protected function canAccessTenant(?int $tenantId): bool
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Super Admins haben Zugriff auf alle Mandanten
|
||||
if ($user->isSuperAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Mandanten-Admins nur auf ihren eigenen Mandanten
|
||||
if ($user->isTenantAdmin()) {
|
||||
return $user->tenant_id === $tenantId;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wirft eine 403-Exception wenn der Benutzer nicht auf den Mandanten zugreifen darf
|
||||
*/
|
||||
protected function ensureTenantAccess(?int $tenantId): void
|
||||
{
|
||||
if (!$this->canAccessTenant($tenantId)) {
|
||||
abort(403, 'Zugriff auf diesen Mandanten nicht erlaubt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stellt sicher dass Mandanten-Admins ihre Session auf ihren eigenen Mandanten setzen
|
||||
*/
|
||||
protected function ensureCorrectTenantSession(): void
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user && $user->isTenantAdmin()) {
|
||||
// Mandanten-Admins müssen immer ihren eigenen Mandanten in der Session haben
|
||||
if (session('current_tenant_id') !== $user->tenant_id) {
|
||||
session(['current_tenant_id' => $user->tenant_id]);
|
||||
|
||||
// Lade auch den Mandanten in die Session
|
||||
if ($user->tenant) {
|
||||
session(['current_tenant' => $user->tenant]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
63
app/Http/Controllers/DebugSettingsController.php
Normal file
63
app/Http/Controllers/DebugSettingsController.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class DebugSettingsController extends Controller
|
||||
{
|
||||
public function updateTenantSettings(Request $request): RedirectResponse
|
||||
{
|
||||
// Logging für Debug
|
||||
\Log::info('=== DEBUG SETTINGS CONTROLLER ERREICHT ===', [
|
||||
'method' => $request->method(),
|
||||
'all_data' => $request->all(),
|
||||
'has_show_prices' => $request->has('show_prices'),
|
||||
'has_show_stock' => $request->has('show_stock'),
|
||||
'user_id' => auth()->id(),
|
||||
'session_tenant_id' => session('current_tenant_id')
|
||||
]);
|
||||
|
||||
// Nimm einfach den ersten Mandanten
|
||||
$tenant = Tenant::first();
|
||||
|
||||
if (!$tenant) {
|
||||
\Log::error('Kein Mandant gefunden!');
|
||||
return redirect()->back()->with('error', 'Kein Mandant gefunden');
|
||||
}
|
||||
|
||||
// Alte Werte loggen
|
||||
$oldValues = [
|
||||
'show_prices' => $tenant->show_prices,
|
||||
'show_stock' => $tenant->show_stock
|
||||
];
|
||||
|
||||
\Log::info('Alte Werte:', $oldValues);
|
||||
|
||||
// Neue Werte setzen
|
||||
$newValues = [
|
||||
'show_prices' => $request->has('show_prices'),
|
||||
'show_stock' => $request->has('show_stock')
|
||||
];
|
||||
|
||||
\Log::info('Neue Werte:', $newValues);
|
||||
|
||||
// Update durchführen
|
||||
$tenant->update($newValues);
|
||||
|
||||
// Prüfen ob Update erfolgreich
|
||||
$tenant->refresh();
|
||||
$finalValues = [
|
||||
'show_prices' => $tenant->show_prices,
|
||||
'show_stock' => $tenant->show_stock
|
||||
];
|
||||
|
||||
\Log::info('Final Werte nach Update:', $finalValues);
|
||||
|
||||
return redirect()->route('admin.settings.tenant')
|
||||
->with('success', 'DEBUG: Einstellungen gespeichert - siehe Log für Details');
|
||||
}
|
||||
}
|
||||
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
142
app/Http/Controllers/ProductController.php
Normal file
142
app/Http/Controllers/ProductController.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Http\Requests\ProductRequest;
|
||||
use App\Http\Controllers\Concerns\HasTenantSecurity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
use HasTenantSecurity;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$query = Product::query();
|
||||
|
||||
if ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$products = $query->paginate(15);
|
||||
return view('admin.products.index', compact('products'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
return view('admin.products.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(ProductRequest $request): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
if (!$tenantId) {
|
||||
return redirect()->back()->with('error', 'Kein Mandant ausgewählt.');
|
||||
}
|
||||
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
$extension = $image->getClientOriginalExtension();
|
||||
|
||||
// Stelle sicher, dass WebP-Dateien korrekt behandelt werden
|
||||
if (strtolower($extension) === 'webp' || $image->getMimeType() === 'image/webp') {
|
||||
$fileName = time() . '_' . uniqid() . '.webp';
|
||||
$imagePath = $image->storeAs('products', $fileName, 'public');
|
||||
} else {
|
||||
$imagePath = $image->store('products', 'public');
|
||||
}
|
||||
|
||||
$validated['image'] = $imagePath;
|
||||
}
|
||||
|
||||
// Setze automatisch die tenant_id
|
||||
$validated['tenant_id'] = $tenantId;
|
||||
|
||||
Product::create($validated);
|
||||
|
||||
return redirect()->route('products.index')->with('success', 'Produkt erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Product $product): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($product->tenant_id);
|
||||
|
||||
return view('admin.products.show', compact('product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Product $product): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($product->tenant_id);
|
||||
|
||||
return view('admin.products.edit', compact('product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(ProductRequest $request, Product $product): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($product->tenant_id);
|
||||
|
||||
$validated = $request->validated();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image');
|
||||
$extension = $image->getClientOriginalExtension();
|
||||
|
||||
// Stelle sicher, dass WebP-Dateien korrekt behandelt werden
|
||||
if (strtolower($extension) === 'webp' || $image->getMimeType() === 'image/webp') {
|
||||
$fileName = time() . '_' . uniqid() . '.webp';
|
||||
$imagePath = $image->storeAs('products', $fileName, 'public');
|
||||
} else {
|
||||
$imagePath = $image->store('products', 'public');
|
||||
}
|
||||
|
||||
$validated['image'] = $imagePath;
|
||||
}
|
||||
|
||||
$product->update($validated);
|
||||
|
||||
return redirect()->route('products.index')->with('success', 'Produkt erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Product $product): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($product->tenant_id);
|
||||
|
||||
$product->delete();
|
||||
return redirect()->route('products.index')->with('success', 'Produkt erfolgreich gelöscht.');
|
||||
}
|
||||
}
|
||||
112
app/Http/Controllers/SettingsController.php
Normal file
112
app/Http/Controllers/SettingsController.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$settings = Setting::orderBy('group')->orderBy('key')->get()->groupBy('group');
|
||||
return view('admin.settings.index', compact('settings'));
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'settings' => 'required|array',
|
||||
'settings.*' => 'nullable'
|
||||
]);
|
||||
|
||||
foreach ($validated['settings'] as $key => $value) {
|
||||
$setting = Setting::where('key', $key)->first();
|
||||
if ($setting) {
|
||||
// Handle boolean checkboxes (unchecked = null, checked = "1")
|
||||
if ($setting->type === 'boolean') {
|
||||
$value = $value ? '1' : '0';
|
||||
}
|
||||
$setting->update(['value' => $value]);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('admin.settings.index')->with('success', 'Einstellungen erfolgreich gespeichert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Mandanten-spezifische Einstellungen
|
||||
*/
|
||||
public function tenantSettings(): View
|
||||
{
|
||||
\Log::info('TenantSettings GET Route erreicht');
|
||||
|
||||
// Vereinfacht: nimm einfach den ersten Mandanten
|
||||
$tenant = Tenant::first();
|
||||
|
||||
if (!$tenant) {
|
||||
\Log::error('Kein Mandant gefunden in tenantSettings!');
|
||||
abort(404, 'Kein Mandant gefunden');
|
||||
}
|
||||
|
||||
\Log::info('Tenant für Settings geladen:', [
|
||||
'id' => $tenant->id,
|
||||
'name' => $tenant->name,
|
||||
'show_prices' => $tenant->show_prices,
|
||||
'show_stock' => $tenant->show_stock
|
||||
]);
|
||||
|
||||
return view('admin.settings.tenant', compact('tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiere Mandanten-spezifische Einstellungen
|
||||
*/
|
||||
public function updateTenantSettings(Request $request): RedirectResponse
|
||||
{
|
||||
// Debug: Was kommt an?
|
||||
\Log::info('Tenant Settings Update Request:', [
|
||||
'all_data' => $request->all(),
|
||||
'has_show_prices' => $request->has('show_prices'),
|
||||
'has_show_stock' => $request->has('show_stock'),
|
||||
'session_tenant_id' => session('current_tenant_id'),
|
||||
'user_id' => auth()->id(),
|
||||
'user_tenant_id' => auth()->user()->tenant_id ?? null
|
||||
]);
|
||||
|
||||
// Vereinfachte Mandanten-Auswahl: nimm einfach den ersten Mandanten
|
||||
$tenant = Tenant::first();
|
||||
|
||||
if (!$tenant) {
|
||||
\Log::error('Kein Mandant gefunden!');
|
||||
return redirect()->back()->with('error', 'Kein Mandant gefunden');
|
||||
}
|
||||
|
||||
// Checkboxes senden nur Werte wenn aktiviert
|
||||
$validated = [
|
||||
'show_prices' => $request->has('show_prices'),
|
||||
'show_stock' => $request->has('show_stock')
|
||||
];
|
||||
|
||||
\Log::info('Updating tenant settings:', [
|
||||
'tenant_id' => $tenant->id,
|
||||
'data' => $validated
|
||||
]);
|
||||
|
||||
$tenant->update($validated);
|
||||
|
||||
// Prüfen ob Update erfolgreich
|
||||
$tenant->refresh();
|
||||
|
||||
\Log::info('Tenant update result:', [
|
||||
'new_show_prices' => $tenant->show_prices,
|
||||
'new_show_stock' => $tenant->show_stock
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.settings.tenant')
|
||||
->with('success', 'Mandanten-Einstellungen erfolgreich gespeichert.');
|
||||
}
|
||||
}
|
||||
206
app/Http/Controllers/SlotController.php
Normal file
206
app/Http/Controllers/SlotController.php
Normal file
@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Slot;
|
||||
use App\Models\VendingMachine;
|
||||
use App\Models\Product;
|
||||
use App\Models\SlotProduct;
|
||||
use App\Http\Controllers\Concerns\HasTenantSecurity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class SlotController extends Controller
|
||||
{
|
||||
use HasTenantSecurity;
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$query = Slot::with(['vendingMachine', 'products']);
|
||||
|
||||
// Filter nach Mandant über vending_machines
|
||||
if ($tenantId) {
|
||||
$query->whereHas('vendingMachine', function ($q) use ($tenantId) {
|
||||
$q->where('tenant_id', $tenantId);
|
||||
});
|
||||
}
|
||||
|
||||
// Filter nach Automat
|
||||
if ($request->filled('machine')) {
|
||||
$query->where('vending_machine_id', $request->machine);
|
||||
}
|
||||
|
||||
// Filter nach Status
|
||||
if ($request->filled('status')) {
|
||||
if ($request->status === 'occupied') {
|
||||
$query->whereHas('products');
|
||||
} elseif ($request->status === 'empty') {
|
||||
$query->whereDoesntHave('products');
|
||||
}
|
||||
}
|
||||
|
||||
$slots = $query->paginate(15);
|
||||
return view('admin.slots.index', compact('slots'));
|
||||
}
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$query = VendingMachine::where('is_active', true);
|
||||
if ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachines = $query->get();
|
||||
return view('admin.slots.create', compact('vendingMachines'));
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
|
||||
$validated = $request->validate([
|
||||
'vending_machine_id' => 'required|exists:vending_machines,id',
|
||||
'slot_number' => 'required|string|max:20',
|
||||
'position' => 'nullable|string|max:100',
|
||||
'capacity' => 'required|integer|min:1|max:50',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
// Prüfe ob der Automat zum aktuellen Mandanten gehört
|
||||
$vendingMachine = VendingMachine::findOrFail($validated['vending_machine_id']);
|
||||
$this->ensureTenantAccess($vendingMachine->tenant_id);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
Slot::create($validated);
|
||||
|
||||
return redirect()->route('slots.index')->with('success', 'Fach erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
public function show(Slot $slot): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
|
||||
$slot->load(['vendingMachine', 'products']);
|
||||
|
||||
// Filtere Produkte nach Mandant
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
$query = Product::query();
|
||||
if ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId);
|
||||
}
|
||||
$products = $query->get();
|
||||
|
||||
return view('admin.slots.show', compact('slot', 'products'));
|
||||
}
|
||||
|
||||
public function edit(Slot $slot): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
$query = VendingMachine::where('is_active', true);
|
||||
if ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachines = $query->get();
|
||||
return view('admin.slots.edit', compact('slot', 'vendingMachines'));
|
||||
}
|
||||
|
||||
public function update(Request $request, Slot $slot): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'vending_machine_id' => 'required|exists:vending_machines,id',
|
||||
'slot_number' => 'required|string|max:20',
|
||||
'position' => 'nullable|string|max:100',
|
||||
'capacity' => 'required|integer|min:1|max:50',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
// Prüfe ob der neue Automat zum aktuellen Mandanten gehört
|
||||
$vendingMachine = VendingMachine::findOrFail($validated['vending_machine_id']);
|
||||
$this->ensureTenantAccess($vendingMachine->tenant_id);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
$slot->update($validated);
|
||||
|
||||
return redirect()->route('slots.index')->with('success', 'Fach erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
public function destroy(Slot $slot): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
|
||||
$slot->delete();
|
||||
return redirect()->route('slots.index')->with('success', 'Fach erfolgreich gelöscht.');
|
||||
}
|
||||
|
||||
public function attachProduct(Request $request, Slot $slot, Product $product): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'product_id' => 'required|exists:products,id',
|
||||
'stock_quantity' => 'required|integer|min:0|max:' . $slot->capacity,
|
||||
'price' => 'nullable|numeric|min:0'
|
||||
]);
|
||||
|
||||
$actualProduct = Product::findOrFail($validated['product_id']);
|
||||
|
||||
// Prüfe ob das Produkt zum aktuellen Mandanten gehört
|
||||
$this->ensureTenantAccess($actualProduct->tenant_id);
|
||||
|
||||
$currentPrice = $validated['price'] ?? $actualProduct->price;
|
||||
|
||||
// Entferne zuerst alle bestehenden Produkte aus diesem Slot
|
||||
$slot->products()->detach();
|
||||
|
||||
// Füge das neue Produkt hinzu
|
||||
$slot->products()->attach($actualProduct->id, [
|
||||
'quantity' => $validated['stock_quantity'],
|
||||
'current_price' => $currentPrice
|
||||
]);
|
||||
|
||||
return redirect()->route('slots.show', $slot)->with('success', 'Produkt erfolgreich dem Slot zugeordnet.');
|
||||
}
|
||||
|
||||
public function detachProduct(Slot $slot, Product $product): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$this->ensureTenantAccess($slot->vendingMachine->tenant_id);
|
||||
$this->ensureTenantAccess($product->tenant_id);
|
||||
|
||||
$slot->products()->detach($product->id);
|
||||
return redirect()->route('slots.show', $slot)->with('success', 'Produkt aus dem Slot entfernt.');
|
||||
}
|
||||
|
||||
public function updateProduct(Request $request, Slot $slot, Product $product): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'quantity' => 'required|integer|min:0|max:' . $slot->capacity,
|
||||
'current_price' => 'nullable|numeric|min:0'
|
||||
]);
|
||||
|
||||
$slot->products()->updateExistingPivot($product->id, [
|
||||
'quantity' => $validated['quantity'],
|
||||
'current_price' => $validated['current_price'] ?? $product->price
|
||||
]);
|
||||
|
||||
return redirect()->route('slots.show', $slot)->with('success', 'Produktdaten aktualisiert.');
|
||||
}
|
||||
}
|
||||
261
app/Http/Controllers/TenantController.php
Normal file
261
app/Http/Controllers/TenantController.php
Normal file
@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TenantController extends Controller
|
||||
{
|
||||
/**
|
||||
* Zeige Mandanten-Auswahl für Super-Admin
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
// Normale Admins werden zu ihrem Dashboard weitergeleitet
|
||||
return redirect()->route('admin.dashboard');
|
||||
}
|
||||
|
||||
$tenants = Tenant::where('is_active', true)
|
||||
->withCount(['users', 'vendingMachines', 'products'])
|
||||
->get();
|
||||
|
||||
return view('admin.tenants.select', compact('tenants'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wechsle zu einem bestimmten Mandanten (nur für Super-Admin)
|
||||
*/
|
||||
public function switch(Request $request, Tenant $tenant)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
if (!$tenant->is_active) {
|
||||
return redirect()->back()->with('error', 'Mandant ist nicht aktiv.');
|
||||
}
|
||||
|
||||
// Setze Mandanten-Kontext in Session
|
||||
session(['current_tenant_id' => $tenant->id, 'current_tenant' => $tenant]);
|
||||
|
||||
return redirect()->route('admin.dashboard')
|
||||
->with('success', "Gewechselt zu Mandant: {$tenant->name}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verlasse Mandanten-Kontext (zurück zur Auswahl)
|
||||
*/
|
||||
public function leave()
|
||||
{
|
||||
session()->forget(['current_tenant_id', 'current_tenant']);
|
||||
|
||||
return redirect()->route('tenants.select')
|
||||
->with('success', 'Mandanten-Kontext verlassen.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige alle Mandanten (Super-Admin Management)
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$tenants = Tenant::withCount(['users', 'vendingMachines', 'products'])
|
||||
->paginate(10);
|
||||
|
||||
return view('admin.tenants.index', compact('tenants'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Formular zum Erstellen eines neuen Mandanten
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
return view('admin.tenants.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichere einen neuen Mandanten
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'domain' => 'nullable|string|max:255|unique:tenants,domain',
|
||||
'public_slug' => 'nullable|string|max:100|regex:/^[a-z0-9-]+$/|unique:tenants,public_slug',
|
||||
'logo' => 'nullable|image|max:2048',
|
||||
'is_active' => 'boolean',
|
||||
'show_prices' => 'boolean',
|
||||
'show_stock' => 'boolean',
|
||||
'street' => 'nullable|string|max:255',
|
||||
'house_number' => 'nullable|string|max:20',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'city' => 'nullable|string|max:255',
|
||||
'country' => 'nullable|string|max:255'
|
||||
], [
|
||||
'public_slug.regex' => 'Der öffentliche Slug darf nur Kleinbuchstaben, Zahlen und Bindestriche enthalten.',
|
||||
'public_slug.unique' => 'Dieser öffentliche Slug wird bereits verwendet.'
|
||||
]);
|
||||
|
||||
if ($request->hasFile('logo')) {
|
||||
$logoPath = $request->file('logo')->store('tenant-logos', 'public');
|
||||
$validated['logo'] = $logoPath;
|
||||
}
|
||||
|
||||
$tenant = Tenant::create($validated);
|
||||
|
||||
return redirect()->route('admin.tenants.index')
|
||||
->with('success', 'Mandant erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Details eines Mandanten
|
||||
*/
|
||||
public function show(Tenant $tenant)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$tenant->loadCount(['users', 'vendingMachines', 'products']);
|
||||
|
||||
return view('admin.tenants.show', compact('tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Formular zum Bearbeiten eines Mandanten
|
||||
*/
|
||||
public function edit(Tenant $tenant)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
return view('admin.tenants.edit', compact('tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiere einen Mandanten
|
||||
*/
|
||||
public function update(Request $request, Tenant $tenant)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
// Debug Logging für Checkbox-Werte
|
||||
\Log::info('TenantController Update:', [
|
||||
'tenant_id' => $tenant->id,
|
||||
'all_data' => $request->all(),
|
||||
'has_show_prices' => $request->has('show_prices'),
|
||||
'has_show_stock' => $request->has('show_stock'),
|
||||
'show_prices_value' => $request->input('show_prices'),
|
||||
'show_stock_value' => $request->input('show_stock')
|
||||
]);
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'domain' => 'nullable|string|max:255|unique:tenants,domain,' . $tenant->id,
|
||||
'public_slug' => 'nullable|string|max:100|regex:/^[a-z0-9-]+$/|unique:tenants,public_slug,' . $tenant->id,
|
||||
'logo' => 'nullable|image|max:2048',
|
||||
'is_active' => 'boolean',
|
||||
// ENTFERNT: 'show_prices' => 'boolean',
|
||||
// ENTFERNT: 'show_stock' => 'boolean',
|
||||
'street' => 'nullable|string|max:255',
|
||||
'house_number' => 'nullable|string|max:20',
|
||||
'postal_code' => 'nullable|string|max:10',
|
||||
'city' => 'nullable|string|max:255',
|
||||
'country' => 'nullable|string|max:255'
|
||||
], [
|
||||
'public_slug.regex' => 'Der öffentliche Slug darf nur Kleinbuchstaben, Zahlen und Bindestriche enthalten.',
|
||||
'public_slug.unique' => 'Dieser öffentliche Slug wird bereits verwendet.'
|
||||
]);
|
||||
|
||||
// Checkboxes manuell verarbeiten
|
||||
$validated['show_prices'] = $request->has('show_prices');
|
||||
$validated['show_stock'] = $request->has('show_stock');
|
||||
|
||||
\Log::info('Validated data for update:', $validated);
|
||||
|
||||
if ($request->hasFile('logo')) {
|
||||
// Lösche altes Logo falls vorhanden
|
||||
if ($tenant->logo && file_exists(storage_path('app/public/' . $tenant->logo))) {
|
||||
unlink(storage_path('app/public/' . $tenant->logo));
|
||||
}
|
||||
|
||||
$logoPath = $request->file('logo')->store('tenant-logos', 'public');
|
||||
$validated['logo'] = $logoPath;
|
||||
}
|
||||
|
||||
$tenant->update($validated);
|
||||
|
||||
\Log::info('Tenant nach Update:', [
|
||||
'show_prices' => $tenant->fresh()->show_prices,
|
||||
'show_stock' => $tenant->fresh()->show_stock
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.tenants.index')
|
||||
->with('success', 'Mandant erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Lösche einen Mandanten
|
||||
*/
|
||||
public function destroy(Tenant $tenant)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
// Prüfe ob Mandant Daten hat
|
||||
if ($tenant->users()->count() > 0 ||
|
||||
$tenant->vendingMachines()->count() > 0 ||
|
||||
$tenant->products()->count() > 0) {
|
||||
return redirect()->route('admin.tenants.index')
|
||||
->with('error', 'Mandant kann nicht gelöscht werden, da noch Daten vorhanden sind.');
|
||||
}
|
||||
|
||||
// Lösche Logo falls vorhanden
|
||||
if ($tenant->logo && file_exists(storage_path('app/public/' . $tenant->logo))) {
|
||||
unlink(storage_path('app/public/' . $tenant->logo));
|
||||
}
|
||||
|
||||
$tenant->delete();
|
||||
|
||||
return redirect()->route('admin.tenants.index')
|
||||
->with('success', 'Mandant erfolgreich gelöscht.');
|
||||
}
|
||||
}
|
||||
157
app/Http/Controllers/UserController.php
Normal file
157
app/Http/Controllers/UserController.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Zeige alle Benutzer
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$users = User::with('tenant')->orderBy('name')->paginate(15);
|
||||
|
||||
return view('admin.users.index', compact('users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Formular zum Erstellen eines neuen Benutzers
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$tenants = Tenant::orderBy('name')->get();
|
||||
|
||||
return view('admin.users.create', compact('tenants'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichere einen neuen Benutzer
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users,email',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'tenant_id' => 'nullable|exists:tenants,id',
|
||||
'role' => 'required|in:tenant_admin,super_admin'
|
||||
]);
|
||||
|
||||
$validated['password'] = Hash::make($validated['password']);
|
||||
|
||||
User::create($validated);
|
||||
|
||||
return redirect()->route('admin.users.index')
|
||||
->with('success', 'Benutzer erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige einen spezifischen Benutzer
|
||||
*/
|
||||
public function show(User $user): View
|
||||
{
|
||||
$authUser = Auth::user();
|
||||
|
||||
if (!$authUser->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
return view('admin.users.show', compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeige Formular zum Bearbeiten eines Benutzers
|
||||
*/
|
||||
public function edit(User $user): View
|
||||
{
|
||||
$authUser = Auth::user();
|
||||
|
||||
if (!$authUser->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$tenants = Tenant::orderBy('name')->get();
|
||||
|
||||
return view('admin.users.edit', compact('user', 'tenants'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiere einen Benutzer
|
||||
*/
|
||||
public function update(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
$authUser = Auth::user();
|
||||
|
||||
if (!$authUser->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users,email,' . $user->id,
|
||||
'password' => 'nullable|string|min:8|confirmed',
|
||||
'tenant_id' => 'nullable|exists:tenants,id',
|
||||
'role' => 'required|in:tenant_admin,super_admin'
|
||||
]);
|
||||
|
||||
if (!empty($validated['password'])) {
|
||||
$validated['password'] = Hash::make($validated['password']);
|
||||
} else {
|
||||
unset($validated['password']);
|
||||
}
|
||||
|
||||
$user->update($validated);
|
||||
|
||||
return redirect()->route('admin.users.index')
|
||||
->with('success', 'Benutzer erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Lösche einen Benutzer
|
||||
*/
|
||||
public function destroy(User $user): RedirectResponse
|
||||
{
|
||||
$authUser = Auth::user();
|
||||
|
||||
if (!$authUser->isSuperAdmin()) {
|
||||
abort(403, 'Nicht autorisiert');
|
||||
}
|
||||
|
||||
// Verhindere, dass sich der Benutzer selbst löscht
|
||||
if ($user->id === $authUser->id) {
|
||||
return redirect()->route('admin.users.index')
|
||||
->with('error', 'Sie können sich nicht selbst löschen.');
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
|
||||
return redirect()->route('admin.users.index')
|
||||
->with('success', 'Benutzer erfolgreich gelöscht.');
|
||||
}
|
||||
}
|
||||
293
app/Http/Controllers/VendingDisplayController.php
Normal file
293
app/Http/Controllers/VendingDisplayController.php
Normal file
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\VendingMachine;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class VendingDisplayController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the main vending machine interface
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
// Zeige allgemeine Info-Seite mit Verweis auf LMIV-Automat.de
|
||||
return view('vending.welcome');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a specific vending machine by machine number (cross-tenant)
|
||||
*/
|
||||
public function showMachineByNumber($machineNumber): View
|
||||
{
|
||||
// Finde erste aktive Maschine mit dieser machine_number
|
||||
$machine = VendingMachine::where('machine_number', $machineNumber)
|
||||
->where('is_active', true)
|
||||
->with(['tenant', 'slots.products'])
|
||||
->first();
|
||||
|
||||
if (!$machine) {
|
||||
abort(404, 'Automat mit dieser Nummer nicht gefunden');
|
||||
}
|
||||
|
||||
// Lade alle Automaten des gleichen Mandanten
|
||||
$vendingMachines = VendingMachine::where('tenant_id', $machine->tenant_id)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
|
||||
$selectedMachine = $machine;
|
||||
$tenant = $machine->tenant;
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a specific machine using legacy route
|
||||
*/
|
||||
public function showMachine(VendingMachine $machine): View
|
||||
{
|
||||
if (!$machine->is_active) {
|
||||
abort(404, 'Automat nicht verfügbar');
|
||||
}
|
||||
|
||||
// Optional: Überprüfe Domain-basierte Mandanten-Zugriffsberechtigung
|
||||
$currentDomain = request()->getHost();
|
||||
if ($currentDomain !== 'localhost' && $currentDomain !== '127.0.0.1' && $currentDomain !== '0.0.0.0') {
|
||||
$tenant = \App\Models\Tenant::where('domain', $currentDomain)->first();
|
||||
if ($tenant && $machine->tenant_id !== $tenant->id) {
|
||||
abort(404, 'Automat nicht für diese Domain verfügbar');
|
||||
}
|
||||
}
|
||||
|
||||
$machine->load(['slots.products']);
|
||||
|
||||
// Filtere verfügbare Automaten basierend auf Mandant
|
||||
$query = VendingMachine::where('is_active', true);
|
||||
$tenant = null;
|
||||
if ($currentDomain !== 'localhost' && $currentDomain !== '127.0.0.1' && $currentDomain !== '0.0.0.0') {
|
||||
$tenant = \App\Models\Tenant::where('domain', $currentDomain)->first();
|
||||
if ($tenant) {
|
||||
$query->where('tenant_id', $tenant->id);
|
||||
}
|
||||
}
|
||||
|
||||
$vendingMachines = $query->get();
|
||||
$selectedMachine = $machine;
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show product details with LMIV information
|
||||
*/
|
||||
public function showProduct(Product $product): View
|
||||
{
|
||||
return view('vending.product-details', compact('product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show products in a specific slot
|
||||
*/
|
||||
public function showSlot($machine, $slot): View
|
||||
{
|
||||
$vendingMachine = VendingMachine::findOrFail($machine);
|
||||
$slotRecord = $vendingMachine->slots()->where('slot_number', $slot)->firstOrFail();
|
||||
$slotRecord->load(['products']);
|
||||
|
||||
return view('vending.slot-details', [
|
||||
'machine' => $vendingMachine,
|
||||
'slot' => $slotRecord
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display vending machines for a specific tenant
|
||||
*/
|
||||
public function indexByTenant(\App\Models\Tenant $tenant): View
|
||||
{
|
||||
// Für nicht-eingeloggte Benutzer: Weiterleitung zur ersten verfügbaren Maschine
|
||||
if (!auth()->check()) {
|
||||
$firstMachine = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if ($firstMachine) {
|
||||
return redirect()->route('vending.tenant.machine', [
|
||||
'tenant' => $tenant->slug,
|
||||
'machine' => $firstMachine->machine_number
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$vendingMachines = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
$selectedMachine = null;
|
||||
|
||||
if ($vendingMachines->isNotEmpty()) {
|
||||
$selectedMachine = $vendingMachines->first();
|
||||
$selectedMachine->load(['slots.products']);
|
||||
}
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a specific vending machine for a tenant
|
||||
*/
|
||||
public function showMachineByTenant(\App\Models\Tenant $tenant, $machineNumber): View
|
||||
{
|
||||
// Finde Automat basierend auf machine_number und tenant
|
||||
$machine = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('machine_number', $machineNumber)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (!$machine) {
|
||||
abort(404, 'Automat nicht für diesen Mandanten verfügbar');
|
||||
}
|
||||
|
||||
$machine->load(['slots.products']);
|
||||
|
||||
// Für nicht-eingeloggte Benutzer: nur die eine Maschine anzeigen
|
||||
if (auth()->check()) {
|
||||
// Eingeloggte Benutzer sehen alle Automaten des Mandanten
|
||||
$vendingMachines = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
} else {
|
||||
// Öffentliche Benutzer sehen nur diese eine Maschine
|
||||
$vendingMachines = collect([$machine]);
|
||||
}
|
||||
$selectedMachine = $machine;
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show product details for a tenant
|
||||
*/
|
||||
public function showProductByTenant($publicSlug, $productId): View
|
||||
{
|
||||
// Finde Tenant basierend auf public_slug
|
||||
$tenant = \App\Models\Tenant::where('public_slug', $publicSlug)
|
||||
->where('is_active', true)
|
||||
->firstOrFail();
|
||||
|
||||
// Finde Produkt basierend auf ID und Tenant
|
||||
$product = \App\Models\Product::where('id', $productId)
|
||||
->where('tenant_id', $tenant->id)
|
||||
->firstOrFail();
|
||||
|
||||
return view('vending.product-details', compact('product', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show slot details for a tenant
|
||||
*/
|
||||
public function showSlotByTenant(\App\Models\Tenant $tenant, $machineNumber, $slotNumber): View
|
||||
{
|
||||
// Finde Automat basierend auf machine_number und tenant
|
||||
$machine = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('machine_number', $machineNumber)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (!$machine) {
|
||||
abort(404, 'Automat nicht für diesen Mandanten verfügbar');
|
||||
}
|
||||
|
||||
$slot = $machine->slots()->where('slot_number', $slotNumber)->firstOrFail();
|
||||
$slot->load(['products']);
|
||||
|
||||
return view('vending.slot-details', compact('machine', 'slot', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display overview of all tenants
|
||||
*/
|
||||
public function tenantsOverview(): View
|
||||
{
|
||||
$tenants = \App\Models\Tenant::where('is_active', true)
|
||||
->withCount(['vendingMachines' => function($query) {
|
||||
$query->where('is_active', true);
|
||||
}])
|
||||
->get();
|
||||
|
||||
return view('vending.tenants', compact('tenants'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a machine using public slug (for QR codes)
|
||||
*/
|
||||
public function showMachineByPublicSlug($publicSlug, $machineNumber): View
|
||||
{
|
||||
// Finde Mandant basierend auf public_slug oder slug
|
||||
$tenant = \App\Models\Tenant::where('public_slug', $publicSlug)
|
||||
->orWhere('slug', $publicSlug)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (!$tenant) {
|
||||
abort(404, 'Mandant mit diesem Slug nicht gefunden');
|
||||
}
|
||||
|
||||
// Finde Automat basierend auf machine_number und tenant
|
||||
$machine = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('machine_number', $machineNumber)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (!$machine) {
|
||||
abort(404, 'Automat nicht für diesen Mandanten verfügbar');
|
||||
}
|
||||
|
||||
$machine->load(['slots.products']);
|
||||
|
||||
// Für öffentliche URLs: nur die eine Maschine anzeigen, Admins sehen alle
|
||||
if (auth()->check()) {
|
||||
// Eingeloggte Benutzer sehen alle Automaten des Mandanten
|
||||
$vendingMachines = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
} else {
|
||||
// Öffentliche Benutzer sehen nur diese eine Maschine
|
||||
$vendingMachines = collect([$machine]);
|
||||
}
|
||||
|
||||
$selectedMachine = $machine;
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display vending machines for a tenant using public slug
|
||||
*/
|
||||
public function indexByPublicSlug($publicSlug): View
|
||||
{
|
||||
// Finde Mandant basierend auf public_slug oder slug
|
||||
$tenant = \App\Models\Tenant::where('public_slug', $publicSlug)
|
||||
->orWhere('slug', $publicSlug)
|
||||
->where('is_active', true)
|
||||
->first();
|
||||
|
||||
if (!$tenant) {
|
||||
abort(404, 'Mandant mit diesem Slug nicht gefunden');
|
||||
}
|
||||
|
||||
$vendingMachines = VendingMachine::where('tenant_id', $tenant->id)
|
||||
->where('is_active', true)
|
||||
->get();
|
||||
$selectedMachine = null;
|
||||
|
||||
if ($vendingMachines->isNotEmpty()) {
|
||||
$selectedMachine = $vendingMachines->first();
|
||||
$selectedMachine->load(['slots.products']);
|
||||
}
|
||||
|
||||
return view('vending.index', compact('vendingMachines', 'selectedMachine', 'tenant'));
|
||||
}
|
||||
}
|
||||
274
app/Http/Controllers/VendingMachineController.php
Normal file
274
app/Http/Controllers/VendingMachineController.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\VendingMachine;
|
||||
use App\Http\Controllers\Concerns\HasTenantSecurity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use Endroid\QrCode\Writer\PngWriter;
|
||||
use Endroid\QrCode\Writer\SvgWriter;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class VendingMachineController extends Controller
|
||||
{
|
||||
use HasTenantSecurity;
|
||||
|
||||
/**
|
||||
* Display a listing of vending machines.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachines = VendingMachine::with(['tenant', 'slots'])
|
||||
->when($tenantId, function($query, $tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
->paginate(10);
|
||||
|
||||
return view('admin.vending-machines.index', compact('vendingMachines'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new vending machine.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
return view('admin.vending-machines.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created vending machine.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'machine_number' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('vending_machines')->where(function ($query) use ($tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
],
|
||||
'location' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$vendingMachine = VendingMachine::create([
|
||||
'name' => $request->name,
|
||||
'machine_number' => $request->machine_number,
|
||||
'location' => $request->location,
|
||||
'description' => $request->description,
|
||||
'is_active' => $request->boolean('is_active', true),
|
||||
'tenant_id' => $tenantId,
|
||||
]);
|
||||
|
||||
return redirect()->route('vending-machines.show', $vendingMachine)
|
||||
->with('success', 'Automat erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified vending machine.
|
||||
*/
|
||||
public function show($id): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::with(['tenant', 'slots.products'])
|
||||
->where('id', $id)
|
||||
->when($tenantId, function($query, $tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
return view('admin.vending-machines.show', compact('vendingMachine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified vending machine.
|
||||
*/
|
||||
public function edit($id): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
return view('admin.vending-machines.edit', compact('vendingMachine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified vending machine.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'machine_number' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('vending_machines')->where(function ($query) use ($tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})->ignore($vendingMachine->id)
|
||||
],
|
||||
'location' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$vendingMachine->update([
|
||||
'name' => $request->name,
|
||||
'machine_number' => $request->machine_number,
|
||||
'location' => $request->location,
|
||||
'description' => $request->description,
|
||||
'is_active' => $request->boolean('is_active', true),
|
||||
]);
|
||||
|
||||
return redirect()->route('vending-machines.show', $vendingMachine)
|
||||
->with('success', 'Automat erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified vending machine.
|
||||
*/
|
||||
public function destroy($id): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
$vendingMachine->delete();
|
||||
return redirect()->route('vending-machines.index')->with('success', 'Automat erfolgreich gelöscht.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate QR code for vending machine
|
||||
*/
|
||||
public function generateQrCode($id)
|
||||
{
|
||||
// Automat mit Tenant-Beziehung suchen
|
||||
$vendingMachine = VendingMachine::with('tenant')->find($id);
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return response('Fehler: Automat mit ID ' . $id . ' nicht gefunden.', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Prüfe Tenant-Berechtigung für Tenant-Admins
|
||||
if (\Auth::user()->isTenantAdmin()) {
|
||||
if (!$vendingMachine->tenant_id || $vendingMachine->tenant_id !== \Auth::user()->tenant_id) {
|
||||
return response('Fehler: Keine Berechtigung für Automat ' . $id . '. VM Tenant: ' . $vendingMachine->tenant_id . ', User Tenant: ' . \Auth::user()->tenant_id, 403)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
|
||||
// Prüfe ob Mandant und public_slug vorhanden
|
||||
if (!$vendingMachine->tenant || !$vendingMachine->tenant->public_slug) {
|
||||
return response('Fehler: Kein öffentlicher Slug konfiguriert für Tenant: ' . ($vendingMachine->tenant ? $vendingMachine->tenant->name : 'null'), 400)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Prüfe ob machine_number vorhanden
|
||||
if (!$vendingMachine->machine_number) {
|
||||
return response('Fehler: Keine Maschinennummer konfiguriert für Automat: ' . $vendingMachine->name, 400)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Erstelle URL für den QR-Code (mandantenspezifisch)
|
||||
$url = route('vending.public.machine', [
|
||||
'publicSlug' => $vendingMachine->tenant->public_slug,
|
||||
'machineNumber' => $vendingMachine->machine_number
|
||||
]);
|
||||
|
||||
try {
|
||||
// Verwende SVG für bessere Kompatibilität
|
||||
$writer = new SvgWriter();
|
||||
$filename = sprintf(
|
||||
'qr-code-%s-automat-%s.svg',
|
||||
$vendingMachine->tenant->public_slug,
|
||||
$vendingMachine->machine_number
|
||||
);
|
||||
|
||||
// Erstelle QR-Code mit einfacher Konfiguration
|
||||
$qrCode = new QrCode($url);
|
||||
|
||||
$result = $writer->write($qrCode);
|
||||
|
||||
return response($result->getString())
|
||||
->header('Content-Type', $result->getMimeType())
|
||||
->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response('QR-Code Fehler: ' . $e->getMessage(), 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureCorrectTenantSession()
|
||||
{
|
||||
// Implementation details...
|
||||
}
|
||||
|
||||
private function getCurrentTenantId()
|
||||
{
|
||||
return session('current_tenant') ? session('current_tenant')->id : \Auth::user()->tenant_id;
|
||||
}
|
||||
}
|
||||
274
app/Http/Controllers/VendingMachineController_backup.php
Normal file
274
app/Http/Controllers/VendingMachineController_backup.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\VendingMachine;
|
||||
use App\Http\Controllers\Concerns\HasTenantSecurity;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use Endroid\QrCode\Writer\PngWriter;
|
||||
use Endroid\QrCode\Writer\SvgWriter;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class VendingMachineController extends Controller
|
||||
{
|
||||
use HasTenantSecurity;
|
||||
|
||||
/**
|
||||
* Display a listing of vending machines.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachines = VendingMachine::with(['tenant', 'slots'])
|
||||
->when($tenantId, function($query, $tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
->paginate(10);
|
||||
|
||||
return view('admin.vending-machines.index', compact('vendingMachines'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new vending machine.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
return view('admin.vending-machines.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created vending machine.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'machine_number' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('vending_machines')->where(function ($query) use ($tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
],
|
||||
'location' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$vendingMachine = VendingMachine::create([
|
||||
'name' => $request->name,
|
||||
'machine_number' => $request->machine_number,
|
||||
'location' => $request->location,
|
||||
'description' => $request->description,
|
||||
'is_active' => $request->boolean('is_active', true),
|
||||
'tenant_id' => $tenantId,
|
||||
]);
|
||||
|
||||
return redirect()->route('vending-machines.show', $vendingMachine)
|
||||
->with('success', 'Automat erfolgreich erstellt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified vending machine.
|
||||
*/
|
||||
public function show($id): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::with(['tenant', 'slots.products'])
|
||||
->where('id', $id)
|
||||
->when($tenantId, function($query, $tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
return view('admin.vending-machines.show', compact('vendingMachine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified vending machine.
|
||||
*/
|
||||
public function edit($id): View
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
return view('admin.vending-machines.edit', compact('vendingMachine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified vending machine.
|
||||
*/
|
||||
public function update(Request $request, $id): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'machine_number' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('vending_machines')->where(function ($query) use ($tenantId) {
|
||||
return $query->where('tenant_id', $tenantId);
|
||||
})->ignore($vendingMachine->id)
|
||||
],
|
||||
'location' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$vendingMachine->update([
|
||||
'name' => $request->name,
|
||||
'machine_number' => $request->machine_number,
|
||||
'location' => $request->location,
|
||||
'description' => $request->description,
|
||||
'is_active' => $request->boolean('is_active', true),
|
||||
]);
|
||||
|
||||
return redirect()->route('vending-machines.show', $vendingMachine)
|
||||
->with('success', 'Automat erfolgreich aktualisiert.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified vending machine.
|
||||
*/
|
||||
public function destroy($id): RedirectResponse
|
||||
{
|
||||
$this->ensureCorrectTenantSession();
|
||||
$tenantId = $this->getCurrentTenantId();
|
||||
|
||||
$vendingMachine = VendingMachine::where('id', $id);
|
||||
|
||||
if ($tenantId) {
|
||||
$vendingMachine->where('tenant_id', $tenantId);
|
||||
}
|
||||
|
||||
$vendingMachine = $vendingMachine->first();
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return redirect()->route('vending-machines.index')
|
||||
->with('error', 'Automat nicht gefunden oder Sie haben keine Berechtigung.');
|
||||
}
|
||||
|
||||
$vendingMachine->delete();
|
||||
return redirect()->route('vending-machines.index')->with('success', 'Automat erfolgreich gelöscht.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate QR code for vending machine
|
||||
*/
|
||||
public function generateQrCode($id)
|
||||
{
|
||||
// Automat mit Tenant-Beziehung suchen
|
||||
$vendingMachine = VendingMachine::with('tenant')->find($id);
|
||||
|
||||
if (!$vendingMachine) {
|
||||
return response('Fehler: Automat mit ID ' . $id . ' nicht gefunden.', 404)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Prüfe Tenant-Berechtigung für Tenant-Admins
|
||||
if (\Auth::user()->isTenantAdmin()) {
|
||||
if (!$vendingMachine->tenant_id || $vendingMachine->tenant_id !== \Auth::user()->tenant_id) {
|
||||
return response('Fehler: Keine Berechtigung für Automat ' . $id . '. VM Tenant: ' . $vendingMachine->tenant_id . ', User Tenant: ' . \Auth::user()->tenant_id, 403)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
|
||||
// Prüfe ob Mandant und public_slug vorhanden
|
||||
if (!$vendingMachine->tenant || !$vendingMachine->tenant->public_slug) {
|
||||
return response('Fehler: Kein öffentlicher Slug konfiguriert für Tenant: ' . ($vendingMachine->tenant ? $vendingMachine->tenant->name : 'null'), 400)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Prüfe ob machine_number vorhanden
|
||||
if (!$vendingMachine->machine_number) {
|
||||
return response('Fehler: Keine Maschinennummer konfiguriert für Automat: ' . $vendingMachine->name, 400)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
|
||||
// Erstelle URL für den QR-Code (mandantenspezifisch)
|
||||
$url = route('vending.public.machine', [
|
||||
'publicSlug' => $vendingMachine->tenant->public_slug,
|
||||
'machineNumber' => $vendingMachine->machine_number
|
||||
]);
|
||||
|
||||
try {
|
||||
// Verwende SVG für bessere Kompatibilität
|
||||
$writer = new SvgWriter();
|
||||
$filename = sprintf(
|
||||
'qr-code-%s-automat-%s.svg',
|
||||
$vendingMachine->tenant->public_slug,
|
||||
$vendingMachine->machine_number
|
||||
);
|
||||
|
||||
// Erstelle QR-Code mit einfacher Konfiguration
|
||||
$qrCode = new QrCode($url);
|
||||
|
||||
$result = $writer->write($qrCode);
|
||||
|
||||
return response($result->getString())
|
||||
->header('Content-Type', $result->getMimeType())
|
||||
->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response('QR-Code Fehler: ' . $e->getMessage(), 500)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureCorrectTenantSession()
|
||||
{
|
||||
// Implementation details...
|
||||
}
|
||||
|
||||
private function getCurrentTenantId()
|
||||
{
|
||||
return session('current_tenant') ? session('current_tenant')->id : \Auth::user()->tenant_id;
|
||||
}
|
||||
}
|
||||
35
app/Http/Middleware/EnsureTenantSession.php
Normal file
35
app/Http/Middleware/EnsureTenantSession.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureTenantSession
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user && $user->isTenantAdmin()) {
|
||||
// Mandanten-Admins müssen immer ihren eigenen Mandanten in der Session haben
|
||||
if (session('current_tenant_id') !== $user->tenant_id) {
|
||||
session(['current_tenant_id' => $user->tenant_id]);
|
||||
|
||||
// Lade auch den Mandanten in die Session
|
||||
if ($user->tenant) {
|
||||
session(['current_tenant' => $user->tenant]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
45
app/Http/Middleware/TenantMiddleware.php
Normal file
45
app/Http/Middleware/TenantMiddleware.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class TenantMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
// Super-Admin kann auf alles zugreifen
|
||||
if ($user->isSuperAdmin()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Prüfe ob Benutzer zu einem Mandanten gehört
|
||||
if (!$user->tenant_id) {
|
||||
abort(403, 'Benutzer ist keinem Mandanten zugeordnet.');
|
||||
}
|
||||
|
||||
// Prüfe ob Mandant aktiv ist
|
||||
if (!$user->tenant->is_active) {
|
||||
abort(403, 'Mandant ist nicht aktiv.');
|
||||
}
|
||||
|
||||
// Setze Mandanten-Kontext in Session
|
||||
session(['current_tenant_id' => $user->tenant_id]);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
46
app/Http/Middleware/TenantScope.php
Normal file
46
app/Http/Middleware/TenantScope.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class TenantScope
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (!$user) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Super-Admin: Muss einen Mandanten gewählt haben oder wird zur Auswahl geleitet
|
||||
if ($user->isSuperAdmin()) {
|
||||
$tenantId = session('current_tenant_id');
|
||||
|
||||
if (!$tenantId) {
|
||||
// Wenn kein Mandant gewählt, zur Auswahl leiten (außer bei bestimmten Routen)
|
||||
$allowedRoutes = ['tenants.select', 'tenants.switch', 'admin.tenants.index', 'admin.tenants.create', 'admin.tenants.store', 'admin.tenants.edit', 'admin.tenants.update', 'admin.tenants.destroy'];
|
||||
|
||||
if (!in_array($request->route()->getName(), $allowedRoutes)) {
|
||||
return redirect()->route('tenants.select')
|
||||
->with('error', 'Bitte wählen Sie einen Mandanten aus.');
|
||||
}
|
||||
} else {
|
||||
// Setze den aktuellen Mandanten für Queries
|
||||
app()->instance('current_tenant_id', $tenantId);
|
||||
}
|
||||
}
|
||||
// Tenant-Admin: Verwende automatisch seinen Mandanten
|
||||
elseif ($user->isTenantAdmin()) {
|
||||
app()->instance('current_tenant_id', $user->tenant_id);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
20
app/Http/Middleware/TenantScopeMiddleware.php
Normal file
20
app/Http/Middleware/TenantScopeMiddleware.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class TenantScopeMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
100
app/Http/Requests/ProductRequest.php
Normal file
100
app/Http/Requests/ProductRequest.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProductRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'price' => 'required|numeric|min:0',
|
||||
'image' => 'nullable|file|mimes:jpeg,jpg,png,gif,webp|max:2048',
|
||||
'barcode' => 'nullable|string|max:255',
|
||||
'ingredients' => 'nullable|string',
|
||||
'allergens' => 'nullable|string',
|
||||
'net_weight' => 'nullable|numeric|min:0',
|
||||
'origin_country' => 'nullable|string|max:255',
|
||||
'manufacturer' => 'nullable|string|max:255',
|
||||
'distributor' => 'nullable|string|max:255',
|
||||
'energy_kj' => 'nullable|numeric|min:0',
|
||||
'energy_kcal' => 'nullable|numeric|min:0',
|
||||
'fat' => 'nullable|numeric|min:0',
|
||||
'saturated_fat' => 'nullable|numeric|min:0',
|
||||
'carbohydrates' => 'nullable|numeric|min:0',
|
||||
'sugar' => 'nullable|numeric|min:0',
|
||||
'protein' => 'nullable|numeric|min:0',
|
||||
'salt' => 'nullable|numeric|min:0',
|
||||
'storage_instructions' => 'nullable|string',
|
||||
'usage_instructions' => 'nullable|string',
|
||||
'best_before_date' => 'nullable|date',
|
||||
'lot_number' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom validation messages.
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => 'Der Produktname ist erforderlich.',
|
||||
'name.max' => 'Der Produktname darf maximal :max Zeichen lang sein.',
|
||||
'price.required' => 'Der Preis ist erforderlich.',
|
||||
'price.numeric' => 'Der Preis muss eine Zahl sein.',
|
||||
'price.min' => 'Der Preis muss mindestens :min sein.',
|
||||
'image.file' => 'Das Bild muss eine gültige Datei sein.',
|
||||
'image.mimes' => 'Das Bild muss vom Typ JPEG, JPG, PNG, GIF oder WebP sein.',
|
||||
'image.max' => 'Das Bild darf maximal :max KB groß sein.',
|
||||
'energy_kj.numeric' => 'Der Energiegehalt (kJ) muss eine Zahl sein.',
|
||||
'energy_kcal.numeric' => 'Der Energiegehalt (kcal) muss eine Zahl sein.',
|
||||
'fat.numeric' => 'Der Fettgehalt muss eine Zahl sein.',
|
||||
'saturated_fat.numeric' => 'Der Gehalt an gesättigten Fettsäuren muss eine Zahl sein.',
|
||||
'carbohydrates.numeric' => 'Der Kohlenhydratgehalt muss eine Zahl sein.',
|
||||
'sugar.numeric' => 'Der Zuckergehalt muss eine Zahl sein.',
|
||||
'protein.numeric' => 'Der Proteingehalt muss eine Zahl sein.',
|
||||
'salt.numeric' => 'Der Salzgehalt muss eine Zahl sein.',
|
||||
'net_weight.numeric' => 'Das Nettogewicht muss eine Zahl sein.',
|
||||
'best_before_date.date' => 'Das Mindesthaltbarkeitsdatum muss ein gültiges Datum sein.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance.
|
||||
*/
|
||||
public function withValidator($validator)
|
||||
{
|
||||
$validator->after(function ($validator) {
|
||||
if ($this->hasFile('image')) {
|
||||
$file = $this->file('image');
|
||||
$mimeType = $file->getMimeType();
|
||||
|
||||
// Explizite WebP-Überprüfung
|
||||
if ($mimeType === 'image/webp' || $file->getClientOriginalExtension() === 'webp') {
|
||||
// WebP ist erlaubt
|
||||
return;
|
||||
}
|
||||
|
||||
// Standard-Bildtypen prüfen
|
||||
$allowedMimes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'];
|
||||
if (!in_array($mimeType, $allowedMimes)) {
|
||||
$validator->errors()->add('image', 'Das Bildformat wird nicht unterstützt. Erlaubt sind: JPEG, PNG, GIF, WebP.');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
59
app/Models/Product.php
Normal file
59
app/Models/Product.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'price',
|
||||
'image',
|
||||
'ingredients',
|
||||
'allergens',
|
||||
'nutritional_values',
|
||||
'energy_kj',
|
||||
'energy_kcal',
|
||||
'fat',
|
||||
'saturated_fat',
|
||||
'carbohydrates',
|
||||
'sugars',
|
||||
'protein',
|
||||
'salt',
|
||||
'net_weight',
|
||||
'best_before',
|
||||
'storage_conditions',
|
||||
'origin',
|
||||
'manufacturer',
|
||||
'usage_instructions',
|
||||
'tenant_id'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'decimal:2',
|
||||
'fat' => 'decimal:2',
|
||||
'saturated_fat' => 'decimal:2',
|
||||
'carbohydrates' => 'decimal:2',
|
||||
'sugars' => 'decimal:2',
|
||||
'protein' => 'decimal:2',
|
||||
'salt' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function slots(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Slot::class, 'slot_product')
|
||||
->withPivot('quantity', 'current_price')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zum Mandanten
|
||||
*/
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
}
|
||||
88
app/Models/Setting.php
Normal file
88
app/Models/Setting.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'value',
|
||||
'type',
|
||||
'group',
|
||||
'label',
|
||||
'description',
|
||||
'tenant_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the value with proper type casting
|
||||
*/
|
||||
public function getValueAttribute($value)
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 'boolean':
|
||||
return (bool) $value;
|
||||
case 'integer':
|
||||
return (int) $value;
|
||||
case 'json':
|
||||
return json_decode($value, true);
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value with proper type conversion
|
||||
*/
|
||||
public function setValueAttribute($value)
|
||||
{
|
||||
switch ($this->type) {
|
||||
case 'boolean':
|
||||
$this->attributes['value'] = $value ? '1' : '0';
|
||||
break;
|
||||
case 'json':
|
||||
$this->attributes['value'] = json_encode($value);
|
||||
break;
|
||||
default:
|
||||
$this->attributes['value'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zum Mandanten
|
||||
*/
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting value by key (mandanten-spezifisch)
|
||||
*/
|
||||
public static function get(string $key, $default = null, ?int $tenantId = null)
|
||||
{
|
||||
$tenantId = $tenantId ?? auth()->user()?->tenant_id;
|
||||
|
||||
$setting = static::where('key', $key)
|
||||
->where('tenant_id', $tenantId)
|
||||
->first();
|
||||
return $setting ? $setting->value : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting value by key (mandanten-spezifisch)
|
||||
*/
|
||||
public static function set(string $key, $value, ?int $tenantId = null): void
|
||||
{
|
||||
$tenantId = $tenantId ?? auth()->user()?->tenant_id;
|
||||
|
||||
$setting = static::where('key', $key)
|
||||
->where('tenant_id', $tenantId)
|
||||
->first();
|
||||
if ($setting) {
|
||||
$setting->update(['value' => $value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
app/Models/Slot.php
Normal file
44
app/Models/Slot.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Slot extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'vending_machine_id',
|
||||
'slot_number',
|
||||
'position',
|
||||
'capacity',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function vendingMachine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(VendingMachine::class);
|
||||
}
|
||||
|
||||
public function products(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'slot_product')
|
||||
->withPivot('quantity', 'current_price')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function currentProduct()
|
||||
{
|
||||
return $this->products()->wherePivot('quantity', '>', 0)->first();
|
||||
}
|
||||
|
||||
public function getTotalQuantityAttribute()
|
||||
{
|
||||
return $this->products()->sum('slot_product.quantity');
|
||||
}
|
||||
}
|
||||
32
app/Models/SlotProduct.php
Normal file
32
app/Models/SlotProduct.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class SlotProduct extends Model
|
||||
{
|
||||
protected $table = 'slot_product';
|
||||
|
||||
protected $fillable = [
|
||||
'slot_id',
|
||||
'product_id',
|
||||
'quantity',
|
||||
'current_price'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'current_price' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function slot(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Slot::class);
|
||||
}
|
||||
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
}
|
||||
110
app/Models/Tenant.php
Normal file
110
app/Models/Tenant.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'public_slug',
|
||||
'description',
|
||||
'domain',
|
||||
'logo',
|
||||
'is_active',
|
||||
'show_prices',
|
||||
'show_stock',
|
||||
'street',
|
||||
'house_number',
|
||||
'postal_code',
|
||||
'city',
|
||||
'country'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'show_prices' => 'boolean',
|
||||
'show_stock' => 'boolean'
|
||||
];
|
||||
|
||||
/**
|
||||
* Beziehung zu Benutzern
|
||||
*/
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zu Snackautomaten
|
||||
*/
|
||||
public function vendingMachines(): HasMany
|
||||
{
|
||||
return $this->hasMany(VendingMachine::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zu Produkten
|
||||
*/
|
||||
public function products(): HasMany
|
||||
{
|
||||
return $this->hasMany(Product::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zu Einstellungen
|
||||
*/
|
||||
public function settings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Setting::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot-Methode für automatische Slug-Generierung
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($tenant) {
|
||||
if (empty($tenant->slug)) {
|
||||
$tenant->slug = $tenant->generateSlug($tenant->name);
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function ($tenant) {
|
||||
if (empty($tenant->slug)) {
|
||||
$tenant->slug = $tenant->generateSlug($tenant->name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiere einen einzigartigen Slug basierend auf dem Namen
|
||||
*/
|
||||
public function generateSlug($name)
|
||||
{
|
||||
if (empty($name)) {
|
||||
$name = 'tenant-' . time();
|
||||
}
|
||||
|
||||
$slug = Str::slug($name);
|
||||
$originalSlug = $slug;
|
||||
$counter = 1;
|
||||
|
||||
// Prüfe ob Slug bereits existiert und füge Nummer hinzu wenn nötig
|
||||
while (static::where('slug', $slug)->where('id', '!=', $this->id ?? 0)->exists()) {
|
||||
$slug = $originalSlug . '-' . $counter++;
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
}
|
||||
92
app/Models/User.php
Normal file
92
app/Models/User.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'tenant_id',
|
||||
'role',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zum Mandanten
|
||||
*/
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfe ob Benutzer Super-Admin ist
|
||||
*/
|
||||
public function isSuperAdmin(): bool
|
||||
{
|
||||
return $this->role === 'super_admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfe ob Benutzer Mandanten-Admin ist
|
||||
*/
|
||||
public function isTenantAdmin(): bool
|
||||
{
|
||||
return $this->role === 'tenant_admin';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfe ob Benutzer Admin-Rechte hat (Super-Admin oder Mandanten-Admin)
|
||||
*/
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return in_array($this->role, ['super_admin', 'tenant_admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope für aktive Benutzer
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
}
|
||||
93
app/Models/VendingMachine.php
Normal file
93
app/Models/VendingMachine.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class VendingMachine extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'machine_number',
|
||||
'slug',
|
||||
'location',
|
||||
'description',
|
||||
'is_active',
|
||||
'tenant_id'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function slots(): HasMany
|
||||
{
|
||||
return $this->hasMany(Slot::class);
|
||||
}
|
||||
|
||||
public function activeSlots(): HasMany
|
||||
{
|
||||
return $this->hasMany(Slot::class)->where('is_active', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Beziehung zum Mandanten
|
||||
*/
|
||||
public function tenant()
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiere einen eindeutigen Slug für diesen Mandanten
|
||||
*/
|
||||
public function generateSlug($name = null, $tenantId = null)
|
||||
{
|
||||
$name = $name ?: $this->name;
|
||||
$tenantId = $tenantId ?: $this->tenant_id;
|
||||
|
||||
$baseSlug = \Illuminate\Support\Str::slug($name);
|
||||
$slug = $baseSlug;
|
||||
$counter = 1;
|
||||
|
||||
// Prüfe auf eindeutigen Slug innerhalb des Mandanten
|
||||
while (static::where('tenant_id', $tenantId)
|
||||
->where('slug', $slug)
|
||||
->where('id', '!=', $this->id ?? 0)
|
||||
->exists()) {
|
||||
$slug = $baseSlug . '-' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot-Method für automatische Slug-Generierung
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($machine) {
|
||||
if (empty($machine->slug)) {
|
||||
$machine->slug = $machine->generateSlug($machine->name, $machine->tenant_id);
|
||||
}
|
||||
});
|
||||
|
||||
static::updating(function ($machine) {
|
||||
if ($machine->isDirty('name') && empty($machine->slug)) {
|
||||
$machine->slug = $machine->generateSlug($machine->name, $machine->tenant_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Route Model Binding basierend auf Mandant und machine_number
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'machine_number';
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
18
artisan
Normal file
18
artisan
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
21
bootstrap/app.php
Normal file
21
bootstrap/app.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->alias([
|
||||
'tenant.scope' => \App\Http\Middleware\TenantScope::class,
|
||||
'tenant.session' => \App\Http\Middleware\EnsureTenantSession::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
5
bootstrap/providers.php
Normal file
5
bootstrap/providers.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
];
|
||||
26
check_tenant_settings.php
Normal file
26
check_tenant_settings.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__ . '/bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
echo "=== PRÜFE AKTUELLE MANDANTEN-EINSTELLUNGEN ===\n";
|
||||
|
||||
$tenants = App\Models\Tenant::all();
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
echo "Mandant ID: {$tenant->id} - {$tenant->name}\n";
|
||||
echo " show_prices: " . ($tenant->show_prices ? 'true' : 'false') . "\n";
|
||||
echo " show_stock: " . ($tenant->show_stock ? 'true' : 'false') . "\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// Prüfe auch die Datenbank-Struktur
|
||||
echo "=== DATENBANK STRUKTUR ===\n";
|
||||
$columns = DB::select("DESCRIBE tenants");
|
||||
foreach ($columns as $column) {
|
||||
if (in_array($column->Field, ['show_prices', 'show_stock'])) {
|
||||
echo "Spalte: {$column->Field} - Type: {$column->Type} - Default: {$column->Default}\n";
|
||||
}
|
||||
}
|
||||
23
check_tenants.php
Normal file
23
check_tenants.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$app->boot();
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
echo "Tenant-Daten:\n";
|
||||
echo "=============\n\n";
|
||||
|
||||
$tenants = Tenant::select('id', 'name', 'slug', 'public_slug')->get();
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
echo "ID: " . $tenant->id . "\n";
|
||||
echo "Name: " . $tenant->name . "\n";
|
||||
echo "Slug: " . $tenant->slug . "\n";
|
||||
echo "Public Slug: " . $tenant->public_slug . "\n";
|
||||
echo "---\n";
|
||||
}
|
||||
|
||||
echo "\n" . $tenants->count() . " Tenants gefunden.\n";
|
||||
30
check_users.php
Normal file
30
check_users.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__ . '/bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
echo "=== BENUTZER STATUS ===\n";
|
||||
|
||||
$users = App\Models\User::all();
|
||||
|
||||
if ($users->count() == 0) {
|
||||
echo "❌ Keine Benutzer gefunden!\n";
|
||||
echo "Erstelle einen Superadmin:\n";
|
||||
echo "php artisan make:user admin@example.com password\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "- ID: {$user->id}\n";
|
||||
echo " Email: {$user->email}\n";
|
||||
echo " Super Admin: " . ($user->isSuperAdmin() ? 'Ja' : 'Nein') . "\n";
|
||||
echo " Tenant ID: " . ($user->tenant_id ?? 'null') . "\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
echo "=== LOGIN-ANLEITUNG ===\n";
|
||||
echo "1. Gehe zu: http://localhost:8001/login\n";
|
||||
echo "2. Verwende: Email: {$users->first()->email}, Password: password\n";
|
||||
echo "3. Dann teste die Einstellungen\n";
|
||||
80
composer.json
Normal file
80
composer.json
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"endroid/qr-code": "^6.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"laravel/ui": "^4.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^11.5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
]
|
||||
},
|
||||
"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
|
||||
}
|
||||
8640
composer.lock
generated
Normal file
8640
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
126
config/app.php
Normal file
126
config/app.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
115
config/auth.php
Normal file
115
config/auth.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
108
config/cache.php
Normal file
108
config/cache.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
];
|
||||
183
config/database.php
Normal file
183
config/database.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
80
config/filesystems.php
Normal file
80
config/filesystems.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
132
config/logging.php
Normal file
132
config/logging.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
];
|
||||
112
config/queue.php
Normal file
112
config/queue.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
38
config/services.php
Normal file
38
config/services.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
217
config/session.php
Normal file
217
config/session.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,51 @@
|
||||
<?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('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->text('description')->nullable();
|
||||
$table->decimal('price', 8, 2);
|
||||
$table->string('image')->nullable();
|
||||
|
||||
// LMIV-Daten (Lebensmittelinformationsverordnung)
|
||||
$table->text('ingredients')->nullable(); // Zutaten
|
||||
$table->text('allergens')->nullable(); // Allergene
|
||||
$table->string('nutritional_values')->nullable(); // Nährwerte pro 100g
|
||||
$table->integer('energy_kj')->nullable(); // Brennwert in kJ
|
||||
$table->integer('energy_kcal')->nullable(); // Brennwert in kcal
|
||||
$table->decimal('fat', 5, 2)->nullable(); // Fett in g
|
||||
$table->decimal('saturated_fat', 5, 2)->nullable(); // gesättigte Fettsäuren in g
|
||||
$table->decimal('carbohydrates', 5, 2)->nullable(); // Kohlenhydrate in g
|
||||
$table->decimal('sugars', 5, 2)->nullable(); // Zucker in g
|
||||
$table->decimal('protein', 5, 2)->nullable(); // Eiweiß in g
|
||||
$table->decimal('salt', 5, 2)->nullable(); // Salz in g
|
||||
$table->string('net_weight')->nullable(); // Nettofüllmenge
|
||||
$table->string('best_before')->nullable(); // Mindesthaltbarkeitsdatum
|
||||
$table->string('storage_conditions')->nullable(); // Aufbewahrungshinweise
|
||||
$table->string('origin')->nullable(); // Herkunft
|
||||
$table->string('manufacturer')->nullable(); // Hersteller
|
||||
$table->text('usage_instructions')->nullable(); // Verwendungshinweise
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('vending_machines', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('location');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('vending_machines');
|
||||
}
|
||||
};
|
||||
34
database/migrations/2025_10_06_140951_create_slots_table.php
Normal file
34
database/migrations/2025_10_06_140951_create_slots_table.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('slots', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('vending_machine_id')->constrained()->onDelete('cascade');
|
||||
$table->string('slot_number'); // z.B. "10", "12", "14"
|
||||
$table->string('position')->nullable(); // Position im Automaten (z.B. "A1", "B2")
|
||||
$table->integer('capacity')->default(10); // Maximale Anzahl Produkte
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['vending_machine_id', 'slot_number']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('slots');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('slot_product', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('slot_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('product_id')->constrained()->onDelete('cascade');
|
||||
$table->integer('quantity')->default(0); // Aktuelle Anzahl im Fach
|
||||
$table->decimal('current_price', 8, 2)->nullable(); // Aktueller Preis (kann vom Produktpreis abweichen)
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('slot_product');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->string('type')->default('string'); // string, boolean, integer, json
|
||||
$table->string('group')->default('general'); // general, inventory, display, etc.
|
||||
$table->string('label');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name'); // Name des Mandanten (z.B. "Unternehmen A")
|
||||
$table->string('slug')->unique(); // URL-freundlicher Identifier
|
||||
$table->string('domain')->nullable(); // Optional: eigene Domain
|
||||
$table->text('description')->nullable();
|
||||
$table->string('logo')->nullable(); // Logo-Pfad
|
||||
$table->json('settings')->nullable(); // Mandanten-spezifische Einstellungen
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->onDelete('cascade');
|
||||
$table->enum('role', ['super_admin', 'tenant_admin', 'user'])->default('user');
|
||||
$table->boolean('is_active')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropForeign(['tenant_id']);
|
||||
$table->dropColumn(['tenant_id', 'role', 'is_active']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Füge tenant_id zu vending_machines hinzu
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->onDelete('cascade');
|
||||
});
|
||||
|
||||
// Füge tenant_id zu products hinzu
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->onDelete('cascade');
|
||||
});
|
||||
|
||||
// Füge tenant_id zu settings hinzu
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->dropForeign(['tenant_id']);
|
||||
$table->dropColumn('tenant_id');
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropForeign(['tenant_id']);
|
||||
$table->dropColumn('tenant_id');
|
||||
});
|
||||
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->dropForeign(['tenant_id']);
|
||||
$table->dropColumn('tenant_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->string('slug')->nullable()->after('name');
|
||||
$table->index(['tenant_id', 'slug']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->dropIndex(['tenant_id', 'slug']);
|
||||
$table->dropColumn('slug');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->string('machine_number')->nullable()->after('name');
|
||||
$table->unique(['tenant_id', 'machine_number']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('vending_machines', function (Blueprint $table) {
|
||||
$table->dropUnique(['tenant_id', 'machine_number']);
|
||||
$table->dropColumn('machine_number');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->string('public_slug')->nullable()->after('slug');
|
||||
$table->index('public_slug');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropIndex(['public_slug']);
|
||||
$table->dropColumn('public_slug');
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
// Display-Einstellungen
|
||||
$table->boolean('show_prices')->default(true)->after('public_slug');
|
||||
$table->boolean('show_stock')->default(true)->after('show_prices');
|
||||
|
||||
// Adressdaten
|
||||
$table->string('street')->nullable()->after('show_stock');
|
||||
$table->string('house_number')->nullable()->after('street');
|
||||
$table->string('postal_code')->nullable()->after('house_number');
|
||||
$table->string('city')->nullable()->after('postal_code');
|
||||
$table->string('country')->default('Deutschland')->after('city');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'show_prices',
|
||||
'show_stock',
|
||||
'street',
|
||||
'house_number',
|
||||
'postal_code',
|
||||
'city',
|
||||
'country'
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
37
database/seeders/AdminUserSeeder.php
Normal file
37
database/seeders/AdminUserSeeder.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AdminUserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Admin-User erstellen
|
||||
User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@snackautomat.local',
|
||||
'email_verified_at' => now(),
|
||||
'password' => Hash::make('admin123'), // Bitte ändern Sie dieses Passwort!
|
||||
]);
|
||||
|
||||
// Weiterer Admin-User falls gewünscht
|
||||
User::create([
|
||||
'name' => 'Verwalter',
|
||||
'email' => 'verwalter@snackautomat.local',
|
||||
'email_verified_at' => now(),
|
||||
'password' => Hash::make('verwalter123'), // Bitte ändern Sie dieses Passwort!
|
||||
]);
|
||||
|
||||
echo "Admin-User erstellt:\n";
|
||||
echo "Email: admin@snackautomat.local, Passwort: admin123\n";
|
||||
echo "Email: verwalter@snackautomat.local, Passwort: verwalter123\n";
|
||||
echo "WICHTIG: Bitte ändern Sie diese Passwörter nach dem ersten Login!\n";
|
||||
}
|
||||
}
|
||||
36
database/seeders/AssignExistingDataToTenantsSeeder.php
Normal file
36
database/seeders/AssignExistingDataToTenantsSeeder.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\VendingMachine;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AssignExistingDataToTenantsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Hole den ersten Mandanten (Bürogebäude A)
|
||||
$tenant = Tenant::where('slug', 'buerogebaeude-a')->first();
|
||||
|
||||
if (!$tenant) {
|
||||
$this->command->error('Mandant "Bürogebäude A" nicht gefunden. Bitte zuerst TenantSeeder ausführen.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Weise alle Automaten ohne tenant_id dem ersten Mandanten zu
|
||||
$machinesUpdated = VendingMachine::whereNull('tenant_id')->update(['tenant_id' => $tenant->id]);
|
||||
$this->command->info("$machinesUpdated Automaten wurden Mandant '{$tenant->name}' zugewiesen.");
|
||||
|
||||
// Weise alle Produkte ohne tenant_id dem ersten Mandanten zu
|
||||
$productsUpdated = Product::whereNull('tenant_id')->update(['tenant_id' => $tenant->id]);
|
||||
$this->command->info("$productsUpdated Produkte wurden Mandant '{$tenant->name}' zugewiesen.");
|
||||
|
||||
$this->command->info('Alle existierenden Daten wurden erfolgreich einem Mandanten zugewiesen.');
|
||||
}
|
||||
}
|
||||
38
database/seeders/CreateTestVendingMachinesSeeder.php
Normal file
38
database/seeders/CreateTestVendingMachinesSeeder.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\VendingMachine;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CreateTestVendingMachinesSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$tenants = Tenant::all();
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
// Erstelle 2-3 Automaten pro Mandant
|
||||
$machineCount = rand(2, 3);
|
||||
|
||||
for ($i = 1; $i <= $machineCount; $i++) {
|
||||
VendingMachine::create([
|
||||
'name' => "Automat {$i}",
|
||||
'location' => "Standort {$i} - {$tenant->name}",
|
||||
'description' => "Test-Automat {$i} für {$tenant->name}",
|
||||
'is_active' => true,
|
||||
'tenant_id' => $tenant->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->command->info("{$machineCount} Automaten für Mandant '{$tenant->name}' erstellt.");
|
||||
}
|
||||
|
||||
$this->command->info('Test-Automaten für alle Mandanten erstellt.');
|
||||
}
|
||||
}
|
||||
23
database/seeders/DatabaseSeeder.php
Normal file
23
database/seeders/DatabaseSeeder.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
137
database/seeders/DemoSeeder.php
Normal file
137
database/seeders/DemoSeeder.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\VendingMachine;
|
||||
use App\Models\Product;
|
||||
use App\Models\Slot;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class DemoSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Super Admin erstellen
|
||||
$superAdmin = User::firstOrCreate(
|
||||
['email' => 'admin@lmiv-automat.de'],
|
||||
[
|
||||
'name' => 'Super Admin',
|
||||
'email' => 'admin@lmiv-automat.de',
|
||||
'password' => Hash::make('admin123'),
|
||||
'role' => 'super_admin',
|
||||
'tenant_id' => null,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
// Demo-Mandant erstellen
|
||||
$tenant = Tenant::firstOrCreate(
|
||||
['slug' => 'demo-firma'],
|
||||
[
|
||||
'name' => 'Demo Firma GmbH',
|
||||
'slug' => 'demo-firma',
|
||||
'public_slug' => 'demo-firma',
|
||||
'is_active' => true,
|
||||
'show_prices' => true,
|
||||
'show_stock' => true,
|
||||
'street' => 'Musterstraße',
|
||||
'house_number' => '123',
|
||||
'city' => 'Musterstadt',
|
||||
'postal_code' => '12345',
|
||||
'country' => 'Deutschland',
|
||||
]
|
||||
);
|
||||
|
||||
// Mandanten-Admin erstellen
|
||||
$tenantAdmin = User::firstOrCreate(
|
||||
['email' => 'admin@demo-firma.de'],
|
||||
[
|
||||
'name' => 'Mandanten Admin',
|
||||
'email' => 'admin@demo-firma.de',
|
||||
'password' => Hash::make('demo123'),
|
||||
'role' => 'tenant_admin',
|
||||
'tenant_id' => $tenant->id,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
// Automat erstellen
|
||||
$machine = VendingMachine::firstOrCreate(
|
||||
['machine_number' => 'VM001'],
|
||||
[
|
||||
'name' => 'Demo Automat Haupteingang',
|
||||
'machine_number' => 'VM001',
|
||||
'location' => 'Haupteingang Gebäude A',
|
||||
'description' => 'Hauptautomat mit Snacks und Getränken',
|
||||
'is_active' => true,
|
||||
'tenant_id' => $tenant->id,
|
||||
]
|
||||
);
|
||||
|
||||
// Produkte erstellen
|
||||
$products = [
|
||||
[
|
||||
'name' => 'Coca Cola 0,33l',
|
||||
'description' => 'Erfrischende Cola',
|
||||
'price' => 1.50,
|
||||
'tenant_id' => $tenant->id,
|
||||
],
|
||||
[
|
||||
'name' => 'Mars Riegel',
|
||||
'description' => 'Schokoladen-Karamell-Riegel',
|
||||
'price' => 1.20,
|
||||
'tenant_id' => $tenant->id,
|
||||
],
|
||||
[
|
||||
'name' => 'Erdnüsse gesalzen',
|
||||
'description' => 'Geröstete gesalzene Erdnüsse',
|
||||
'price' => 2.00,
|
||||
'tenant_id' => $tenant->id,
|
||||
],
|
||||
];
|
||||
|
||||
$createdProducts = [];
|
||||
foreach ($products as $productData) {
|
||||
$product = Product::firstOrCreate(
|
||||
['name' => $productData['name'], 'tenant_id' => $productData['tenant_id']],
|
||||
$productData
|
||||
);
|
||||
$createdProducts[] = $product;
|
||||
}
|
||||
|
||||
// Slots erstellen
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$slot = Slot::firstOrCreate(
|
||||
['slot_number' => $i, 'vending_machine_id' => $machine->id],
|
||||
[
|
||||
'slot_number' => $i,
|
||||
'vending_machine_id' => $machine->id,
|
||||
'capacity' => 8,
|
||||
'is_active' => true,
|
||||
]
|
||||
);
|
||||
|
||||
// Produkt zu Slot zuordnen (für die ersten 3 Slots)
|
||||
if ($i <= 3 && isset($createdProducts[$i - 1])) {
|
||||
$product = $createdProducts[$i - 1];
|
||||
$slot->products()->syncWithoutDetaching([$product->id => [
|
||||
'quantity' => 5,
|
||||
'current_price' => $product->price,
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->command->info('Demo-Daten erfolgreich erstellt:');
|
||||
$this->command->info('- Super Admin: admin@lmiv-automat.de / admin123');
|
||||
$this->command->info('- Mandanten Admin: admin@demo-firma.de / demo123');
|
||||
$this->command->info('- Demo-Mandant: ' . $tenant->name);
|
||||
$this->command->info('- Demo-Automat: ' . $machine->name);
|
||||
$this->command->info('- 3 Produkte und 6 Slots erstellt');
|
||||
}
|
||||
}
|
||||
27
database/seeders/GenerateVendingMachineSlugsSeeder.php
Normal file
27
database/seeders/GenerateVendingMachineSlugsSeeder.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\VendingMachine;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GenerateVendingMachineSlugsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$machines = VendingMachine::whereNull('slug')->get();
|
||||
|
||||
foreach ($machines as $machine) {
|
||||
$machine->slug = $machine->generateSlug();
|
||||
$machine->save();
|
||||
|
||||
$this->command->info("Slug '{$machine->slug}' für Automat '{$machine->name}' generiert.");
|
||||
}
|
||||
|
||||
$this->command->info("Slugs für {$machines->count()} Automaten generiert.");
|
||||
}
|
||||
}
|
||||
170
database/seeders/ProductSeeder.php
Normal file
170
database/seeders/ProductSeeder.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\VendingMachine;
|
||||
use App\Models\Slot;
|
||||
use App\Models\SlotProduct;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Beispiel-Produkte erstellen
|
||||
$products = [
|
||||
[
|
||||
'name' => 'Coca Cola 0,33l',
|
||||
'description' => 'Erfrischungsgetränk mit Koffein',
|
||||
'price' => 1.50,
|
||||
'ingredients' => 'Wasser, Zucker, Kohlensäure, Säuerungsmittel Phosphorsäure, natürliches Aroma, Farbstoff E150d, Koffein',
|
||||
'allergens' => 'Keine bekannten Allergene',
|
||||
'energy_kj' => 180,
|
||||
'energy_kcal' => 42,
|
||||
'fat' => 0,
|
||||
'saturated_fat' => 0,
|
||||
'carbohydrates' => 10.6,
|
||||
'sugars' => 10.6,
|
||||
'protein' => 0,
|
||||
'salt' => 0.01,
|
||||
'net_weight' => '330ml',
|
||||
'manufacturer' => 'The Coca-Cola Company',
|
||||
'storage_conditions' => 'Kühl und trocken lagern'
|
||||
],
|
||||
[
|
||||
'name' => 'Fanta Orange 0,33l',
|
||||
'description' => 'Orangenlimonade mit Orangengeschmack',
|
||||
'price' => 1.50,
|
||||
'ingredients' => 'Wasser, Zucker, Orangensaft aus Orangensaftkonzentrat (4%), Kohlensäure, Säuerungsmittel Citronensäure, natürliches Orangenaroma, Antioxidationsmittel Ascorbinsäure, Stabilisator Pektin, Farbstoff Carotin',
|
||||
'allergens' => 'Keine bekannten Allergene',
|
||||
'energy_kj' => 192,
|
||||
'energy_kcal' => 45,
|
||||
'fat' => 0,
|
||||
'saturated_fat' => 0,
|
||||
'carbohydrates' => 11.0,
|
||||
'sugars' => 11.0,
|
||||
'protein' => 0,
|
||||
'salt' => 0.01,
|
||||
'net_weight' => '330ml',
|
||||
'manufacturer' => 'The Coca-Cola Company',
|
||||
'storage_conditions' => 'Kühl und trocken lagern'
|
||||
],
|
||||
[
|
||||
'name' => 'Sprite 0,33l',
|
||||
'description' => 'Erfrischungsgetränk mit Zitronen- und Limettengeschmack',
|
||||
'price' => 1.50,
|
||||
'ingredients' => 'Wasser, Zucker, Kohlensäure, Säuerungsmittel Citronensäure, natürliches Zitronen- und Limettennaroma, Süßungsmittel Steviol Glykoside',
|
||||
'allergens' => 'Keine bekannten Allergene',
|
||||
'energy_kj' => 144,
|
||||
'energy_kcal' => 34,
|
||||
'fat' => 0,
|
||||
'saturated_fat' => 0,
|
||||
'carbohydrates' => 8.5,
|
||||
'sugars' => 8.5,
|
||||
'protein' => 0,
|
||||
'salt' => 0.01,
|
||||
'net_weight' => '330ml',
|
||||
'manufacturer' => 'The Coca-Cola Company',
|
||||
'storage_conditions' => 'Kühl und trocken lagern'
|
||||
],
|
||||
[
|
||||
'name' => 'Mars Riegel 51g',
|
||||
'description' => 'Schokoriegel mit Karamell und Nougat',
|
||||
'price' => 1.20,
|
||||
'ingredients' => 'Glukosesirup, Zucker, Kakaobutter, Magermilchpulver, Kakaomasse, Laktose und Molkeneiweiß, Palmfett, Milchfett, Salz, Emulgator (Sojalecithin), Eiweiß, Vanilleextrakt',
|
||||
'allergens' => 'Enthält Milch und Soja. Kann Spuren von Erdnüssen, Nüssen und Gluten enthalten.',
|
||||
'energy_kj' => 1870,
|
||||
'energy_kcal' => 449,
|
||||
'fat' => 17.0,
|
||||
'saturated_fat' => 6.8,
|
||||
'carbohydrates' => 68.0,
|
||||
'sugars' => 59.0,
|
||||
'protein' => 4.1,
|
||||
'salt' => 0.24,
|
||||
'net_weight' => '51g',
|
||||
'manufacturer' => 'Mars Wrigley Confectionery',
|
||||
'storage_conditions' => 'Trocken lagern und vor Wärme schützen'
|
||||
],
|
||||
[
|
||||
'name' => 'Snickers 50g',
|
||||
'description' => 'Schokoriegel mit Erdnüssen, Karamell und Nougat',
|
||||
'price' => 1.20,
|
||||
'ingredients' => 'Erdnüsse (19%), Glukosesirup, Zucker, Kakaobutter, Magermilchpulver, Kakaomasse, Laktose und Molkeneiweiß, Palmfett, Milchfett, Salz, Emulgator (Sojalecithin), Eiweiß, Vanilleextrakt',
|
||||
'allergens' => 'Enthält Erdnüsse, Milch und Soja. Kann Spuren von anderen Nüssen und Gluten enthalten.',
|
||||
'energy_kj' => 2034,
|
||||
'energy_kcal' => 488,
|
||||
'fat' => 24.0,
|
||||
'saturated_fat' => 9.3,
|
||||
'carbohydrates' => 56.0,
|
||||
'sugars' => 48.0,
|
||||
'protein' => 9.0,
|
||||
'salt' => 0.32,
|
||||
'net_weight' => '50g',
|
||||
'manufacturer' => 'Mars Wrigley Confectionery',
|
||||
'storage_conditions' => 'Trocken lagern und vor Wärme schützen'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($products as $productData) {
|
||||
Product::create($productData);
|
||||
}
|
||||
|
||||
// Beispiel-Snackautomat erstellen
|
||||
$vendingMachine = VendingMachine::create([
|
||||
'name' => 'Automat Bürogebäude A',
|
||||
'location' => 'Erdgeschoss, Eingangsbereich',
|
||||
'description' => 'Hauptautomat im Bürogebäude mit Getränken und Snacks',
|
||||
'is_active' => true
|
||||
]);
|
||||
|
||||
// Fächer für den Automaten erstellen
|
||||
$slots = [
|
||||
['slot_number' => '10', 'position' => 'A1'],
|
||||
['slot_number' => '12', 'position' => 'A2'],
|
||||
['slot_number' => '14', 'position' => 'A3'],
|
||||
['slot_number' => '16', 'position' => 'B1'],
|
||||
['slot_number' => '18', 'position' => 'B2'],
|
||||
['slot_number' => '20', 'position' => 'B3'],
|
||||
];
|
||||
|
||||
foreach ($slots as $slotData) {
|
||||
Slot::create([
|
||||
'vending_machine_id' => $vendingMachine->id,
|
||||
'slot_number' => $slotData['slot_number'],
|
||||
'position' => $slotData['position'],
|
||||
'capacity' => 10,
|
||||
'is_active' => true
|
||||
]);
|
||||
}
|
||||
|
||||
// Produkte den Fächern zuordnen
|
||||
$slotAssignments = [
|
||||
['slot_number' => '10', 'product_name' => 'Coca Cola 0,33l', 'quantity' => 8],
|
||||
['slot_number' => '12', 'product_name' => 'Fanta Orange 0,33l', 'quantity' => 6],
|
||||
['slot_number' => '14', 'product_name' => 'Sprite 0,33l', 'quantity' => 7],
|
||||
['slot_number' => '16', 'product_name' => 'Mars Riegel 51g', 'quantity' => 5],
|
||||
['slot_number' => '18', 'product_name' => 'Snickers 50g', 'quantity' => 4],
|
||||
];
|
||||
|
||||
foreach ($slotAssignments as $assignment) {
|
||||
$slot = Slot::where('vending_machine_id', $vendingMachine->id)
|
||||
->where('slot_number', $assignment['slot_number'])
|
||||
->first();
|
||||
|
||||
$product = Product::where('name', $assignment['product_name'])->first();
|
||||
|
||||
if ($slot && $product) {
|
||||
SlotProduct::create([
|
||||
'slot_id' => $slot->id,
|
||||
'product_id' => $product->id,
|
||||
'quantity' => $assignment['quantity'],
|
||||
'current_price' => $product->price
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
93
database/seeders/SettingsSeeder.php
Normal file
93
database/seeders/SettingsSeeder.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SettingsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeder.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$settings = [
|
||||
// Bestandsverwaltung
|
||||
[
|
||||
'key' => 'inventory_enabled',
|
||||
'value' => '1',
|
||||
'type' => 'boolean',
|
||||
'group' => 'inventory',
|
||||
'label' => 'Bestandsverwaltung aktivieren',
|
||||
'description' => 'Aktiviert die Verwaltung von Produktmengen in den Slots. Wenn deaktiviert, werden nur Produktinformationen ohne Bestandsangaben angezeigt.'
|
||||
],
|
||||
[
|
||||
'key' => 'low_stock_threshold',
|
||||
'value' => '5',
|
||||
'type' => 'integer',
|
||||
'group' => 'inventory',
|
||||
'label' => 'Warnschwelle für niedrigen Bestand',
|
||||
'description' => 'Anzahl der Produkte, ab der ein Slot als "niedrig" markiert wird.'
|
||||
],
|
||||
[
|
||||
'key' => 'show_stock_in_public',
|
||||
'value' => '1',
|
||||
'type' => 'boolean',
|
||||
'group' => 'display',
|
||||
'label' => 'Bestand öffentlich anzeigen',
|
||||
'description' => 'Zeigt die verfügbare Anzahl von Produkten in der öffentlichen Ansicht an.'
|
||||
],
|
||||
[
|
||||
'key' => 'show_out_of_stock',
|
||||
'value' => '1',
|
||||
'type' => 'boolean',
|
||||
'group' => 'display',
|
||||
'label' => 'Ausverkaufte Produkte anzeigen',
|
||||
'description' => 'Zeigt Produkte auch dann an, wenn sie nicht mehr verfügbar sind (mit entsprechender Kennzeichnung).'
|
||||
],
|
||||
// Allgemeine Einstellungen
|
||||
[
|
||||
'key' => 'site_name',
|
||||
'value' => 'LMIV Snackautomat',
|
||||
'type' => 'string',
|
||||
'group' => 'general',
|
||||
'label' => 'Website-Name',
|
||||
'description' => 'Name der Website, der im Titel und in der Navigation angezeigt wird.'
|
||||
],
|
||||
[
|
||||
'key' => 'contact_email',
|
||||
'value' => 'admin@snackautomat.local',
|
||||
'type' => 'string',
|
||||
'group' => 'general',
|
||||
'label' => 'Kontakt E-Mail',
|
||||
'description' => 'E-Mail-Adresse für Supportanfragen und Kontaktformular.'
|
||||
],
|
||||
// LMIV-Einstellungen
|
||||
[
|
||||
'key' => 'show_allergens_warning',
|
||||
'value' => '1',
|
||||
'type' => 'boolean',
|
||||
'group' => 'lmiv',
|
||||
'label' => 'Allergen-Warnung anzeigen',
|
||||
'description' => 'Zeigt einen deutlichen Hinweis auf Allergene in der Produktansicht.'
|
||||
],
|
||||
[
|
||||
'key' => 'require_nutrition_info',
|
||||
'value' => '0',
|
||||
'type' => 'boolean',
|
||||
'group' => 'lmiv',
|
||||
'label' => 'Nährwertangaben verpflichtend',
|
||||
'description' => 'Macht die Eingabe von Nährwertangaben bei Produkten zur Pflicht.'
|
||||
]
|
||||
];
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
Setting::updateOrCreate(
|
||||
['key' => $setting['key']],
|
||||
$setting
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
database/seeders/TenantSeeder.php
Normal file
87
database/seeders/TenantSeeder.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class TenantSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Super-Admin erstellen (ohne Mandant)
|
||||
User::create([
|
||||
'name' => 'Super Administrator',
|
||||
'email' => 'superadmin@snackautomat.local',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'super_admin',
|
||||
'tenant_id' => null,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandant 1: Bürogebäude A
|
||||
$tenant1 = Tenant::create([
|
||||
'name' => 'Bürogebäude A',
|
||||
'slug' => 'buerogebaeude-a',
|
||||
'description' => 'Hauptstandort im Bürogebäude A mit 3 Snackautomaten',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandanten-Admin für Bürogebäude A
|
||||
User::create([
|
||||
'name' => 'Admin Bürogebäude A',
|
||||
'email' => 'admin@buerogebaeude-a.local',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'tenant_admin',
|
||||
'tenant_id' => $tenant1->id,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandant 2: Kantinen-Service
|
||||
$tenant2 = Tenant::create([
|
||||
'name' => 'Kantinen-Service GmbH',
|
||||
'slug' => 'kantinen-service',
|
||||
'description' => 'Kantinen-Service mit mehreren Standorten',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandanten-Admin für Kantinen-Service
|
||||
User::create([
|
||||
'name' => 'Admin Kantinen-Service',
|
||||
'email' => 'admin@kantinen-service.local',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'tenant_admin',
|
||||
'tenant_id' => $tenant2->id,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandant 3: Campus-Automaten
|
||||
$tenant3 = Tenant::create([
|
||||
'name' => 'Campus-Automaten',
|
||||
'slug' => 'campus-automaten',
|
||||
'description' => 'Snackautomaten auf dem Universitätscampus',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
// Mandanten-Admin für Campus-Automaten
|
||||
User::create([
|
||||
'name' => 'Admin Campus',
|
||||
'email' => 'admin@campus-automaten.local',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'tenant_admin',
|
||||
'tenant_id' => $tenant3->id,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->command->info('Mandanten und Benutzer erstellt:');
|
||||
$this->command->line('- Super-Admin: superadmin@snackautomat.local / password');
|
||||
$this->command->line('- Bürogebäude A: admin@buerogebaeude-a.local / password');
|
||||
$this->command->line('- Kantinen-Service: admin@kantinen-service.local / password');
|
||||
$this->command->line('- Campus-Automaten: admin@campus-automaten.local / password');
|
||||
}
|
||||
}
|
||||
60
database/seeders/UpdateTenantPublicSlugs.php
Normal file
60
database/seeders/UpdateTenantPublicSlugs.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Tenant;
|
||||
|
||||
class UpdateTenantPublicSlugs extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$tenants = Tenant::whereNull('public_slug')->get();
|
||||
|
||||
foreach ($tenants as $tenant) {
|
||||
$publicSlug = $this->generatePublicSlug($tenant);
|
||||
$tenant->public_slug = $publicSlug;
|
||||
$tenant->save();
|
||||
|
||||
echo "Updated {$tenant->name} with public_slug: {$publicSlug}\n";
|
||||
}
|
||||
}
|
||||
|
||||
private function generatePublicSlug(Tenant $tenant): string
|
||||
{
|
||||
// Generiere public_slug basierend auf dem Namen
|
||||
$name = strtolower($tenant->name);
|
||||
|
||||
// Basis-Slug aus dem Namen generieren
|
||||
$baseSlug = str_replace([' ', 'ä', 'ö', 'ü', 'ß'], ['-', 'ae', 'oe', 'ue', 'ss'], $name);
|
||||
$baseSlug = preg_replace('/[^a-z0-9-]/', '', $baseSlug);
|
||||
$baseSlug = preg_replace('/-+/', '-', $baseSlug); // Mehrfache Bindestriche entfernen
|
||||
$baseSlug = trim($baseSlug, '-');
|
||||
|
||||
// Spezielle Mappings falls gewünscht
|
||||
if (str_contains($name, 'firma 1')) {
|
||||
$baseSlug = 'firma-1';
|
||||
} elseif (str_contains($name, 'firma 2')) {
|
||||
$baseSlug = 'firma-2';
|
||||
} elseif (str_contains($name, 'firma 3')) {
|
||||
$baseSlug = 'firma-3';
|
||||
}
|
||||
|
||||
// Stelle sicher, dass public_slug eindeutig ist
|
||||
$counter = 1;
|
||||
$publicSlug = $baseSlug;
|
||||
|
||||
while (Tenant::where('public_slug', $publicSlug)
|
||||
->where('id', '!=', $tenant->id)
|
||||
->exists()) {
|
||||
$publicSlug = $baseSlug . '-' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $publicSlug;
|
||||
}
|
||||
}
|
||||
60
database/seeders/UpdateVendingMachineNumbers.php
Normal file
60
database/seeders/UpdateVendingMachineNumbers.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\VendingMachine;
|
||||
|
||||
class UpdateVendingMachineNumbers extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$machines = VendingMachine::all();
|
||||
|
||||
foreach ($machines as $machine) {
|
||||
if (empty($machine->machine_number)) {
|
||||
// Generiere machine_number basierend auf dem Namen oder einem Pattern
|
||||
$machineNumber = $this->generateMachineNumber($machine);
|
||||
$machine->machine_number = $machineNumber;
|
||||
$machine->save();
|
||||
|
||||
echo "Updated {$machine->name} with machine_number: {$machineNumber}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function generateMachineNumber(VendingMachine $machine): string
|
||||
{
|
||||
// Spezielle Mappings für bessere machine_numbers
|
||||
$name = strtolower($machine->name);
|
||||
|
||||
if (str_contains($name, 'bürogebäude') || str_contains($name, 'burogebaude')) {
|
||||
$baseNumber = 'automat-burogebaude-a';
|
||||
} elseif (str_contains($name, 'snack')) {
|
||||
$baseNumber = 'snackost';
|
||||
} else {
|
||||
// Generiere aus dem Namen
|
||||
$baseNumber = str_replace([' ', 'ä', 'ö', 'ü', 'ß'], ['-', 'ae', 'oe', 'ue', 'ss'], $name);
|
||||
$baseNumber = preg_replace('/[^a-z0-9-]/', '', $baseNumber);
|
||||
$baseNumber = trim($baseNumber, '-');
|
||||
}
|
||||
|
||||
// Stelle sicher, dass machine_number eindeutig pro Mandant ist
|
||||
$counter = 1;
|
||||
$machineNumber = $baseNumber;
|
||||
|
||||
while (VendingMachine::where('tenant_id', $machine->tenant_id)
|
||||
->where('machine_number', $machineNumber)
|
||||
->where('id', '!=', $machine->id)
|
||||
->exists()) {
|
||||
$machineNumber = $baseNumber . '-' . $counter;
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $machineNumber;
|
||||
}
|
||||
}
|
||||
32
debug_machines.php
Normal file
32
debug_machines.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
try {
|
||||
// Laravel App initialisieren
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$app->boot();
|
||||
|
||||
echo "=== VENDING MACHINES DEBUG ===\n";
|
||||
|
||||
$machines = App\Models\VendingMachine::with('tenant')->get();
|
||||
|
||||
echo "Anzahl Maschinen: " . $machines->count() . "\n\n";
|
||||
|
||||
foreach ($machines as $machine) {
|
||||
echo "ID: " . $machine->id . "\n";
|
||||
echo "Name: " . ($machine->name ?: 'NULL') . "\n";
|
||||
echo "Machine Number: " . ($machine->machine_number ?: 'NULL') . "\n";
|
||||
echo "Tenant ID: " . ($machine->tenant_id ?: 'NULL') . "\n";
|
||||
if ($machine->tenant) {
|
||||
echo "Tenant Name: " . $machine->tenant->name . "\n";
|
||||
echo "Tenant Public Slug: " . ($machine->tenant->public_slug ?: 'NULL') . "\n";
|
||||
} else {
|
||||
echo "Tenant: NULL\n";
|
||||
}
|
||||
echo "---\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "FEHLER: " . $e->getMessage() . "\n";
|
||||
}
|
||||
59
form_test.html
Normal file
59
form_test.html
Normal file
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Form Submit Test</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Form Submit Test</h1>
|
||||
|
||||
<h2>Test 1: GET Request zur Debug Session</h2>
|
||||
<button onclick="testSession()">Test Session Status</button>
|
||||
<div id="sessionResult"></div>
|
||||
|
||||
<h2>Test 2: Form Submit mit JavaScript</h2>
|
||||
<form id="testForm">
|
||||
<label>
|
||||
<input type="checkbox" name="show_prices" value="1" id="show_prices"> Preise anzeigen
|
||||
</label><br>
|
||||
<label>
|
||||
<input type="checkbox" name="show_stock" value="1" checked id="show_stock"> Bestand anzeigen
|
||||
</label><br>
|
||||
<button type="button" onclick="testFormSubmit()">JavaScript Test Submit</button>
|
||||
</form>
|
||||
<div id="formResult"></div>
|
||||
|
||||
<script>
|
||||
async function testSession() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:8001/debug/session');
|
||||
const data = await response.json();
|
||||
document.getElementById('sessionResult').innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
||||
} catch (error) {
|
||||
document.getElementById('sessionResult').innerHTML = '<p style="color: red;">Error: ' + error.message + '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
async function testFormSubmit() {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
if (document.getElementById('show_prices').checked) {
|
||||
formData.append('show_prices', '1');
|
||||
}
|
||||
if (document.getElementById('show_stock').checked) {
|
||||
formData.append('show_stock', '1');
|
||||
}
|
||||
|
||||
const response = await fetch('http://localhost:8001/debug/tenant-test', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
const data = await response.json();
|
||||
document.getElementById('formResult').innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
|
||||
} catch (error) {
|
||||
document.getElementById('formResult').innerHTML = '<p style="color: red;">Error: ' + error.message + '</p>';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
24
mysql_setup.sql
Normal file
24
mysql_setup.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- SQL-Script für MySQL-Server 192.168.178.201
|
||||
-- Als MySQL-Root-User ausführen
|
||||
|
||||
-- 1. Datenbank erstellen
|
||||
CREATE DATABASE IF NOT EXISTS lmiv_snackautomat CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- 2. User erstellen
|
||||
CREATE USER IF NOT EXISTS 'lmiv_snackautomat'@'localhost' IDENTIFIED BY 'lmiv_snackautomat';
|
||||
CREATE USER IF NOT EXISTS 'lmiv_snackautomat'@'%' IDENTIFIED BY 'lmiv_snackautomat';
|
||||
|
||||
-- 3. Berechtigung gewähren
|
||||
GRANT ALL PRIVILEGES ON lmiv_snackautomat.* TO 'lmiv_snackautomat'@'localhost';
|
||||
GRANT ALL PRIVILEGES ON lmiv_snackautomat.* TO 'lmiv_snackautomat'@'%';
|
||||
|
||||
-- 4. Berechtigung aktualisieren
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
-- 5. Überprüfung
|
||||
SHOW DATABASES;
|
||||
SELECT User, Host FROM mysql.user WHERE User = 'lmiv_snackautomat';
|
||||
|
||||
-- 6. Datenbank verwenden
|
||||
USE lmiv_snackautomat;
|
||||
SHOW TABLES;
|
||||
2980
package-lock.json
generated
Normal file
2980
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
Normal file
20
package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"axios": "^1.11.0",
|
||||
"bootstrap": "^5.2.3",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"sass": "^1.56.1",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^7.0.7"
|
||||
}
|
||||
}
|
||||
34
phpunit.xml
Normal file
34
phpunit.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
25
public/.htaccess
Normal file
25
public/.htaccess
Normal file
@ -0,0 +1,25 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Handle X-XSRF-Token Header
|
||||
RewriteCond %{HTTP:x-xsrf-token} .
|
||||
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user