Passed
Push — master ( 16d7d8...ddcee5 )
by John
07:25 queued 11s
created

MainController::oldRedirect()   A

Complexity

Conditions 6
Paths 12

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 7
nc 12
nop 1
dl 0
loc 10
rs 9.2222
c 0
b 0
f 0
1
<?php
2
/**
3
 * File of Main Controller of NOJ
4
 * php version 7.2.10
5
 *
6
 * @category NOJ
7
 * @package  MainController
8
 * @author   John Zhang <[email protected]>
9
 * @license  https://github.com/ZsgsDesign/NOJ/blob/master/LICENSE MIT
10
 * @link     https://github.com/ZsgsDesign/NOJ/ GitHub
11
 */
12
namespace App\Http\Controllers;
13
14
use App\Models\GroupModel;
15
use App\Models\ProblemModel;
16
use App\Http\Controllers\Controller;
17
use Illuminate\Http\Request;
18
use Auth;
19
use Log;
20
use Redirect;
21
22
/**
23
 * Main Controller of NOJ
24
 *
25
 * @category NOJ
26
 * @package  MainController
27
 * @author   John Zhang <[email protected]>
28
 * @license  https://github.com/ZsgsDesign/NOJ/blob/master/LICENSE MIT
29
 * @link     https://github.com/ZsgsDesign/NOJ/ GitHub
30
 */
31
class MainController extends Controller
32
{
33
    /**
34
     * Show the Home Page.
35
     *
36
     * @param Request $request your web request
37
     *
38
     * @return Response
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
39
     */
40
    public function home(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

40
    public function home(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        $groupModel=new GroupModel();
43
        $group_notice=$groupModel->groupNotice(1);
44
        $problem=new ProblemModel();
45
        $ojs=$problem->ojs();
46
        // Log::debug(["info"=>"User Viewed Home!"]);
47
        return view('home', [
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('home', arra...notice, 'ojs' => $ojs)) returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
48
                'page_title'=>"Home",
49
                'site_title'=>"NOJ",
50
                'navigation' => "Home",
51
                'group_notice' => $group_notice,
52
                'ojs' => $ojs
53
            ]);
54
    }
55
56
    public function oldRedirect(Request $request)
57
    {
58
        $all_data=$request->all();
59
        $method=isset($all_data["method"])?$all_data["method"]:null;
60
        $id=isset($all_data["id"])?$all_data["id"]:null;
61
        if($method=="showdetail" && !is_null($id)){
62
            $problemModel=new ProblemModel();
63
            return ($problemModel->existPCode("NOJ$id"))?Redirect::route('problem_detail', ['pcode' => "NOJ$id"]):Redirect::route('problem_index');
64
        }
65
        return Redirect::route('home');
66
    }
67
}
68