Skip to content

Commit a04ce1a

Browse files
committed
Merge remote-tracking branch 'origin/main' into developer-plugin-terms
# Conflicts: # app/Http/Controllers/CustomerLicenseController.php
2 parents 6abf1fe + d65ef9c commit a04ce1a

15 files changed

Lines changed: 1343 additions & 11 deletions

File tree

app/Http/Controllers/CustomerLicenseController.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ public function index(): View
3131
// Get subscription plan name
3232
$subscriptionName = null;
3333
if ($activeSubscription) {
34-
try {
35-
$subscriptionName = $activeSubscription->stripe_price
36-
? \App\Enums\Subscription::fromStripePriceId($activeSubscription->stripe_price)->name()
37-
: ucfirst($activeSubscription->type);
38-
} catch (\RuntimeException) {
34+
if ($activeSubscription->stripe_price) {
35+
try {
36+
$subscriptionName = \App\Enums\Subscription::fromStripePriceId($activeSubscription->stripe_price)->name();
37+
} catch (\RuntimeException) {
38+
$subscriptionName = ucfirst($activeSubscription->type);
39+
}
40+
} else {
3941
$subscriptionName = ucfirst($activeSubscription->type);
4042
}
4143
}
@@ -61,8 +63,9 @@ public function index(): View
6163
default => 'No accounts connected',
6264
};
6365

64-
// Total purchases (licenses + plugins)
65-
$totalPurchases = $licenseCount + $pluginLicenseCount;
66+
// Total purchases (licenses + plugins + products)
67+
$productLicenseCount = $user->productLicenses()->count();
68+
$totalPurchases = $licenseCount + $pluginLicenseCount + $productLicenseCount;
6669

6770
$developerAccount = $user->developerAccount;
6871

app/Http/Controllers/ProductController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\Product;
6+
use Illuminate\Http\RedirectResponse;
67
use Illuminate\Support\Facades\Auth;
78
use Illuminate\View\View;
89

910
class ProductController extends Controller
1011
{
11-
public function show(Product $product): View
12+
public function show(Product $product): View|RedirectResponse
1213
{
1314
abort_unless($product->isActive(), 404);
1415

16+
if ($product->slug === 'nativephp-masterclass') {
17+
return redirect()->route('course');
18+
}
19+
1520
$user = Auth::user();
1621

1722
if (! $product->hasAccessiblePriceFor($user)) {

app/Http/Controllers/PurchaseHistoryController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,28 @@ public function index(): View
6161
];
6262
});
6363

64+
// Fetch product licenses (e.g. Plugin Dev Kit, Masterclass)
65+
$productLicenses = $user->productLicenses()
66+
->with('product')
67+
->orderBy('purchased_at', 'desc')
68+
->get()
69+
->map(function ($productLicense) {
70+
return [
71+
'type' => 'product',
72+
'name' => $productLicense->product->name ?? 'Product',
73+
'description' => $productLicense->product->description ?? null,
74+
'price' => $productLicense->price_paid,
75+
'currency' => $productLicense->currency,
76+
'purchased_at' => $productLicense->purchased_at,
77+
'expires_at' => null,
78+
'is_active' => true,
79+
'href' => $productLicense->product ? route('products.show', $productLicense->product) : null,
80+
];
81+
});
82+
6483
// Combine and sort by purchased_at descending
6584
$purchases = $licenses->concat($pluginLicenses)
85+
->concat($productLicenses)
6686
->sortByDesc('purchased_at')
6787
->values();
6888

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
use App\Models\Product;
4+
use App\Models\ProductPrice;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
$product = Product::create([
15+
'name' => 'The NativePHP Masterclass',
16+
'slug' => 'nativephp-masterclass',
17+
'description' => 'Go from zero to published app. Learn to build native mobile and desktop applications using the PHP and Laravel skills you already have.',
18+
'is_active' => true,
19+
'published_at' => now(),
20+
]);
21+
22+
ProductPrice::create([
23+
'product_id' => $product->id,
24+
'tier' => 'regular',
25+
'amount' => 10100,
26+
'currency' => 'USD',
27+
'is_active' => true,
28+
]);
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*/
34+
public function down(): void
35+
{
36+
$product = Product::where('slug', 'nativephp-masterclass')->first();
37+
38+
if ($product) {
39+
$product->prices()->delete();
40+
$product->delete();
41+
}
42+
}
43+
};

