File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace App \Http \Controllers ;
44
5+ use App \Models \Badge \Badge ;
56use Illuminate \Support \Facades \Auth ;
7+ use Illuminate \Support \Facades \Gate ;
68use Inertia \Inertia ;
79
810class WelcomeController extends Controller
@@ -14,7 +16,7 @@ public function __invoke()
1416 $ event = \App \Models \Event::getActiveEvent ();
1517
1618 $ prepaidBadgesLeft = 0 ;
17- if ($ event && Auth::check ()) {
19+ if ($ event && Auth::check () && Gate:: allows ( ' create ' , Badge::class) ) {
1820 $ user = Auth::user ();
1921 $ prepaidBadgesLeft = $ user ->getPrepaidBadgesLeft ($ event ->id );
2022 }
Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ public function create(User $user): bool
3838 return false ;
3939 }
4040
41+ // Allow badge creation only if event allows orders (for paid badges)
42+ if (! $ event ->allowsOrders ()) {
43+ return false ;
44+ }
45+
4146 // Check if user has prepaid badges left
4247 $ eventUser = $ user ->eventUser ($ event ->id );
4348 if ($ eventUser ) {
@@ -55,11 +60,6 @@ public function create(User $user): bool
5560 }
5661 }
5762
58- // Allow badge creation only if event allows orders (for paid badges)
59- if (! $ event ->allowsOrders ()) {
60- return false ;
61- }
62-
6363 return true ;
6464 }
6565
You can’t perform that action at this time.
0 commit comments