Passed
Push — master ( ddd100...a995c1 )
by John
05:34
created

AccountController::settings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 2
nop 0
dl 0
loc 17
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use App\Models\AccountModel;
7
use Auth;
8
9
class AccountController extends Controller
10
{
11
    /**
12
     * Show the account index.
13
     *
14
     * @return \Illuminate\View\View
15
     */
16
    public function index()
17
    {
18
        return Auth::check() ? redirect("/account/dashboard") : redirect("/login");
0 ignored issues
show
Bug Best Practice introduced by
The expression return Auth::check() ? r...') : redirect('/login') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\View\View.
Loading history...
19
    }
20
21
    /**
22
     * Show the account dashboard.
23
     *
24
     * @return \Illuminate\View\View
25
     */
26
    public function dashboard()
27
    {
28
        $accountModel=new AccountModel();
29
        $info=$accountModel->detail(Auth::user()->id);
30
        $feed=$accountModel->feed(Auth::user()->id);
31
        $extraInfo = $accountModel->getExtraInfo(Auth::user()->id,100);
32
        return view("account.dashboard", [
33
            'page_title'=>"DashBoard",
34
            'site_title'=>"NOJ",
35
            'navigation'=>"DashBoard",
36
            'info'=>$info,
37
            'userView'=>false,
38
            'settingView' => false,
39
            'feed'=>$feed,
40
            'extra_info' => $extraInfo
41
        ]);
42
    }
43
44
    public function settings()
45
    {
46
        $accountModel=new AccountModel();
47
        $info=$accountModel->detail(Auth::user()->id);
48
        if(!empty(session('last_email_send'))){
49
            $email_cooldown = 300 - (time() - session('last_email_send'));
50
        }
51
        $extraInfo = $accountModel->getExtraInfo(Auth::user()->id,100);
52
        return view("account.dashboard", [
53
            'page_title'=>"Setting",
54
            'site_title'=>"NOJ",
55
            'navigation'=>"Setting",
56
            'info'=>$info,
57
            'userView'=>false,
58
            'settingView' => true,
59
            'email_cooldown' => $email_cooldown ?? null,
60
            'extra_info' => $extraInfo
61
        ]);
62
    }
63
}
64