AccountController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 37
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A settings() 0 21 2
A index() 0 3 1
A dashboard() 0 19 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use App\Models\AccountModel;
7
use App\Models\Eloquent\UserExtra;
8
use App\Models\Eloquent\Tool\Socialite;
9
use Auth;
10
11
class AccountController extends Controller
12
{
13
    /**
14
     * Show the account index.
15
     *
16
     * @return \Illuminate\View\View
17
     */
18
    public function index()
19
    {
20
        return response()->redirectTo("/account/dashboard");
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->redir...o('/account/dashboard') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\View\View.
Loading history...
21
    }
22
23
    /**
24
     * Show the account dashboard.
25
     *
26
     * @return \Illuminate\View\View
27
     */
28
    public function dashboard()
29
    {
30
        $accountModel=new AccountModel();
31
        $info=$accountModel->detail(Auth::user()->id);
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
32
        $feed=$accountModel->feed(Auth::user()->id);
33
        $extraInfo=Auth::user()->getExtra(['gender', 'contact', 'school', 'country', 'location'], 100);
0 ignored issues
show
Bug introduced by
The method getExtra() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of said class. However, the method does not exist in Illuminate\Auth\GenericUser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        $extraInfo=Auth::user()->/** @scrutinizer ignore-call */ getExtra(['gender', 'contact', 'school', 'country', 'location'], 100);
Loading history...
34
        $socialiteInfo=Auth::user()->getSocialiteInfo(100);
0 ignored issues
show
Bug introduced by
The method getSocialiteInfo() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of said class. However, the method does not exist in Illuminate\Auth\GenericUser. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $socialiteInfo=Auth::user()->/** @scrutinizer ignore-call */ getSocialiteInfo(100);
Loading history...
35
        return view("account.dashboard", [
36
            'page_title'=>"DashBoard",
37
            'site_title'=>config("app.name"),
38
            'navigation'=>"DashBoard",
39
            'info'=>$info,
40
            'userView'=>false,
41
            'settingsView' => false,
42
            'feed'=>$feed,
43
            'extra_info' => $extraInfo,
44
            'extraDict' => UserExtra::$extraDict,
45
            'socialite_info' => $socialiteInfo,
46
            'socialites' => Socialite::getAvailable(),
47
        ]);
48
    }
49
50
    /**
51
     * Show the account dashboard.
52
     *
53
     * @return \Illuminate\View\View
54
     */
55
    public function settings()
56
    {
57
        $accountModel=new AccountModel();
58
        $info=$accountModel->detail(Auth::user()->id);
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
59
        if (!empty(session('last_email_send'))) {
60
            $email_cooldown=300-(time()-session('last_email_send'));
61
        }
62
        $extraInfo=Auth::user()->getExtra(['gender', 'contact', 'school', 'country', 'location'], 100);
63
        $socialiteInfo=Auth::user()->getSocialiteInfo(100);
64
        return view("account.dashboard", [
65
            'page_title'=>"Settings",
66
            'site_title'=>config("app.name"),
67
            'navigation'=>"Settings",
68
            'info'=>$info,
69
            'userView'=>false,
70
            'settingsView' => true,
71
            'email_cooldown' => $email_cooldown ?? null,
72
            'extra_info' => $extraInfo,
73
            'extraDict' => UserExtra::$extraDict,
74
            'socialite_info' => $socialiteInfo,
75
            'socialites' => Socialite::getAvailable(),
76
        ]);
77
    }
78
}
79