resources/views/components/footer.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ class="inline-block px-px py-1.5 transition duration-300 will-change-transform h
239239
Develop
240240
</a>
241241
</li>
242+
<li>
243+
<a
244+
href="{{ route('course') }}"
245+
class="inline-block px-px py-1.5 transition duration-300 will-change-transform hover:translate-x-1 hover:text-gray-700 dark:hover:text-gray-300"
246+
>
247+
<span class="inline-flex items-center gap-1.5">
248+
Learn
249+
<span class="rounded-full bg-emerald-500 px-1.5 py-px text-[10px] font-bold leading-tight text-white">New</span>
250+
</span>
251+
</a>
252+
</li>
242253
<li>
243254
<a
244255
href="{{ route('wall-of-love') }}"

resources/views/components/layout.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
}"
105105
x-resize="
106106
width = $width
107-
if (width >= 1024) {
107+
if (width >= 1280) {
108108
showMobileMenu = false
109109
showDocsMenu = false
110110
}

resources/views/components/navbar/mobile-menu.blade.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class="@md:grid-cols-3 grid grid-cols-2 text-xl"
9292
$isBlogActive = request()->routeIs('blog*');
9393
$isPartnersActive = request()->routeIs('partners*');
9494
$isServicesActive = request()->routeIs('build-my-app');
95+
$isCourseActive = request()->routeIs('course');
9596
$isSponsorActive = request()->routeIs('sponsoring*');
9697
$isLoginActive = request()->routeIs('customer.login*');
9798
@endphp
@@ -244,6 +245,32 @@ class="size-4 shrink-0"
244245
</a>
245246
</div>
246247

248+
{{-- Course Link --}}
249+
<div>
250+
<a
251+
href="{{ route('course') }}"
252+
@class([
253+
'flex items-center gap-2 py-3 transition duration-200',
254+
'font-medium' => $isCourseActive,
255+
'opacity-50 hover:translate-x-1 hover:opacity-100' => ! $isCourseActive,
256+
])
257+
aria-current="{{ $isCourseActive ? 'page' : 'false' }}"
258+
>
259+
@if ($isCourseActive)
260+
<x-icons.right-arrow
261+
class="size-4 shrink-0"
262+
aria-hidden="true"
263+
focusable="false"
264+
/>
265+
@endif
266+
267+
<div class="inline-flex items-center gap-2">
268+
Learn
269+
<span class="rounded-full bg-emerald-500 px-1.5 py-px text-[10px] font-bold leading-tight text-white">New</span>
270+
</div>
271+
</a>
272+
</div>
273+
247274
{{-- Login/Dashboard --}}
248275
@feature(App\Features\ShowAuthButtons::class)
249276
<div>

resources/views/components/navigation-bar.blade.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,28 @@ class="size-[3px] rotate-45 rounded-xs bg-gray-400 transition duration-200 dark:
162162
Develop
163163
</a>
164164

165+
{{-- Decorative circle --}}
166+
<div
167+
class="size-[3px] rotate-45 rounded-xs bg-gray-400 transition duration-200 dark:opacity-60"
168+
aria-hidden="true"
169+
></div>
170+
171+
{{-- Link --}}
172+
<a
173+
href="{{ route('course') }}"
174+
@class([
175+
'transition duration-200',
176+
'font-medium' => request()->routeIs('course'),
177+
'opacity-60 hover:opacity-100' => ! request()->routeIs('course'),
178+
])
179+
aria-current="{{ request()->routeIs('course') ? 'page' : 'false' }}"
180+
>
181+
<span class="inline-flex items-center gap-1.5">
182+
Learn
183+
<span class="rounded-full bg-emerald-500 px-1.5 py-px text-[10px] font-bold leading-tight text-white">New</span>
184+
</span>
185+
</a>
186+
165187
{{-- Login/Logout --}}
166188
@feature(App\Features\ShowAuthButtons::class)
167189
{{-- Decorative circle --}}

0 commit comments

Comments
 (0)