massive improvements to tests, streamlined and synced migrations, fixed a lot of wrong or old table field references. implemented a lot of pages in react for website frontend
This commit is contained in:
@@ -79,7 +79,7 @@ class PackageController extends Controller
|
||||
\App\Models\EventPackage::create([
|
||||
'event_id' => $request->event_id,
|
||||
'package_id' => $package->id,
|
||||
'purchased_price' => $package->price,
|
||||
'price' => $package->price,
|
||||
'purchased_at' => now(),
|
||||
]);
|
||||
} else {
|
||||
|
||||
@@ -63,7 +63,7 @@ class StripeWebhookController extends Controller
|
||||
'type' => $type,
|
||||
'provider_id' => 'stripe',
|
||||
'transaction_id' => $paymentIntent['id'],
|
||||
'purchased_price' => $paymentIntent['amount_received'] / 100,
|
||||
'price' => $paymentIntent['amount_received'] / 100,
|
||||
'metadata' => $metadata,
|
||||
]);
|
||||
|
||||
@@ -128,7 +128,7 @@ class StripeWebhookController extends Controller
|
||||
'type' => 'reseller_subscription',
|
||||
'provider_id' => 'stripe',
|
||||
'transaction_id' => $invoice['id'],
|
||||
'purchased_price' => $invoice['amount_paid'] / 100,
|
||||
'price' => $invoice['amount_paid'] / 100,
|
||||
'metadata' => $metadata,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class EventController extends Controller
|
||||
$eventPackage = \App\Models\EventPackage::create([
|
||||
'event_id' => $event->id,
|
||||
'package_id' => $packageId,
|
||||
'purchased_price' => $package->price,
|
||||
'price' => $package->price,
|
||||
'purchased_at' => now(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Http\Requests\Auth\LoginRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
@@ -29,10 +30,21 @@ class AuthenticatedSessionController extends Controller
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
try {
|
||||
$request->authenticate();
|
||||
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||
return redirect()->route('login')->withErrors($e->errors());
|
||||
}
|
||||
|
||||
Log::info('Login attempt', ['login' => $request->login, 'authenticated' => Auth::check()]);
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
$user = Auth::user();
|
||||
if ($user && !$user->hasVerifiedEmail()) {
|
||||
return redirect()->route('verification.notice');
|
||||
}
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,32 +3,31 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Package;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Models\User;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\Package;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Models\PackagePurchase;
|
||||
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\Support\Str;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MarketingRegisterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the registration form.
|
||||
* Show the registration page.
|
||||
*/
|
||||
public function create(Request $request): View
|
||||
public function create(Request $request, $package_id = null): \Illuminate\View\View
|
||||
{
|
||||
$package = null;
|
||||
if ($request->has('package_id')) {
|
||||
$package = Package::findOrFail($request->package_id);
|
||||
}
|
||||
$package = $package_id ? Package::find($package_id) : null;
|
||||
|
||||
return view('marketing.register', compact('package'));
|
||||
return view('marketing.register', [
|
||||
'package' => $package,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,14 +39,14 @@ class MarketingRegisterController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'username' => ['required', 'string', 'max:255', 'unique:' . User::class, 'alpha_dash'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:' . User::class],
|
||||
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'address' => ['required', 'string'],
|
||||
'address' => ['required', 'string', 'max:500'],
|
||||
'phone' => ['required', 'string', 'max:20'],
|
||||
'privacy_consent' => ['required', 'accepted'],
|
||||
'privacy_consent' => ['accepted'],
|
||||
'package_id' => ['nullable', 'exists:packages,id'],
|
||||
]);
|
||||
|
||||
@@ -55,12 +54,11 @@ class MarketingRegisterController extends Controller
|
||||
'name' => $request->name,
|
||||
'username' => $request->username,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'preferred_locale' => $request->preferred_locale ?? 'de',
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
$tenant = Tenant::create([
|
||||
@@ -68,27 +66,68 @@ class MarketingRegisterController extends Controller
|
||||
'name' => $request->name,
|
||||
'slug' => Str::slug($request->name . '-' . now()->timestamp),
|
||||
'email' => $request->email,
|
||||
'is_active' => true,
|
||||
'is_suspended' => false,
|
||||
'event_credits_balance' => 0,
|
||||
'subscription_tier' => 'free',
|
||||
'subscription_expires_at' => null,
|
||||
'settings' => json_encode([
|
||||
'branding' => [
|
||||
'logo_url' => null,
|
||||
'primary_color' => '#3B82F6',
|
||||
'secondary_color' => '#1F2937',
|
||||
'font_family' => 'Inter, sans-serif',
|
||||
],
|
||||
'features' => [
|
||||
'photo_likes_enabled' => false,
|
||||
'event_checklist' => false,
|
||||
'custom_domain' => false,
|
||||
'advanced_analytics' => false,
|
||||
],
|
||||
'custom_domain' => null,
|
||||
'contact_email' => $request->email,
|
||||
'event_default_type' => 'general',
|
||||
]),
|
||||
]);
|
||||
|
||||
// If package_id provided and free, assign immediately
|
||||
if ($request->package_id) {
|
||||
$package = Package::find($request->package_id);
|
||||
if ($package && $package->price == 0) {
|
||||
TenantPackage::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'active' => true,
|
||||
'expires_at' => now()->addYear(), // or based on package duration
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
// Send Welcome Email
|
||||
\Illuminate\Support\Facades\Mail::to($user)->send(new \App\Mail\Welcome($user));
|
||||
|
||||
if ($request->filled('package_id')) {
|
||||
$package = Package::find($request->package_id);
|
||||
if (!$package) {
|
||||
// Fallback for invalid package_id
|
||||
} else if ($package->price == 0) {
|
||||
// Assign free package
|
||||
TenantPackage::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'active' => true,
|
||||
'price' => 0,
|
||||
]);
|
||||
|
||||
PackagePurchase::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'type' => $package->type === 'endcustomer' ? 'endcustomer_event' : 'reseller_subscription',
|
||||
'price' => 0,
|
||||
'purchased_at' => now(),
|
||||
'provider_id' => 'free',
|
||||
]);
|
||||
|
||||
$tenant->update(['subscription_status' => 'active']);
|
||||
} else {
|
||||
// Redirect to buy for paid package
|
||||
return redirect()->route('buy.packages', $package->id);
|
||||
}
|
||||
}
|
||||
|
||||
return $user->hasVerifiedEmail()
|
||||
? redirect()->intended('/admin')
|
||||
? redirect()->intended(route('dashboard'))
|
||||
: redirect()->route('verification.notice');
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,13 @@ class RegisteredUserController extends Controller
|
||||
/**
|
||||
* Show the registration page.
|
||||
*/
|
||||
public function create(): Response
|
||||
public function create(Request $request): Response
|
||||
{
|
||||
return Inertia::render('auth/register');
|
||||
$package = $request->query('package_id') ? \App\Models\Package::find($request->query('package_id')) : null;
|
||||
|
||||
return Inertia::render('auth/register', [
|
||||
'package' => $package,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,28 +37,101 @@ class RegisteredUserController extends Controller
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|lowercase|email|max:255|unique:'.User::class,
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'username' => ['required', 'string', 'max:255', 'unique:'.User::class],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'address' => ['required', 'string', 'max:500'],
|
||||
'phone' => ['required', 'string', 'max:20'],
|
||||
'privacy_consent' => ['accepted'],
|
||||
'package_id' => ['nullable', 'exists:packages,id'],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'username' => $request->username,
|
||||
'email' => $request->email,
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'password' => Hash::make($request->password),
|
||||
'privacy_consent_at' => now(), // Neues Feld für Consent (füge Migration hinzu, falls nötig)
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Creating tenant for user ID: ' . $user->id);
|
||||
|
||||
$tenant = Tenant::create([
|
||||
'user_id' => $user->id,
|
||||
'name' => $request->name,
|
||||
'slug' => Str::slug($request->name . '-' . now()->timestamp),
|
||||
'email' => $request->email,
|
||||
'is_active' => true,
|
||||
'is_suspended' => false,
|
||||
'event_credits_balance' => 0,
|
||||
'subscription_tier' => 'free',
|
||||
'subscription_expires_at' => null,
|
||||
'settings' => json_encode([
|
||||
'branding' => [
|
||||
'logo_url' => null,
|
||||
'primary_color' => '#3B82F6',
|
||||
'secondary_color' => '#1F2937',
|
||||
'font_family' => 'Inter, sans-serif',
|
||||
],
|
||||
'features' => [
|
||||
'photo_likes_enabled' => false,
|
||||
'event_checklist' => false,
|
||||
'custom_domain' => false,
|
||||
'advanced_analytics' => false,
|
||||
],
|
||||
'custom_domain' => null,
|
||||
'contact_email' => $request->email,
|
||||
'event_default_type' => 'general',
|
||||
]),
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Tenant created with ID: ' . $tenant->id);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
// Send Welcome Email
|
||||
\Illuminate\Support\Facades\Mail::to($user)->send(new \App\Mail\Welcome($user));
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
if ($request->filled('package_id')) {
|
||||
$package = \App\Models\Package::find($request->package_id);
|
||||
if ($package && $package->price == 0) {
|
||||
// Assign free package
|
||||
\App\Models\TenantPackage::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'active' => true,
|
||||
'price' => 0,
|
||||
]);
|
||||
|
||||
\App\Models\PackagePurchase::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'type' => $package->type === 'endcustomer' ? 'endcustomer_event' : 'reseller_subscription',
|
||||
'price' => 0,
|
||||
'purchased_at' => now(),
|
||||
'provider_id' => 'free',
|
||||
]);
|
||||
|
||||
$tenant->update(['subscription_status' => 'active']);
|
||||
} else if ($package) {
|
||||
// Redirect to buy for paid package
|
||||
return redirect()->route('buy.packages', $package->id);
|
||||
}
|
||||
}
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Logging in user ID: ' . $user->id);
|
||||
Auth::login($user);
|
||||
\Illuminate\Support\Facades\Log::info('User logged in: ' . (Auth::check() ? 'Yes' : 'No'));
|
||||
|
||||
return $user->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard'))
|
||||
: redirect()->route('verification.notice');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ use Stripe\Stripe;
|
||||
use Stripe\Checkout\Session;
|
||||
use Stripe\StripeClient;
|
||||
use Exception;
|
||||
use PayPal\PayPalHttp\Client;
|
||||
use PayPal\PayPalHttp\HttpException;
|
||||
use PayPal\Checkout\Orders\OrdersCreateRequest;
|
||||
use PayPal\Checkout\Orders\OrdersCaptureRequest;
|
||||
use PayPal\Checkout\Orders\OrdersGetRequest;
|
||||
use PayPal\Checkout\Orders\Order;
|
||||
use PayPalHttp\Client;
|
||||
use PayPalHttp\HttpException;
|
||||
use PayPalCheckout\OrdersCreateRequest;
|
||||
use PayPalCheckout\OrdersCaptureRequest;
|
||||
use PayPalCheckout\OrdersGetRequest;
|
||||
use PayPalCheckout\Order;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\BlogPost;
|
||||
use App\Models\Package;
|
||||
@@ -62,6 +62,7 @@ class MarketingController extends Controller
|
||||
*/
|
||||
public function buyPackages(Request $request, $packageId)
|
||||
{
|
||||
Log::info('Buy packages called', ['auth' => Auth::check(), 'package_id' => $packageId]);
|
||||
$package = Package::findOrFail($packageId);
|
||||
|
||||
if (!Auth::check()) {
|
||||
@@ -87,6 +88,7 @@ class MarketingController extends Controller
|
||||
'package_id' => $package->id,
|
||||
],
|
||||
[
|
||||
'price' => $package->price,
|
||||
'active' => true,
|
||||
'purchased_at' => now(),
|
||||
'expires_at' => now()->addYear(),
|
||||
@@ -97,8 +99,8 @@ class MarketingController extends Controller
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'provider_id' => 'free',
|
||||
'price' => 0,
|
||||
'type' => $package->type,
|
||||
'price' => $package->price,
|
||||
'type' => $package->type === 'endcustomer' ? 'endcustomer_event' : 'reseller_subscription',
|
||||
'purchased_at' => now(),
|
||||
'refunded' => false,
|
||||
]);
|
||||
@@ -300,6 +302,7 @@ class MarketingController extends Controller
|
||||
'package_id' => $package->id,
|
||||
],
|
||||
[
|
||||
'price' => $package->price,
|
||||
'active' => true,
|
||||
'purchased_at' => now(),
|
||||
'expires_at' => now()->addYear(), // One-time as annual for reseller too
|
||||
@@ -311,7 +314,7 @@ class MarketingController extends Controller
|
||||
'package_id' => $package->id,
|
||||
'provider_id' => 'paypal',
|
||||
'price' => $package->price,
|
||||
'type' => $package->type,
|
||||
'type' => $package->type === 'endcustomer' ? 'endcustomer_event' : 'reseller_subscription',
|
||||
'purchased_at' => now(),
|
||||
'refunded' => false,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user