Initial commit: WitShop Laravel Online-Shop

- Laravel 11, Blade, Alpine.js, Tailwind CSS
- Produkt- & Kategorieverwaltung mit Varianten
- Checkout (Vorkasse + Rechnung), Session-Warenkorb
- Admin-Backend (Dashboard, Bestellungen, Kunden, CMS)
- DSGVO-konform: Cookie-Consent, Impressum, Widerruf, AGB
- PDF-Rechnung via dompdf, SMTP-Mailversand
- Kundenverwaltung mit manueller Freischaltung

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 00:34:09 +02:00
co-authored by Claude Sonnet 4.6
commit 41078fdc08
208 changed files with 21725 additions and 0 deletions
+18
View 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,docker-compose}.{yml,yaml}]
indent_size = 4
+45
View File
@@ -0,0 +1,45 @@
APP_NAME="Mein Online-Shop"
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=https://www.example.de
APP_LOCALE=de
APP_FALLBACK_LOCALE=de
APP_FAKER_LOCALE=de_DE
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_LEVEL=error
# Produktionsdatenbank: MySQL
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=shop
DB_USERNAME=shopuser
DB_PASSWORD=SICHERES_PASSWORT
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
FILESYSTEM_DISK=public
QUEUE_CONNECTION=database
CACHE_STORE=file
# SMTP — wird auch über Admin → Einstellungen konfiguriert
MAIL_MAILER=smtp
MAIL_SCHEME=tls
MAIL_HOST=smtp.example.de
MAIL_PORT=587
MAIL_USERNAME=shop@example.de
MAIL_PASSWORD=SMTP_PASSWORT
MAIL_FROM_ADDRESS="shop@example.de"
MAIL_FROM_NAME="Mein Online-Shop"
VITE_APP_NAME="${APP_NAME}"
+11
View 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
+18
View File
@@ -0,0 +1,18 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/storage/app/public
/vendor
.env
.env.backup
.phpunit.result.cache
database/database.sqlite
*.sqlite
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
+2
View File
@@ -0,0 +1,2 @@
ignore-scripts=true
audit=true
+117
View File
@@ -0,0 +1,117 @@
# Deployment-Anleitung (VPS / Debian/Ubuntu)
## Voraussetzungen
- PHP 8.3 + Extensions: pdo_mysql, mbstring, xml, zip, gd, curl, intl
- MySQL 8+
- Nginx
- Composer 2
- Node.js 20 + npm
## Schritt 1: Projekt deployen
```bash
cd /var/www
git clone <repo-url> shop
cd shop
composer install --no-dev --optimize-autoloader
npm ci && npm run build
cp .env.example .env
php artisan key:generate
```
## Schritt 2: .env konfigurieren
Datenbankzugangsdaten, APP_URL und MAIL-Einstellungen eintragen.
```bash
nano .env
```
## Schritt 3: Datenbank & Storage
```bash
php artisan migrate --force
php artisan db:seed --force
php artisan storage:link
```
## Schritt 4: Berechtigungen
```bash
chown -R www-data:www-data /var/www/shop
chmod -R 755 /var/www/shop
chmod -R 775 /var/www/shop/storage /var/www/shop/bootstrap/cache
```
## Schritt 5: Nginx-Konfiguration
```nginx
server {
listen 80;
server_name example.de www.example.de;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.de www.example.de;
ssl_certificate /etc/letsencrypt/live/example.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.de/privkey.pem;
root /var/www/shop/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
client_max_body_size 20M;
location ~ /\.ht { deny all; }
}
```
## Schritt 6: Queue-Worker (für E-Mails)
```bash
# /etc/supervisor/conf.d/shop-worker.conf
[program:shop-worker]
command=php /var/www/shop/artisan queue:work --sleep=3 --tries=3 --max-time=3600
user=www-data
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/shop-worker.log
```
```bash
supervisorctl reread && supervisorctl update && supervisorctl start shop-worker
```
## Schritt 7: Admin-Account setzen
Nach dem ersten Login unter `/login` mit `admin@example.de` / `changeme123`:
→ Sofort das Passwort unter **Admin → Einstellungen → Mein Konto** ändern!
## Updates deployen
```bash
cd /var/www/shop
git pull
composer install --no-dev --optimize-autoloader
npm ci && npm run build
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
supervisorctl restart shop-worker
```
+58
View File
@@ -0,0 +1,58 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals.
## Agentic Development
Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow:
```bash
composer require laravel/boost --dev
php artisan boost:install
```
Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices.
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Attribute;
use App\Models\AttributeValue;
use Illuminate\Http\Request;
class AttributeController extends Controller
{
public function index()
{
$attributes = Attribute::with('values')->get();
return view('admin.attributes.index', compact('attributes'));
}
public function store(Request $request)
{
$data = $request->validate(['name' => 'required|string|max:255']);
Attribute::create($data);
return back()->with('success', 'Attribut erstellt.');
}
public function destroy(Attribute $attribute)
{
$attribute->delete();
return back()->with('success', 'Attribut gelöscht.');
}
public function storeValue(Request $request, Attribute $attribute)
{
$data = $request->validate([
'value' => 'required|string|max:255',
'sort_order' => 'integer',
]);
$attribute->values()->create($data);
return back()->with('success', 'Wert hinzugefügt.');
}
public function destroyValue(AttributeValue $value)
{
$value->delete();
return back()->with('success', 'Wert gelöscht.');
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Banner;
use Illuminate\Http\Request;
class BannerController extends Controller
{
public function index()
{
$banners = Banner::orderBy('sort_order')->get();
return view('admin.banners.index', compact('banners'));
}
public function create()
{
return view('admin.banners.form');
}
public function store(Request $request)
{
$data = $this->validated($request);
Banner::create($data);
return redirect()->route('admin.banners.index')->with('success', 'Banner erstellt.');
}
public function edit(Banner $banner)
{
return view('admin.banners.form', compact('banner'));
}
public function update(Request $request, Banner $banner)
{
$data = $this->validated($request, $banner);
$banner->update($data);
return redirect()->route('admin.banners.index')->with('success', 'Banner aktualisiert.');
}
public function destroy(Banner $banner)
{
$banner->delete();
return redirect()->route('admin.banners.index')->with('success', 'Banner gelöscht.');
}
private function validated(Request $request, ?Banner $banner = null): array
{
$data = $request->validate([
'headline' => 'nullable|string|max:255',
'subtext' => 'nullable|string|max:500',
'button_label' => 'nullable|string|max:100',
'button_link' => 'nullable|string|max:500',
'sort_order' => 'integer',
'active' => 'boolean',
]);
$data['active'] = $request->boolean('active');
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('banners', 'public');
} elseif ($banner) {
$data['image'] = $banner->image;
}
return $data;
}
}
@@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Category;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class CategoryController extends Controller
{
public function index()
{
$categories = Category::with('parent')->orderBy('sort_order')->get();
return view('admin.categories.index', compact('categories'));
}
public function create()
{
$parents = Category::whereNull('parent_id')->orderBy('name')->get();
return view('admin.categories.form', compact('parents'));
}
public function store(Request $request)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'parent_id' => 'nullable|exists:categories,id',
'description' => 'nullable|string',
'sort_order' => 'integer',
'active' => 'boolean',
]);
$data['slug'] = Str::slug($data['name']);
$data['active'] = $request->boolean('active');
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('categories', 'public');
}
Category::create($data);
return redirect()->route('admin.categories.index')->with('success', 'Kategorie erstellt.');
}
public function edit(Category $category)
{
$parents = Category::whereNull('parent_id')->where('id', '!=', $category->id)->orderBy('name')->get();
return view('admin.categories.form', compact('category', 'parents'));
}
public function update(Request $request, Category $category)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'parent_id' => 'nullable|exists:categories,id',
'description' => 'nullable|string',
'sort_order' => 'integer',
'active' => 'boolean',
]);
$data['slug'] = Str::slug($data['name']);
$data['active'] = $request->boolean('active');
if ($request->hasFile('image')) {
$data['image'] = $request->file('image')->store('categories', 'public');
}
$category->update($data);
return redirect()->route('admin.categories.index')->with('success', 'Kategorie aktualisiert.');
}
public function destroy(Category $category)
{
$category->delete();
return redirect()->route('admin.categories.index')->with('success', 'Kategorie gelöscht.');
}
}
@@ -0,0 +1,74 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
class CustomerController extends Controller
{
public function index(Request $request)
{
$query = User::where('role', 'customer')->withCount('orders');
if ($request->filled('q')) {
$query->where(function ($q) use ($request) {
$q->where('name', 'like', '%'.$request->q.'%')
->orWhere('email', 'like', '%'.$request->q.'%');
});
}
$customers = $query->latest()->paginate(25);
return view('admin.customers.index', compact('customers'));
}
public function show(User $customer)
{
abort_if($customer->isAdmin(), 404);
$customer->load('addresses');
$orders = $customer->orders()
->with('addresses')
->latest()
->paginate(15);
$stats = [
'total_orders' => $customer->orders()->count(),
'total_revenue' => $customer->orders()
->whereNotIn('status', ['cancelled'])
->sum('total'),
'open_orders' => $customer->orders()
->whereIn('status', ['new', 'payment_received', 'processing'])
->count(),
'last_order' => $customer->orders()->latest()->first(),
];
return view('admin.customers.show', compact('customer', 'orders', 'stats'));
}
public function toggleApproval(User $customer)
{
abort_if($customer->isAdmin(), 403);
$approving = ! $customer->approved;
$customer->approved = $approving;
if ($approving && ! $customer->email_verified_at) {
$customer->email_verified_at = now();
}
$customer->save();
$status = $approving ? 'freigeschaltet' : 'gesperrt';
return back()->with('success', "Kunde {$customer->name} wurde {$status}.");
}
public function destroy(User $customer)
{
abort_if($customer->isAdmin(), 403);
$customer->delete();
return redirect()->route('admin.customers.index')->with('success', 'Kunde gelöscht.');
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\Product;
use App\Models\ProductVariant;
class DashboardController extends Controller
{
public function index()
{
$todayRevenue = Order::whereDate('created_at', today())->whereIn('status', ['payment_received','processing','shipped','completed'])->sum('total');
$monthRevenue = Order::whereMonth('created_at', now()->month)->whereYear('created_at', now()->year)->whereIn('status', ['payment_received','processing','shipped','completed'])->sum('total');
$openOrders = Order::where('status', 'new')->count();
$lowStock = ProductVariant::whereColumn('stock', '<=', 'stock_warning')->where('active', true)->with('product')->get();
$recentOrders = Order::with('addresses')->latest()->take(10)->get();
return view('admin.dashboard.index', compact('todayRevenue', 'monthRevenue', 'openOrders', 'lowStock', 'recentOrders'));
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Faq;
use App\Models\FaqGroup;
use Illuminate\Http\Request;
class FaqController extends Controller
{
public function index()
{
$groups = FaqGroup::with('faqs')->orderBy('sort_order')->get();
return view('admin.faqs.index', compact('groups'));
}
public function storeGroup(Request $request)
{
$data = $request->validate(['name' => 'required|string|max:255', 'sort_order' => 'integer']);
FaqGroup::create($data);
return back()->with('success', 'Gruppe erstellt.');
}
public function store(Request $request)
{
$data = $request->validate([
'faq_group_id' => 'nullable|exists:faq_groups,id',
'question' => 'required|string|max:500',
'answer' => 'required|string',
'sort_order' => 'integer',
]);
Faq::create($data);
return back()->with('success', 'FAQ erstellt.');
}
public function update(Request $request, Faq $faq)
{
$data = $request->validate([
'question' => 'required|string|max:500',
'answer' => 'required|string',
'sort_order' => 'integer',
]);
$faq->update($data);
return back()->with('success', 'FAQ aktualisiert.');
}
public function destroy(Faq $faq)
{
$faq->delete();
return back()->with('success', 'FAQ gelöscht.');
}
}
@@ -0,0 +1,79 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Mail\PaymentReceivedMail;
use App\Models\Order;
use App\Services\InvoiceService;
use App\Services\OrderService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class OrderController extends Controller
{
public function __construct(
private OrderService $orderService,
private InvoiceService $invoiceService,
) {}
public function index(Request $request)
{
$query = Order::with('addresses')->latest();
if ($request->filled('status')) {
$query->where('status', $request->status);
}
if ($request->filled('payment')) {
$query->where('payment_method', $request->payment);
}
if ($request->filled('q')) {
$query->where('order_number', 'like', '%'.$request->q.'%');
}
$orders = $query->paginate(25);
return view('admin.orders.index', compact('orders'));
}
public function show(Order $order)
{
$order->load('items', 'addresses', 'user');
return view('admin.orders.show', compact('order'));
}
public function updateStatus(Request $request, Order $order)
{
$data = $request->validate([
'status' => 'required|in:' . implode(',', array_keys(Order::$statusLabels)),
'tracking_code' => 'nullable|string|max:255',
]);
$this->orderService->updateStatus($order, $data['status'], $data['tracking_code'] ?? null);
// Bei Zahlungseingang: Rechnung per Mail senden
if ($data['status'] === 'payment_received') {
$pdf = $this->invoiceService->generate($order);
$email = $order->guest_email ?? $order->user?->email;
if ($email) {
Mail::to($email)->send(new PaymentReceivedMail($order, $pdf->output(), $this->invoiceService->filename($order)));
}
}
return back()->with('success', 'Status aktualisiert.');
}
public function sendInvoice(Order $order)
{
$pdf = $this->invoiceService->generate($order);
$email = $order->guest_email ?? $order->user?->email;
if ($email) {
Mail::to($email)->send(new PaymentReceivedMail($order, $pdf->output(), $this->invoiceService->filename($order)));
}
return back()->with('success', 'Rechnung erneut gesendet.');
}
public function downloadInvoice(Order $order)
{
return $this->invoiceService->generate($order)->download($this->invoiceService->filename($order));
}
}
@@ -0,0 +1,69 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Page;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class PageController extends Controller
{
public function index()
{
$pages = Page::orderBy('type')->orderBy('title')->get();
return view('admin.pages.index', compact('pages'));
}
public function create()
{
return view('admin.pages.form');
}
public function store(Request $request)
{
$data = $this->validated($request);
Page::create($data);
return redirect()->route('admin.pages.index')->with('success', 'Seite erstellt.');
}
public function edit(Page $page)
{
return view('admin.pages.form', compact('page'));
}
public function update(Request $request, Page $page)
{
$data = $this->validated($request, $page);
$page->update($data);
return redirect()->route('admin.pages.index')->with('success', 'Seite aktualisiert.');
}
public function destroy(Page $page)
{
$page->delete();
return redirect()->route('admin.pages.index')->with('success', 'Seite gelöscht.');
}
private function validated(Request $request, ?Page $page = null): array
{
$data = $request->validate([
'title' => 'required|string|max:255',
'slug' => 'nullable|string|max:255',
'type' => 'required|in:static,blog,faq',
'content' => 'nullable|string',
'meta_title' => 'nullable|string|max:255',
'meta_description' => 'nullable|string|max:500',
'published' => 'boolean',
'published_at' => 'nullable|date',
'show_in_footer' => 'boolean',
'show_in_nav' => 'boolean',
'nav_sort' => 'integer|min:0',
]);
$data['slug'] = $data['slug'] ? Str::slug($data['slug']) : Str::slug($data['title']);
$data['published'] = $request->boolean('published');
$data['show_in_footer'] = $request->boolean('show_in_footer');
$data['show_in_nav'] = $request->boolean('show_in_nav');
return $data;
}
}
@@ -0,0 +1,177 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Attribute;
use App\Models\AttributeValue;
use App\Models\Category;
use App\Models\Product;
use App\Models\ProductImage;
use App\Models\ProductVariant;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class ProductController extends Controller
{
public function index(Request $request)
{
$query = Product::with('category')->latest();
if ($request->filled('q')) {
$query->where('name', 'like', '%'.$request->q.'%');
}
$products = $query->paginate(25);
return view('admin.products.index', compact('products'));
}
public function create()
{
$categories = Category::orderBy('name')->get();
$attributes = Attribute::with('values')->get();
$variantsJson = '[]';
return view('admin.products.form', compact('categories', 'attributes', 'variantsJson'));
}
public function store(Request $request)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'category_id' => 'nullable|exists:categories,id',
'description' => 'nullable|string',
'base_price' => 'required|numeric|min:0',
'tax_rate' => 'required|numeric|in:7,19',
'weight' => 'nullable|numeric|min:0',
'active' => 'boolean',
'featured' => 'boolean',
'track_stock' => 'boolean',
'sort_order' => 'integer',
]);
$data['slug'] = Str::slug($data['name']);
$data['active'] = $request->boolean('active');
$data['featured'] = $request->boolean('featured');
$data['track_stock'] = $request->boolean('track_stock');
$product = Product::create($data);
$this->syncImages($request, $product);
$this->syncVariants($request, $product);
return redirect()->route('admin.products.index')->with('success', 'Artikel erstellt.');
}
public function edit(Product $product)
{
$product->load('images', 'variants.attributeValues.attribute');
$categories = Category::orderBy('name')->get();
$attributes = Attribute::with('values')->get();
$variantsJson = json_encode($product->variants->map(fn($v) => [
'id' => $v->id,
'sku' => $v->sku,
'price_override' => $v->price_override,
'stock' => $v->stock,
'stock_warning' => $v->stock_warning,
'active' => (bool) $v->active,
'attribute_value_ids' => $v->attributeValues->pluck('id')->values()->all(),
]));
return view('admin.products.form', compact('product', 'categories', 'attributes', 'variantsJson'));
}
public function update(Request $request, Product $product)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'category_id' => 'nullable|exists:categories,id',
'description' => 'nullable|string',
'base_price' => 'required|numeric|min:0',
'tax_rate' => 'required|numeric|in:7,19',
'weight' => 'nullable|numeric|min:0',
'active' => 'boolean',
'featured' => 'boolean',
'track_stock' => 'boolean',
'sort_order' => 'integer',
]);
$data['slug'] = Str::slug($data['name']);
$data['active'] = $request->boolean('active');
$data['featured'] = $request->boolean('featured');
$data['track_stock'] = $request->boolean('track_stock');
$product->update($data);
$this->syncImages($request, $product);
$this->syncVariants($request, $product);
return redirect()->route('admin.products.index')->with('success', 'Artikel aktualisiert.');
}
public function destroy(Product $product)
{
$product->delete();
return redirect()->route('admin.products.index')->with('success', 'Artikel gelöscht.');
}
private function syncImages(Request $request, Product $product): void
{
if ($request->hasFile('images')) {
foreach ($request->file('images') as $i => $file) {
$path = $file->store('products', 'public');
ProductImage::create(['product_id' => $product->id, 'path' => $path, 'sort_order' => $i]);
}
}
// Bild löschen
if ($request->filled('delete_images')) {
ProductImage::whereIn('id', $request->delete_images)
->where('product_id', $product->id)
->delete();
}
}
private function syncVariants(Request $request, Product $product): void
{
$variants = $request->input('variants', []);
$existingIds = [];
foreach ($variants as $v) {
if (empty($v['sku'])) continue;
$variant = isset($v['id'])
? ProductVariant::find($v['id'])
: null;
$variantData = [
'product_id' => $product->id,
'sku' => $v['sku'],
'price_override' => filled($v['price_override']) ? $v['price_override'] : null,
'stock' => (int) ($v['stock'] ?? 0),
'stock_warning' => (int) ($v['stock_warning'] ?? 5),
'active' => isset($v['active']),
];
if ($variant) {
$variant->update($variantData);
} else {
$variant = ProductVariant::create($variantData);
}
// Attributwerte synchronisieren
$valueIds = array_filter((array) ($v['attribute_value_ids'] ?? []));
$variant->attributeValues()->sync($valueIds);
$existingIds[] = $variant->id;
}
// Nicht mehr vorhandene Varianten löschen
$product->variants()->whereNotIn('id', $existingIds)->delete();
// Sicherstellen dass jedes Produkt mindestens eine Standard-Variante hat
if ($product->variants()->count() === 0) {
ProductVariant::create([
'product_id' => $product->id,
'sku' => 'DEFAULT-' . $product->id,
'price_override'=> null,
'stock' => 0,
'stock_warning' => 5,
'active' => true,
]);
}
}
}
@@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Setting;
use Illuminate\Http\Request;
class SettingsController extends Controller
{
private array $keys = [
'shop_name','shop_email','shop_phone','shop_address','shop_owner','shop_vat_id',
'bank_name','bank_iban','bank_bic','invoice_payment_days',
'smtp_host','smtp_port','smtp_user','smtp_password','smtp_from_name','smtp_from_email',
'cookie_consent','google_analytics','require_customer_approval',
];
public function index()
{
$settings = [];
foreach ($this->keys as $key) {
$settings[$key] = Setting::get($key, '');
}
$settings['shop_logo'] = Setting::get('shop_logo', '');
return view('admin.settings.index', compact('settings'));
}
public function update(Request $request)
{
foreach ($this->keys as $key) {
Setting::set($key, $request->input($key, ''));
}
// Logo hochladen
if ($request->hasFile('shop_logo')) {
$path = $request->file('shop_logo')->store('branding', 'public');
Setting::set('shop_logo', $path);
}
// Logo löschen
if ($request->boolean('delete_logo')) {
Setting::set('shop_logo', '');
}
// SMTP live in .env-Werte schreiben (für aktuellen Request anwenden)
config([
'mail.mailers.smtp.host' => Setting::get('smtp_host'),
'mail.mailers.smtp.port' => Setting::get('smtp_port'),
'mail.mailers.smtp.username' => Setting::get('smtp_user'),
'mail.mailers.smtp.password' => Setting::get('smtp_password'),
'mail.from.address' => Setting::get('smtp_from_email'),
'mail.from.name' => Setting::get('smtp_from_name'),
]);
return back()->with('success', 'Einstellungen gespeichert.');
}
}
@@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\ShippingRate;
use Illuminate\Http\Request;
class ShippingController extends Controller
{
public function index()
{
$rates = ShippingRate::orderBy('zone')->get();
return view('admin.settings.shipping', compact('rates'));
}
public function store(Request $request)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'zone' => 'required|string|max:10',
'price' => 'required|numeric|min:0',
'free_from' => 'nullable|numeric|min:0',
'active' => 'boolean',
]);
$data['active'] = $request->boolean('active');
ShippingRate::create($data);
return back()->with('success', 'Versandkosten erstellt.');
}
public function update(Request $request, ShippingRate $rate)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'zone' => 'required|string|max:10',
'price' => 'required|numeric|min:0',
'free_from' => 'nullable|numeric|min:0',
'active' => 'boolean',
]);
$data['active'] = $request->boolean('active');
$rate->update($data);
return back()->with('success', 'Versandkosten aktualisiert.');
}
public function destroy(ShippingRate $rate)
{
$rate->delete();
return back()->with('success', 'Versandkosten gelöscht.');
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*/
public function create(): View
{
return view('auth.login');
}
/**
* Handle an incoming authentication request.
*/
public function store(LoginRequest $request): RedirectResponse
{
$request->authenticate();
$request->session()->regenerate();
$user = auth()->user();
if ($user->isAdmin()) {
return redirect()->intended(route('admin.dashboard'));
}
return redirect()->intended(route('account.index'));
}
/**
* Destroy an authenticated session.
*/
public function destroy(Request $request): RedirectResponse
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*/
public function show(): View
{
return view('auth.confirm-password');
}
/**
* Confirm the user's password.
*/
public function store(Request $request): RedirectResponse
{
if (! Auth::guard('web')->validate([
'email' => $request->user()->email,
'password' => $request->password,
])) {
throw ValidationException::withMessages([
'password' => __('auth.password'),
]);
}
$request->session()->put('auth.password_confirmed_at', time());
return redirect()->intended(route('dashboard', absolute: false));
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
class EmailVerificationNotificationController extends Controller
{
/**
* Send a new email verification notification.
*/
public function store(Request $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
*/
public function __invoke(Request $request): RedirectResponse|View
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(route('dashboard', absolute: false))
: view('auth.verify-email');
}
}
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
*/
public function create(Request $request): View
{
return view('auth.reset-password', ['request' => $request]);
}
/**
* Handle an incoming new password request.
*
* @throws ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'token' => ['required'],
'email' => ['required', 'email'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function (User $user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
event(new PasswordReset($user));
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
class PasswordController extends Controller
{
/**
* Update the user's password.
*/
public function update(Request $request): RedirectResponse
{
$validated = $request->validateWithBag('updatePassword', [
'current_password' => ['required', 'current_password'],
'password' => ['required', Password::defaults(), 'confirmed'],
]);
$request->user()->update([
'password' => Hash::make($validated['password']),
]);
return back()->with('status', 'password-updated');
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
*/
public function create(): View
{
return view('auth.forgot-password');
}
/**
* Handle an incoming password reset link request.
*
* @throws ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'email' => ['required', 'email'],
]);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = Password::sendResetLink(
$request->only('email')
);
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*/
public function create(): View
{
return view('auth.register');
}
/**
* Handle an incoming registration request.
*
* @throws ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
$requiresApproval = (bool) Setting::get('require_customer_approval', false);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'approved' => ! $requiresApproval,
]);
event(new Registered($user));
if ($requiresApproval) {
return redirect()->route('login')
->with('status', 'Registrierung erfolgreich. Ihr Konto wird nach Prüfung durch einen Administrator freigeschaltet.');
}
Auth::login($user);
return redirect()->route('account.index');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;
class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*/
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}
@@ -0,0 +1,60 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;
class ProfileController extends Controller
{
/**
* Display the user's profile form.
*/
public function edit(Request $request): View
{
return view('profile.edit', [
'user' => $request->user(),
]);
}
/**
* Update the user's profile information.
*/
public function update(ProfileUpdateRequest $request): RedirectResponse
{
$request->user()->fill($request->validated());
if ($request->user()->isDirty('email')) {
$request->user()->email_verified_at = null;
}
$request->user()->save();
return Redirect::route('profile.edit')->with('status', 'profile-updated');
}
/**
* Delete the user's account.
*/
public function destroy(Request $request): RedirectResponse
{
$request->validateWithBag('userDeletion', [
'password' => ['required', 'current_password'],
]);
$user = $request->user();
Auth::logout();
$user->delete();
$request->session()->invalidate();
$request->session()->regenerateToken();
return Redirect::to('/');
}
}
@@ -0,0 +1,84 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\Address;
use App\Models\Order;
use Illuminate\Http\Request;
class AccountController extends Controller
{
public function index()
{
$orders = auth()->user()->orders()->latest()->take(5)->get();
return view('shop.account.index', compact('orders'));
}
public function orders()
{
$orders = auth()->user()->orders()->latest()->paginate(10);
return view('shop.account.orders', compact('orders'));
}
public function orderDetail(Order $order)
{
abort_unless($order->user_id === auth()->id(), 403);
$order->load('items', 'addresses');
return view('shop.account.order', compact('order'));
}
public function addresses()
{
$addresses = auth()->user()->addresses()->get();
return view('shop.account.addresses', compact('addresses'));
}
public function storeAddress(Request $request)
{
$data = $request->validate([
'first_name' => 'required|string|max:100',
'last_name' => 'required|string|max:100',
'company' => 'nullable|string|max:255',
'street' => 'required|string|max:255',
'zip' => 'required|string|max:10',
'city' => 'required|string|max:100',
'country' => 'required|string|max:2',
'phone' => 'nullable|string|max:50',
]);
$data['user_id'] = auth()->id();
Address::create($data);
return back()->with('success', 'Adresse gespeichert.');
}
public function destroyAddress(Address $address)
{
abort_unless($address->user_id === auth()->id(), 403);
$address->delete();
return back()->with('success', 'Adresse gelöscht.');
}
public function settings()
{
return view('shop.account.settings');
}
public function updateSettings(Request $request)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'email' => 'required|email|unique:users,email,' . auth()->id(),
'password' => 'nullable|min:8|confirmed',
]);
$user = auth()->user();
$user->name = $data['name'];
$user->email = $data['email'];
if (!empty($data['password'])) {
$user->password = bcrypt($data['password']);
}
$user->save();
return back()->with('success', 'Einstellungen gespeichert.');
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\ShippingRate;
use App\Services\CartService;
use Illuminate\Http\Request;
class CartController extends Controller
{
public function __construct(private CartService $cart) {}
public function index()
{
$items = $this->cart->get();
$subtotal = $this->cart->subtotal();
$shippingRate = ShippingRate::forCart($subtotal);
$shippingCost = $shippingRate ? $shippingRate->getCostForTotal($subtotal) : 0;
$total = $subtotal + $shippingCost;
return view('shop.cart.index', compact('items', 'subtotal', 'shippingRate', 'shippingCost', 'total'));
}
public function add(Request $request)
{
$request->validate(['variant_id' => 'required|exists:product_variants,id', 'qty' => 'integer|min:1']);
$this->cart->add($request->variant_id, $request->integer('qty', 1));
return back()->with('success', 'Artikel zum Warenkorb hinzugefügt.');
}
public function update(Request $request)
{
foreach ($request->input('qty', []) as $key => $qty) {
$this->cart->update($key, (int) $qty);
}
return back()->with('success', 'Warenkorb aktualisiert.');
}
public function remove(string $key)
{
$this->cart->remove($key);
return back()->with('success', 'Artikel entfernt.');
}
}
@@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\ShippingRate;
use App\Services\CartService;
use App\Services\OrderService;
use Illuminate\Http\Request;
class CheckoutController extends Controller
{
public function __construct(
private CartService $cart,
private OrderService $orderService,
) {}
public function index()
{
if ($this->cart->count() === 0) {
return redirect()->route('cart.index')->with('error', 'Ihr Warenkorb ist leer.');
}
$subtotal = $this->cart->subtotal();
$shippingRate = ShippingRate::forCart($subtotal);
$shippingCost = $shippingRate ? $shippingRate->getCostForTotal($subtotal) : 0;
$total = $subtotal + $shippingCost;
$userAddresses = auth()->user()?->addresses ?? collect();
return view('shop.checkout.index', compact('subtotal', 'shippingCost', 'total', 'userAddresses'));
}
public function storeAddress(Request $request)
{
$rules = [
'billing.first_name' => 'required|string|max:100',
'billing.last_name' => 'required|string|max:100',
'billing.street' => 'required|string|max:255',
'billing.zip' => 'required|string|max:10',
'billing.city' => 'required|string|max:100',
'billing.country' => 'required|string|max:2',
'payment_method' => 'required|in:prepayment,invoice',
'agb' => 'accepted',
];
if (!auth()->check()) {
$rules['email'] = 'required|email';
}
if ($request->input('shipping_same') !== '1') {
$rules['shipping.first_name'] = 'required|string|max:100';
$rules['shipping.last_name'] = 'required|string|max:100';
$rules['shipping.street'] = 'required|string|max:255';
$rules['shipping.zip'] = 'required|string|max:10';
$rules['shipping.city'] = 'required|string|max:100';
$rules['shipping.country'] = 'required|string|max:2';
}
$data = $request->validate($rules);
if ($request->input('shipping_same') === '1') {
$data['shipping'] = $data['billing'];
}
$data['email'] = $request->input('email');
session(['checkout_data' => $data]);
return redirect()->route('checkout.confirm');
}
public function payment()
{
return redirect()->route('checkout.index');
}
public function confirm(Request $request)
{
$checkoutData = session('checkout_data');
if (!$checkoutData || $this->cart->count() === 0) {
return redirect()->route('checkout.index');
}
if ($request->isMethod('get')) {
$items = $this->cart->get();
$subtotal = $this->cart->subtotal();
$shippingRate = ShippingRate::forCart($subtotal);
$shippingCost = $shippingRate ? $shippingRate->getCostForTotal($subtotal) : 0;
$total = $subtotal + $shippingCost;
return view('shop.checkout.confirm', compact('checkoutData', 'items', 'subtotal', 'shippingCost', 'total'));
}
$order = $this->orderService->createFromSession(
$checkoutData,
$checkoutData['payment_method']
);
session()->forget('checkout_data');
return redirect()->route('checkout.thankyou', $order->order_number);
}
public function thankyou(string $order)
{
$order = \App\Models\Order::where('order_number', $order)->firstOrFail();
return view('shop.checkout.thankyou', compact('order'));
}
}
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\FaqGroup;
class FaqController extends Controller
{
public function index()
{
$groups = FaqGroup::with('faqs')->orderBy('sort_order')->get();
return view('shop.faq', compact('groups'));
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\Banner;
use App\Models\Category;
use App\Models\Page;
use App\Models\Product;
class HomeController extends Controller
{
public function index()
{
$banners = Banner::where('active', true)->orderBy('sort_order')->get();
$categories = Category::whereNull('parent_id')->where('active', true)->orderBy('sort_order')->get();
$topProducts = Product::where('active', true)->where('featured', true)->latest()->take(8)->get();
$newProducts = Product::where('active', true)->latest()->take(8)->get();
$blogPosts = Page::where('type', 'blog')->where('published', true)->latest('published_at')->take(3)->get();
return view('shop.home', compact('banners', 'categories', 'topProducts', 'newProducts', 'blogPosts'));
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\Order;
use Illuminate\Http\Request;
class OrderTrackingController extends Controller
{
public function index()
{
return view('shop.order_tracking');
}
public function show(Request $request)
{
$request->validate(['order_number' => 'required|string', 'email' => 'required|email']);
$order = Order::where('order_number', $request->order_number)
->where(function ($q) use ($request) {
$q->where('guest_email', $request->email)
->orWhereHas('user', fn($u) => $u->where('email', $request->email));
})->with('items', 'addresses')->first();
if (!$order) {
return back()->with('error', 'Bestellung nicht gefunden. Bitte prüfen Sie die Bestellnummer und E-Mail-Adresse.');
}
return view('shop.order_tracking', compact('order'));
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\Page;
class PageController extends Controller
{
public function show(string $slug)
{
$page = Page::where('slug', $slug)->where('published', true)->firstOrFail();
return view('shop.page', compact('page'));
}
public function blog()
{
$posts = Page::where('type', 'blog')->where('published', true)->latest('published_at')->paginate(10);
return view('shop.blog.index', compact('posts'));
}
public function blogPost(string $slug)
{
$post = Page::where('slug', $slug)->where('type', 'blog')->where('published', true)->firstOrFail();
return view('shop.blog.post', compact('post'));
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Product;
use Illuminate\Http\Request;
class ProductController extends Controller
{
public function index(Request $request)
{
$query = Product::with(['images', 'category'])->where('active', true);
if ($request->filled('q')) {
$query->where('name', 'like', '%'.$request->q.'%');
}
if ($request->filled('min_price')) {
$query->where('base_price', '>=', $request->min_price);
}
if ($request->filled('max_price')) {
$query->where('base_price', '<=', $request->max_price);
}
$products = $query->orderBy('sort_order')->paginate(16);
$categories = Category::whereNull('parent_id')->where('active', true)->get();
return view('shop.products.index', compact('products', 'categories'));
}
public function category(string $slug)
{
$category = Category::where('slug', $slug)->where('active', true)->firstOrFail();
$categoryIds = collect([$category->id])->merge($category->children->pluck('id'));
$products = Product::with(['images'])->where('active', true)->whereIn('category_id', $categoryIds)->orderBy('sort_order')->paginate(16);
return view('shop.products.index', compact('products', 'category'));
}
public function show(string $slug)
{
$product = Product::with(['images', 'category', 'variants.attributeValues.attribute'])
->where('slug', $slug)
->where('active', true)
->firstOrFail();
$related = Product::where('category_id', $product->category_id)
->where('id', '!=', $product->id)
->where('active', true)
->take(4)->get();
return view('shop.products.show', compact('product', 'related'));
}
}
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use App\Mail\WiderrufsformularMail;
use App\Models\Setting;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class WiderrufsController extends Controller
{
public function index()
{
return view('shop.widerruf');
}
public function submit(Request $request)
{
$data = $request->validate([
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'email' => 'required|email',
'street' => 'required|string|max:255',
'zip' => 'required|string|max:20',
'city' => 'required|string|max:255',
'customer_number' => 'nullable|string|max:100',
'order_number' => 'nullable|string|max:100',
'order_date' => 'nullable|date',
'date' => 'required|date',
'product' => 'required|string|max:500',
'reason_category' => 'nullable|string|max:100',
'reason' => 'nullable|string|max:2000',
'refund_method' => 'nullable|string|in:original,bank,credit',
'privacy_accepted' => 'accepted',
'accuracy_confirmed'=> 'accepted',
]);
$data['name'] = $data['first_name'] . ' ' . $data['last_name'];
$shopEmail = Setting::get('shop_email');
Mail::to($shopEmail)->send(new WiderrufsformularMail($data));
Mail::to($data['email'])->send(new WiderrufsformularMail($data, true));
return back()->with('success', 'Ihr Widerrufsformular wurde erfolgreich übermittelt. Sie erhalten eine Bestätigungsmail.');
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class AdminMiddleware
{
public function handle(Request $request, Closure $next): Response
{
if (!auth()->check() || !auth()->user()->isAdmin()) {
abort(403, 'Zugriff verweigert.');
}
return $next($request);
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureUserIsApproved
{
public function handle(Request $request, Closure $next): Response
{
if (auth()->check() && ! auth()->user()->isApproved()) {
auth()->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('login')
->with('error', 'Ihr Konto wurde noch nicht freigeschaltet. Bitte warten Sie auf die Bestätigung durch einen Administrator.');
}
return $next($request);
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @throws ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @throws ValidationException
*/
public function ensureIsNotRateLimited(): void
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*/
public function throttleKey(): string
{
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProfileUpdateRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
'lowercase',
'email',
'max:255',
Rule::unique(User::class)->ignore($this->user()->id),
],
];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Mail;
use App\Models\Order;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class OrderConfirmationMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Order $order) {}
public function build()
{
return $this
->subject('Bestellbestätigung ' . $this->order->order_number . ' – ' . Setting::get('shop_name'))
->view('emails.order_confirmation');
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Mail;
use App\Models\Order;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class OrderShippedMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Order $order) {}
public function build()
{
return $this
->subject('Ihre Bestellung wurde versendet – ' . $this->order->order_number)
->view('emails.order_shipped');
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Mail;
use App\Models\Order;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class PaymentReceivedMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(
public Order $order,
private string $pdfContent,
private string $pdfFilename,
) {}
public function build()
{
return $this
->subject('Ihre Rechnung – ' . $this->order->order_number . ' – ' . Setting::get('shop_name'))
->view('emails.payment_received')
->attachData($this->pdfContent, $this->pdfFilename, ['mime' => 'application/pdf']);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Mail;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class WiderrufsformularMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(
public array $data,
public bool $isConfirmation = false,
) {}
public function build()
{
$subject = $this->isConfirmation
? 'Bestätigung Ihres Widerrufs – ' . Setting::get('shop_name')
: 'Neues Widerrufsformular eingegangen';
return $this->subject($subject)->view('emails.widerruf');
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Address extends Model
{
protected $fillable = ['user_id','first_name','last_name','company','street','street2','zip','city','country','phone','is_default'];
protected $casts = ['is_default' => 'boolean'];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Attribute extends Model
{
protected $fillable = ['name'];
public function values(): HasMany
{
return $this->hasMany(AttributeValue::class)->orderBy('sort_order');
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class AttributeValue extends Model
{
protected $fillable = ['attribute_id','value','sort_order'];
public function attribute(): BelongsTo
{
return $this->belongsTo(Attribute::class);
}
public function variants(): BelongsToMany
{
return $this->belongsToMany(ProductVariant::class, 'product_variant_attribute_values');
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Banner extends Model
{
protected $fillable = ['image','headline','subtext','button_label','button_link','sort_order','active'];
protected $casts = ['active' => 'boolean'];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Category extends Model
{
protected $fillable = ['parent_id','name','slug','description','image','sort_order','active'];
protected $casts = ['active' => 'boolean'];
public function parent(): BelongsTo
{
return $this->belongsTo(Category::class, 'parent_id');
}
public function children(): HasMany
{
return $this->hasMany(Category::class, 'parent_id')->orderBy('sort_order');
}
public function products(): HasMany
{
return $this->hasMany(Product::class);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Faq extends Model
{
protected $fillable = ['faq_group_id','question','answer','sort_order'];
public function group(): BelongsTo
{
return $this->belongsTo(FaqGroup::class, 'faq_group_id');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class FaqGroup extends Model
{
protected $fillable = ['name','sort_order'];
public function faqs(): HasMany
{
return $this->hasMany(Faq::class)->orderBy('sort_order');
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Order extends Model
{
protected $fillable = [
'order_number','user_id','guest_email','status','payment_method',
'subtotal','tax_total','shipping_cost','total','tracking_code','notes','paid_at',
];
protected $casts = [
'paid_at' => 'datetime',
'subtotal' => 'decimal:2',
'tax_total' => 'decimal:2',
'shipping_cost' => 'decimal:2',
'total' => 'decimal:2',
];
public static array $statusLabels = [
'new' => 'Neu',
'payment_received' => 'Zahlung eingegangen',
'processing' => 'In Bearbeitung',
'shipped' => 'Versendet',
'completed' => 'Abgeschlossen',
'cancelled' => 'Storniert',
];
public static array $paymentLabels = [
'prepayment' => 'Vorkasse',
'invoice' => 'Rechnung',
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function items(): HasMany
{
return $this->hasMany(OrderItem::class);
}
public function addresses(): HasMany
{
return $this->hasMany(OrderAddress::class);
}
public function billingAddress()
{
return $this->addresses()->where('type', 'billing')->first();
}
public function shippingAddress()
{
return $this->addresses()->where('type', 'shipping')->first();
}
public function getStatusLabelAttribute(): string
{
return self::$statusLabels[$this->status] ?? $this->status;
}
public function getPaymentLabelAttribute(): string
{
return self::$paymentLabels[$this->payment_method] ?? $this->payment_method;
}
public static function generateOrderNumber(): string
{
return 'ORD-' . date('Ymd') . '-' . strtoupper(substr(uniqid(), -5));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class OrderAddress extends Model
{
protected $fillable = ['order_id','type','first_name','last_name','company','street','street2','zip','city','country','phone'];
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
public function getFullNameAttribute(): string
{
return trim("{$this->first_name} {$this->last_name}");
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class OrderItem extends Model
{
protected $fillable = ['order_id','product_variant_id','product_name','variant_label','quantity','unit_price','tax_rate'];
protected $casts = ['unit_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
public function variant(): BelongsTo
{
return $this->belongsTo(ProductVariant::class, 'product_variant_id');
}
public function getLineTotalAttribute(): float
{
return round($this->unit_price * $this->quantity, 2);
}
public function getTaxAmountAttribute(): float
{
$net = $this->unit_price / (1 + $this->tax_rate / 100);
return round(($this->unit_price - $net) * $this->quantity, 2);
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
protected $fillable = ['slug','title','content','type','image','meta_title','meta_description','published','published_at','show_in_footer','show_in_nav','nav_sort'];
protected $casts = ['published' => 'boolean', 'published_at' => 'datetime', 'show_in_footer' => 'boolean', 'show_in_nav' => 'boolean'];
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Product extends Model
{
protected $fillable = ['category_id','name','slug','description','base_price','tax_rate','weight','active','featured','track_stock','sort_order'];
protected $casts = ['active' => 'boolean', 'featured' => 'boolean', 'track_stock' => 'boolean', 'base_price' => 'decimal:2', 'tax_rate' => 'decimal:2'];
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function images(): HasMany
{
return $this->hasMany(ProductImage::class)->orderBy('sort_order');
}
public function variants(): HasMany
{
return $this->hasMany(ProductVariant::class);
}
/** Effektiver Bruttopreis (Basispreis, wenn keine Variante gewählt) */
public function getDisplayPriceAttribute(): float
{
return (float) $this->base_price;
}
public function getNetPriceAttribute(): float
{
return round($this->base_price / (1 + $this->tax_rate / 100), 2);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductImage extends Model
{
protected $fillable = ['product_id','path','sort_order'];
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class ProductVariant extends Model
{
protected $fillable = ['product_id','sku','price_override','stock','stock_warning','active'];
protected $casts = ['active' => 'boolean', 'price_override' => 'decimal:2'];
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function attributeValues(): BelongsToMany
{
return $this->belongsToMany(AttributeValue::class, 'product_variant_attribute_values')
->with('attribute');
}
public function getEffectivePriceAttribute(): float
{
return (float) ($this->price_override ?? $this->product->base_price);
}
public function getLabelAttribute(): string
{
return $this->attributeValues->map(fn($v) => $v->value)->join(', ');
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class Setting extends Model
{
protected $fillable = ['key','value'];
public static function get(string $key, mixed $default = null): mixed
{
return Cache::remember("setting_{$key}", 3600, function () use ($key, $default) {
return self::where('key', $key)->value('value') ?? $default;
});
}
public static function set(string $key, mixed $value): void
{
self::updateOrCreate(['key' => $key], ['value' => $value]);
Cache::forget("setting_{$key}");
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ShippingRate extends Model
{
protected $fillable = ['name','zone','price','free_from','active'];
protected $casts = ['active' => 'boolean', 'price' => 'decimal:2', 'free_from' => 'decimal:2'];
public static function forCart(float $total, string $zone = 'DE'): ?self
{
return self::where('zone', $zone)->where('active', true)->first();
}
public function getCostForTotal(float $total): float
{
if ($this->free_from !== null && $total >= (float) $this->free_from) {
return 0.0;
}
return (float) $this->price;
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable;
protected $fillable = ['name', 'email', 'password', 'role', 'approved'];
protected $hidden = ['password', 'remember_token'];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'approved' => 'boolean',
];
}
public function isApproved(): bool
{
return $this->isAdmin() || (bool) $this->approved;
}
public function isAdmin(): bool
{
return in_array($this->role, ['admin', 'super_admin']);
}
public function isSuperAdmin(): bool
{
return $this->role === 'super_admin';
}
public function addresses(): HasMany
{
return $this->hasMany(Address::class);
}
public function orders(): HasMany
{
return $this->hasMany(Order::class);
}
}
+24
View 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
{
//
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Services;
use App\Models\ProductVariant;
use Illuminate\Support\Facades\Session;
class CartService
{
private const SESSION_KEY = 'cart';
public function get(): array
{
return Session::get(self::SESSION_KEY, []);
}
public function add(int $variantId, int $qty = 1): void
{
$cart = $this->get();
$key = "v{$variantId}";
if (isset($cart[$key])) {
$cart[$key]['qty'] += $qty;
} else {
$variant = ProductVariant::with('product')->findOrFail($variantId);
$cart[$key] = [
'variant_id' => $variantId,
'product_name' => $variant->product->name,
'variant_label'=> $variant->label,
'price' => $variant->effective_price,
'tax_rate' => $variant->product->tax_rate,
'qty' => $qty,
];
}
Session::put(self::SESSION_KEY, $cart);
}
public function update(string $key, int $qty): void
{
$cart = $this->get();
if (isset($cart[$key])) {
if ($qty <= 0) {
unset($cart[$key]);
} else {
$cart[$key]['qty'] = $qty;
}
}
Session::put(self::SESSION_KEY, $cart);
}
public function remove(string $key): void
{
$cart = $this->get();
unset($cart[$key]);
Session::put(self::SESSION_KEY, $cart);
}
public function clear(): void
{
Session::forget(self::SESSION_KEY);
}
public function subtotal(): float
{
return array_sum(array_map(fn($i) => $i['price'] * $i['qty'], $this->get()));
}
public function count(): int
{
return array_sum(array_column($this->get(), 'qty'));
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Services;
use App\Models\Order;
use Barryvdh\DomPDF\Facade\Pdf;
class InvoiceService
{
public function generate(Order $order): \Barryvdh\DomPDF\PDF
{
$order->load('items', 'addresses');
return Pdf::loadView('pdf.invoice', compact('order'))
->setPaper('a4', 'portrait');
}
public function filename(Order $order): string
{
return 'Rechnung-' . $order->order_number . '.pdf';
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace App\Services;
use App\Mail\OrderConfirmationMail;
use App\Mail\OrderShippedMail;
use App\Models\Order;
use App\Models\OrderAddress;
use App\Models\OrderItem;
use App\Models\ProductVariant;
use App\Models\ShippingRate;
use Illuminate\Support\Facades\Mail;
class OrderService
{
public function __construct(private CartService $cart) {}
public function createFromSession(array $addressData, string $paymentMethod): Order
{
$items = $this->cart->get();
$subtotal = $this->cart->subtotal();
$shippingRate = ShippingRate::forCart($subtotal);
$shippingCost = $shippingRate ? $shippingRate->getCostForTotal($subtotal) : 0;
$taxTotal = array_sum(array_map(function ($item) {
$net = $item['price'] / (1 + $item['tax_rate'] / 100);
return round(($item['price'] - $net) * $item['qty'], 2);
}, $items));
$order = Order::create([
'order_number' => Order::generateOrderNumber(),
'user_id' => auth()->id(),
'guest_email' => auth()->check() ? null : ($addressData['email'] ?? null),
'status' => 'new',
'payment_method' => $paymentMethod,
'subtotal' => $subtotal,
'tax_total' => $taxTotal,
'shipping_cost' => $shippingCost,
'total' => $subtotal + $shippingCost,
]);
foreach ($items as $item) {
OrderItem::create([
'order_id' => $order->id,
'product_variant_id'=> $item['variant_id'],
'product_name' => $item['product_name'],
'variant_label' => $item['variant_label'],
'quantity' => $item['qty'],
'unit_price' => $item['price'],
'tax_rate' => $item['tax_rate'],
]);
// Bestand reduzieren — nur wenn track_stock aktiv
$variant = ProductVariant::with('product')->find($item['variant_id']);
if ($variant && $variant->product->track_stock) {
$variant->decrement('stock', $item['qty']);
}
}
foreach (['billing', 'shipping'] as $type) {
$src = $addressData[$type] ?? $addressData['billing'];
OrderAddress::create(array_merge($src, ['order_id' => $order->id, 'type' => $type]));
}
$this->cart->clear();
Mail::to($order->guest_email ?? $order->user?->email)->send(new OrderConfirmationMail($order));
return $order;
}
public function updateStatus(Order $order, string $newStatus, ?string $trackingCode = null): void
{
$order->status = $newStatus;
if ($newStatus === 'payment_received' && !$order->paid_at) {
$order->paid_at = now();
}
if ($trackingCode) {
$order->tracking_code = $trackingCode;
}
$order->save();
if ($newStatus === 'shipped') {
$email = $order->guest_email ?? $order->user?->email;
if ($email) {
Mail::to($email)->send(new OrderShippedMail($order));
}
}
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class AppLayout extends Component
{
/**
* Get the view / contents that represents the component.
*/
public function render(): View
{
return view('layouts.app');
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use Illuminate\View\View;
class GuestLayout extends Component
{
/**
* Get the view / contents that represents the component.
*/
public function render(): View
{
return view('layouts.guest');
}
}
Executable
+18
View 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);
+25
View File
@@ -0,0 +1,25 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Request;
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([
'admin' => \App\Http\Middleware\AdminMiddleware::class,
'approved' => \App\Http\Middleware\EnsureUserIsApproved::class,
]);
$middleware->appendToGroup('web', \App\Http\Middleware\EnsureUserIsApproved::class);
})
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen(
fn (Request $request) => $request->is('api/*'),
);
})->create();
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+7
View File
@@ -0,0 +1,7 @@
<?php
use App\Providers\AppServiceProvider;
return [
AppServiceProvider::class,
];
+88
View File
@@ -0,0 +1,88 @@
{
"$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.3",
"barryvdh/laravel-dompdf": "^3.1",
"laravel/breeze": "^2.4",
"laravel/framework": "^13.8",
"laravel/tinker": "^3.0"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.5",
"laravel/pao": "^1.0.6",
"laravel/pint": "^1.27",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^12.5.12"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install --ignore-scripts",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi @no_additional_args",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
Generated
+8878
View File
File diff suppressed because it is too large Load Diff
+126
View 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'),
],
];
+117
View File
@@ -0,0 +1,117 @@
<?php
use App\Models\User;
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the number of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];
+136
View File
@@ -0,0 +1,136 @@
<?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", "storage", "octane",
| "session", "failover", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
'table' => env('DB_CACHE_TABLE', 'cache'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'storage' => [
'driver' => 'storage',
'disk' => env('CACHE_STORAGE_DISK'),
'path' => env('CACHE_STORAGE_PATH', 'framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
/*
|--------------------------------------------------------------------------
| Serializable Classes
|--------------------------------------------------------------------------
|
| This value determines the classes that can be unserialized from cache
| storage. By default, no PHP classes will be unserialized from your
| cache to prevent gadget chain attacks if your APP_KEY is leaked.
|
*/
'serializable_classes' => false,
];
+184
View File
@@ -0,0 +1,184 @@
<?php
use Illuminate\Support\Str;
use Pdo\Mysql;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
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([
Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => env('DB_SSLMODE', 'prefer'),
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];
+80
View 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' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
+132
View 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', env('APP_NAME', 'Laravel')),
'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
View 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', env('APP_NAME', 'Laravel')),
],
];
+129
View File
@@ -0,0 +1,129 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "background", "failover", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];
+38
View 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' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];
+233
View File
@@ -0,0 +1,233 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "memcached",
| "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain without subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
/*
|--------------------------------------------------------------------------
| Session Serialization
|--------------------------------------------------------------------------
|
| This value controls the serialization strategy for session data, which
| is JSON by default. Setting this to "php" allows the storage of PHP
| objects in the session but can make an application vulnerable to
| "gadget chain" serialization attacks if the APP_KEY is leaked.
|
| Supported: "json", "php"
|
*/
'serialization' => 'json',
];
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->bigInteger('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->bigInteger('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedSmallInteger('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->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,233 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
// Adressbuch
Schema::create('addresses', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('first_name');
$table->string('last_name');
$table->string('company')->nullable();
$table->string('street');
$table->string('street2')->nullable();
$table->string('zip');
$table->string('city');
$table->string('country')->default('DE');
$table->string('phone')->nullable();
$table->boolean('is_default')->default(false);
$table->timestamps();
});
// Kategorien
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('image')->nullable();
$table->unsignedInteger('sort_order')->default(0);
$table->boolean('active')->default(true);
$table->timestamps();
});
// Produkte
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->string('name');
$table->string('slug')->unique();
$table->longText('description')->nullable();
$table->decimal('base_price', 10, 2);
$table->decimal('tax_rate', 5, 2)->default(19.00);
$table->decimal('weight', 8, 3)->nullable();
$table->boolean('active')->default(true);
$table->unsignedInteger('sort_order')->default(0);
$table->timestamps();
});
// Produktbilder
Schema::create('product_images', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->string('path');
$table->unsignedInteger('sort_order')->default(0);
$table->timestamps();
});
// Attribute (z.B. "Größe", "Farbe")
Schema::create('attributes', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
// Attributwerte (z.B. "M", "Rot")
Schema::create('attribute_values', function (Blueprint $table) {
$table->id();
$table->foreignId('attribute_id')->constrained()->cascadeOnDelete();
$table->string('value');
$table->unsignedInteger('sort_order')->default(0);
$table->timestamps();
});
// Produktvarianten
Schema::create('product_variants', function (Blueprint $table) {
$table->id();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->string('sku')->unique();
$table->decimal('price_override', 10, 2)->nullable();
$table->integer('stock')->default(0);
$table->integer('stock_warning')->default(5);
$table->boolean('active')->default(true);
$table->timestamps();
});
// Variante ↔ Attributwerte (Pivot)
Schema::create('product_variant_attribute_values', function (Blueprint $table) {
$table->foreignId('product_variant_id')->constrained()->cascadeOnDelete();
$table->foreignId('attribute_value_id')->constrained()->cascadeOnDelete();
$table->primary(['product_variant_id', 'attribute_value_id']);
});
// Versandzonen
Schema::create('shipping_rates', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('zone')->default('DE');
$table->decimal('price', 10, 2);
$table->decimal('free_from', 10, 2)->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
});
// Bestellungen
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->string('order_number')->unique();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('guest_email')->nullable();
$table->enum('status', ['new','payment_received','processing','shipped','completed','cancelled'])->default('new');
$table->enum('payment_method', ['prepayment','invoice']);
$table->decimal('subtotal', 10, 2);
$table->decimal('tax_total', 10, 2);
$table->decimal('shipping_cost', 10, 2)->default(0);
$table->decimal('total', 10, 2);
$table->string('tracking_code')->nullable();
$table->text('notes')->nullable();
$table->timestamp('paid_at')->nullable();
$table->timestamps();
});
// Bestellpositionen
Schema::create('order_items', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_variant_id')->nullable()->constrained()->nullOnDelete();
$table->string('product_name');
$table->string('variant_label')->nullable();
$table->integer('quantity');
$table->decimal('unit_price', 10, 2);
$table->decimal('tax_rate', 5, 2);
$table->timestamps();
});
// Bestelladressen (Rechnungs- & Lieferadresse eingefroren)
Schema::create('order_addresses', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->enum('type', ['billing','shipping']);
$table->string('first_name');
$table->string('last_name');
$table->string('company')->nullable();
$table->string('street');
$table->string('street2')->nullable();
$table->string('zip');
$table->string('city');
$table->string('country')->default('DE');
$table->string('phone')->nullable();
$table->timestamps();
});
// CMS-Seiten (statisch, blog, faq)
Schema::create('pages', function (Blueprint $table) {
$table->id();
$table->string('slug')->unique();
$table->string('title');
$table->longText('content')->nullable();
$table->enum('type', ['static','blog','faq'])->default('static');
$table->string('image')->nullable();
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->boolean('published')->default(true);
$table->timestamp('published_at')->nullable();
$table->timestamps();
});
// Startseiten-Banner
Schema::create('banners', function (Blueprint $table) {
$table->id();
$table->string('image');
$table->string('headline')->nullable();
$table->string('subtext')->nullable();
$table->string('button_label')->nullable();
$table->string('button_link')->nullable();
$table->unsignedInteger('sort_order')->default(0);
$table->boolean('active')->default(true);
$table->timestamps();
});
// FAQ-Gruppen
Schema::create('faq_groups', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->unsignedInteger('sort_order')->default(0);
$table->timestamps();
});
// FAQ-Einträge
Schema::create('faqs', function (Blueprint $table) {
$table->id();
$table->foreignId('faq_group_id')->nullable()->constrained()->nullOnDelete();
$table->string('question');
$table->text('answer');
$table->unsignedInteger('sort_order')->default(0);
$table->timestamps();
});
// Shop-Einstellungen (key/value)
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('settings');
Schema::dropIfExists('faqs');
Schema::dropIfExists('faq_groups');
Schema::dropIfExists('banners');
Schema::dropIfExists('pages');
Schema::dropIfExists('order_addresses');
Schema::dropIfExists('order_items');
Schema::dropIfExists('orders');
Schema::dropIfExists('shipping_rates');
Schema::dropIfExists('product_variant_attribute_values');
Schema::dropIfExists('product_variants');
Schema::dropIfExists('attribute_values');
Schema::dropIfExists('attributes');
Schema::dropIfExists('product_images');
Schema::dropIfExists('products');
Schema::dropIfExists('categories');
Schema::dropIfExists('addresses');
}
};
@@ -0,0 +1,21 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->enum('role', ['customer', 'admin', 'super_admin'])->default('customer')->after('email');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('role');
});
}
};
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('approved')->default(false)->after('role');
});
// Admins and existing super_admins are always approved
\DB::table('users')->whereIn('role', ['admin', 'super_admin'])->update(['approved' => true]);
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('approved');
});
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->boolean('show_in_footer')->default(true)->after('published');
$table->boolean('show_in_nav')->default(false)->after('show_in_footer');
$table->integer('nav_sort')->default(0)->after('show_in_nav');
});
}
public function down(): void
{
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn(['show_in_footer', 'show_in_nav', 'nav_sort']);
});
}
};
@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::table('products', function (Blueprint $table) {
$table->boolean('featured')->default(false)->after('active');
});
}
public function down(): void {
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('featured');
});
}
};
@@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void {
Schema::table('products', function (Blueprint $table) {
$table->boolean('track_stock')->default(true)->after('featured');
});
}
public function down(): void {
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('track_stock');
});
}
};
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class AdminUserSeeder extends Seeder
{
public function run(): void
{
User::firstOrCreate(['email' => 'admin@example.de'], [
'name' => 'Administrator',
'password' => bcrypt('changeme123'),
'role' => 'super_admin',
'email_verified_at' => now(),
]);
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call([
SettingsSeeder::class,
AdminUserSeeder::class,
]);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Database\Seeders;
use App\Models\Setting;
use App\Models\ShippingRate;
use Illuminate\Database\Seeder;
class SettingsSeeder extends Seeder
{
public function run(): void
{
$defaults = [
'shop_name' => 'Mein Online-Shop',
'shop_email' => 'info@example.de',
'shop_phone' => '',
'shop_address' => '',
'shop_owner' => '',
'shop_vat_id' => '',
'bank_name' => '',
'bank_iban' => '',
'bank_bic' => '',
'invoice_payment_days' => '14',
'currency' => 'EUR',
'currency_symbol' => '€',
'smtp_host' => '',
'smtp_port' => '587',
'smtp_user' => '',
'smtp_password' => '',
'smtp_from_name' => 'Mein Online-Shop',
'smtp_from_email' => 'noreply@example.de',
'cookie_consent' => '1',
'google_analytics' => '',
];
foreach ($defaults as $key => $value) {
Setting::firstOrCreate(['key' => $key], ['value' => $value]);
}
ShippingRate::firstOrCreate(['name' => 'Standard (Deutschland)'], [
'zone' => 'DE',
'price' => 4.99,
'free_from' => 50.00,
'active' => true,
]);
}
}
+2730
View File
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More