chore: code style
This commit is contained in:
@@ -2,21 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use App\Models\User;
|
||||
use App\Models\ConnectedAccount;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use App\Models\User;
|
||||
use App\Notifications\VerifyConnectedAccountNotification;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
use App\Notifications\VerifyConnectedAccountNotification;
|
||||
|
||||
class ConnectedAccountController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Redirect the user to the GitHub authentication page.
|
||||
*
|
||||
*/
|
||||
public function redirectToProvider(string $provider)
|
||||
{
|
||||
@@ -27,7 +25,6 @@ class ConnectedAccountController extends Controller
|
||||
|
||||
/**
|
||||
* Obtain the user information from GitHub.
|
||||
*
|
||||
*/
|
||||
public function handleProviderCallback(string $provider)
|
||||
{
|
||||
@@ -44,21 +41,21 @@ class ConnectedAccountController extends Controller
|
||||
}
|
||||
|
||||
// check if this account is already linked
|
||||
$connected_account = ConnectedAccount::firstOrNew([
|
||||
$connected_account = ConnectedAccount::firstOrNew([
|
||||
'provider' => $provider,
|
||||
'provider_id' => $providerUser->id
|
||||
'provider_id' => $providerUser->id,
|
||||
], [
|
||||
'token' => $providerUser->token,
|
||||
'secret' => $providerUser->tokenSecret,
|
||||
'refresh_token' => $providerUser->refreshToken,
|
||||
'expires_at' => $providerUser->expiresIn,
|
||||
'verified_at' => false
|
||||
'verified_at' => false,
|
||||
]);
|
||||
|
||||
// already linked and verified, let's go login!
|
||||
if (
|
||||
$connected_account->exists
|
||||
&& !is_null($connected_account->verified_at)
|
||||
$connected_account->exists
|
||||
&& ! is_null($connected_account->verified_at)
|
||||
) {
|
||||
|
||||
Auth::login($connected_account->user, true);
|
||||
@@ -67,20 +64,20 @@ class ConnectedAccountController extends Controller
|
||||
}
|
||||
|
||||
// new user, let's create one
|
||||
if (!$user = User::where('email', $providerUser->email)->first()) {
|
||||
if (! $user = User::where('email', $providerUser->email)->first()) {
|
||||
|
||||
$user = User::create([
|
||||
'name' => $providerUser->name,
|
||||
'email' => $providerUser->email,
|
||||
'email_verified_at' => now()
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
|
||||
$connected_account->user_id = $user->id;
|
||||
$connected_account->verified_at = now();
|
||||
$connected_account->save();
|
||||
|
||||
|
||||
Auth::login($user, true);
|
||||
|
||||
|
||||
return redirect(route('dashboard'));
|
||||
}
|
||||
|
||||
@@ -91,23 +88,23 @@ class ConnectedAccountController extends Controller
|
||||
$user->notify(new VerifyConnectedAccountNotification($connected_account->id));
|
||||
|
||||
return redirect(route('login'))
|
||||
->with('status', __(
|
||||
'Account already exists. Check your email to connect your :provider account.',
|
||||
['provider' => config("services.$provider.name")]
|
||||
));
|
||||
->with('status', __(
|
||||
'Account already exists. Check your email to connect your :provider account.',
|
||||
['provider' => config("services.$provider.name")]
|
||||
));
|
||||
}
|
||||
|
||||
protected function validateProvider($provider): void
|
||||
{
|
||||
if (!in_array($provider, explode(',', config('services.enabled_login_providers')))) {
|
||||
|
||||
if (! in_array($provider, explode(',', config('services.enabled_login_providers')))) {
|
||||
|
||||
throw new Exception('Please provide a valid social provider.');
|
||||
}
|
||||
}
|
||||
|
||||
public function verify(ConnectedAccount $connected_account)
|
||||
{
|
||||
if (!$connected_account->verified_at) {
|
||||
if (! $connected_account->verified_at) {
|
||||
|
||||
// mark request as verified
|
||||
$connected_account->verified_at = now();
|
||||
@@ -127,8 +124,8 @@ class ConnectedAccountController extends Controller
|
||||
'css' => 'alert-success',
|
||||
'icon' => Blade::render("<x-mary-icon class='w-7 h-7' name='o-check-circle' />"),
|
||||
'position' => 'toast-top toast-end',
|
||||
'timeout' => '5000'
|
||||
]
|
||||
'timeout' => '5000',
|
||||
],
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ class DashboardController extends Controller
|
||||
|
||||
// get portfolio metrics
|
||||
$metrics = cache()->remember(
|
||||
'dashboard-metrics-' . $user->id,
|
||||
10,
|
||||
'dashboard-metrics-'.$user->id,
|
||||
10,
|
||||
function () {
|
||||
return
|
||||
Holding::query()
|
||||
->myHoldings()
|
||||
->withoutWishlists()
|
||||
->withPortfolioMetrics()
|
||||
->first();
|
||||
->myHoldings()
|
||||
->withoutWishlists()
|
||||
->withPortfolioMetrics()
|
||||
->first();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -8,21 +8,20 @@ use Illuminate\Http\Request;
|
||||
|
||||
class HoldingController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Request $request, Portfolio $portfolio, String $symbol)
|
||||
public function show(Request $request, Portfolio $portfolio, string $symbol)
|
||||
{
|
||||
$holding = Holding::with([
|
||||
'market_data',
|
||||
'transactions' => function ($query) use ($symbol) {
|
||||
$query->where('transactions.symbol', $symbol);
|
||||
}
|
||||
])
|
||||
->symbol($symbol)
|
||||
->portfolio($portfolio->id)
|
||||
->firstOrFail();
|
||||
'market_data',
|
||||
'transactions' => function ($query) use ($symbol) {
|
||||
$query->where('transactions.symbol', $symbol);
|
||||
},
|
||||
])
|
||||
->symbol($symbol)
|
||||
->portfolio($portfolio->id)
|
||||
->firstOrFail();
|
||||
|
||||
$formattedTransactions = $holding->getFormattedTransactions();
|
||||
|
||||
|
||||
@@ -2,21 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Portfolio;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvitedOnboardingController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Check if the invited user needs a password?
|
||||
*
|
||||
*/
|
||||
public function __invoke(Request $request, Portfolio $portfolio, User $user)
|
||||
{
|
||||
|
||||
if (!$request->hasValidSignature()) {
|
||||
if (! $request->hasValidSignature()) {
|
||||
abort(401, 'Invalid signature');
|
||||
}
|
||||
|
||||
@@ -26,7 +24,7 @@ class InvitedOnboardingController extends Controller
|
||||
// route to create password form
|
||||
return view('auth.invited-onboarding', [
|
||||
'portfolio' => $portfolio,
|
||||
'user' => $user
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class PortfolioController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
@@ -26,21 +25,21 @@ class PortfolioController extends Controller
|
||||
Gate::authorize('readOnly', $portfolio);
|
||||
|
||||
$portfolio->load(['transactions', 'holdings']);
|
||||
|
||||
|
||||
// get portfolio metrics
|
||||
$metrics = cache()->remember(
|
||||
'portfolio-metrics-' . $portfolio->id,
|
||||
60,
|
||||
'portfolio-metrics-'.$portfolio->id,
|
||||
60,
|
||||
function () use ($portfolio) {
|
||||
return Holding::query()
|
||||
->portfolio($portfolio->id)
|
||||
->withPortfolioMetrics()
|
||||
->first();
|
||||
->portfolio($portfolio->id)
|
||||
->withPortfolioMetrics()
|
||||
->first();
|
||||
}
|
||||
);
|
||||
|
||||
$formattedHoldings = $portfolio->getFormattedHoldings();
|
||||
|
||||
|
||||
return view('portfolio.show', compact(['portfolio', 'metrics', 'formattedHoldings']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
||||
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user