feat: cache team settings
This commit is contained in:
parent
0d1a2aa5d1
commit
45b597bbab
@ -6,6 +6,7 @@ use App\Actions\Server\InstallDocker;
|
|||||||
use App\Models\PrivateKey;
|
use App\Models\PrivateKey;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
|
use App\Models\Team;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@ -70,9 +71,10 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
}
|
}
|
||||||
public function skipBoarding()
|
public function skipBoarding()
|
||||||
{
|
{
|
||||||
currentTeam()->update([
|
Team::find(currentTeam()->id)->update([
|
||||||
'show_boarding' => false
|
'show_boarding' => false
|
||||||
]);
|
]);
|
||||||
|
ray(currentTeam());
|
||||||
refreshSession();
|
refreshSession();
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class SwitchTeam extends Component
|
|||||||
if (!$team_to_switch_to) {
|
if (!$team_to_switch_to) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session(['currentTeam' => $team_to_switch_to]);
|
refreshSession($team_to_switch_to);
|
||||||
return redirect(request()->header('Referer'));
|
return redirect(request()->header('Referer'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class IsBoardingFlow
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
// ray()->showQueries()->color('orange');
|
ray()->showQueries()->color('orange');
|
||||||
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
|
if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) {
|
||||||
return redirect('boarding');
|
return redirect('boarding');
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Notifications\Channels\SendsEmail;
|
use App\Notifications\Channels\SendsEmail;
|
||||||
use App\Notifications\TransactionalEmails\ResetPassword as TransactionalEmailsResetPassword;
|
use App\Notifications\TransactionalEmails\ResetPassword as TransactionalEmailsResetPassword;
|
||||||
|
use Cache;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@ -94,7 +95,9 @@ class User extends Authenticatable implements SendsEmail
|
|||||||
|
|
||||||
public function currentTeam()
|
public function currentTeam()
|
||||||
{
|
{
|
||||||
return Team::find(session('currentTeam')->id);
|
return Cache::remember('team:' . auth()->user()->id, 3600, function() {
|
||||||
|
return Team::find(session('currentTeam')->id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function otherTeams()
|
public function otherTeams()
|
||||||
|
@ -57,9 +57,15 @@ function showBoarding(): bool
|
|||||||
{
|
{
|
||||||
return currentTeam()->show_boarding ?? false;
|
return currentTeam()->show_boarding ?? false;
|
||||||
}
|
}
|
||||||
function refreshSession(): void
|
function refreshSession(?Team $team = null): void
|
||||||
{
|
{
|
||||||
$team = Team::find(currentTeam()->id);
|
if (!$team) {
|
||||||
|
$team = Team::find(currentTeam()->id);
|
||||||
|
}
|
||||||
|
Cache::forget('team:' . auth()->user()->id);
|
||||||
|
Cache::remember('team:' . auth()->user()->id, 3600, function() use ($team) {
|
||||||
|
return $team;
|
||||||
|
});
|
||||||
session(['currentTeam' => $team]);
|
session(['currentTeam' => $team]);
|
||||||
}
|
}
|
||||||
function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed
|
function general_error_handler(Throwable | null $err = null, $that = null, $isJson = false, $customErrorMessage = null): mixed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user