Create billing section in settings
MODIFY
app/Http/Controllers/SettingsController.php
app/Http/Controllers/SettingsController.php
@@ -113,4 +113,11 @@ class SettingsController extends Controller
return view('settings.preferences', compact('languages'));
}
+
+ public function getBilling(Request $request)
+ {
+ $user = $request->user();
+
+ return view('settings.billing', ['user' => $user]);
+ }
}

MODIFY
app/Http/Kernel.php
app/Http/Kernel.php
@@ -59,6 +59,7 @@ class Kernel extends HttpKernel
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
+ 'stripe' => \App\Http\Middleware\RedirectIfStripeAbsent::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

ADD
app/Http/Middleware/RedirectIfStripeAbsent.php
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Helper;
+use Closure;
+
+class RedirectIfStripeAbsent
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ if (!Helper::arePlansEnabled()) {
+ return redirect()->route('dashboard');
+ }
+
+ return $next($request);
+ }
+}

MODIFY
app/Providers/AppServiceProvider.php
app/Providers/AppServiceProvider.php
namespace App\Providers;
+use App\Helper;
use App\Models\Space;
use Illuminate\Support\ServiceProvider;
use Auth;
@@ -20,6 +21,7 @@ class AppServiceProvider extends ServiceProvider
'userName' => Auth::check() ? Auth::user()->name : null,
'currency' => $selectedSpace ? $selectedSpace->currency->symbol : '-',
'selectedSpace' => $selectedSpace,
+ 'arePlansEnabled' => Helper::arePlansEnabled(),
'suggestionBoxEnabled' => env('SUGGESTION_BOX_ENABLED', false),
'versionNumber' => $versionNumber
]);

MODIFY
resources/lang/en/general.php
resources/lang/en/general.php
@@ -18,6 +18,7 @@ return [
'profile' => 'Profile',
'account' => 'Account',
'preferences' => 'Preferences',
+ 'billing' => 'Billing',
'general' => 'General',
'members' => 'Members',

MODIFY
resources/views/settings/layout.blade.php
resources/views/settings/layout.blade.php
<li><a href="/settings/profile"><i class="fas fa-user fa-sm"></i> {{ __('general.profile') }}</a></li>
<li><a href="/settings/account"><i class="fas fa-lock fa-sm"></i> {{ __('general.account') }}</a></li>
<li><a href="/settings/preferences"><i class="fas fa-sliders-h fa-sm"></i> {{ __('general.preferences') }}</a></li>
+ @if ($arePlansEnabled)
+ <li><a href="/settings/billing"><i class="fas fa-wallet fa-sm"></i> {{ __('general.billing') }}</a></li>
+ @endif
<li><a href="/settings/spaces"><i class="fas fa-rocket fa-sm"></i> {{ __('models.spaces') }}</a></li>
</ul>
</div>

MODIFY
routes/web.php
routes/web.php
@@ -121,6 +121,7 @@ Route::group(['middleware' => ['auth']], function () {
Route::get('/settings/profile', [SettingsController::class, 'getProfile'])->name('profile');
Route::get('/settings/account', [SettingsController::class, 'getAccount'])->name('account');
Route::get('/settings/preferences', [SettingsController::class, 'getPreferences'])->name('preferences');
+ Route::get('/settings/billing', [SettingsController::class, 'getBilling'])->name('billing')->middleware('stripe');
Route::get('/settings/spaces', [SettingsController::class, 'getSpaces'])->name('spaces.index');
});

Create billing section in settings