MainController::oldRedirect()   A
last analyzed

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\Eloquent\Announcement;
15
use App\Models\ProblemModel;
16
use App\Models\Eloquent\Carousel;
17
use App\Http\Controllers\Controller;
18
use Illuminate\Http\Request;
19
use Auth;
20
use Log;
21
use Redirect;
22
use Cache;
23
/**
24
 * Main Controller of NOJ
25
 *
26
 * @category NOJ
27
 * @package  MainController
28
 * @author   John Zhang <[email protected]>
29
 * @license  https://github.com/ZsgsDesign/NOJ/blob/master/LICENSE MIT
30
 * @link     https://github.com/ZsgsDesign/NOJ/ GitHub
31
 */
32
class MainController extends Controller
33
{
34
    /**
35
     * Show the Home Page.
36
     *
37
     * @param Request $request your web request
38
     *
39
     * @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...
40
     */
41
    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

41
    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...
42
    {
43
        $problem=new ProblemModel();
44
        $ojs=$problem->ojs();
45
        // Log::debug(["info"=>"User Viewed Home!"]);
46
        return view('home', [
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('home', arra...d_at', 'desc')->get())) returns the type Illuminate\View\View which is incompatible with the documented return type App\Http\Controllers\Response.
Loading history...
47
            'page_title'=>"Home",
48
            'site_title'=>config("app.name"),
49
            'navigation' => "Home",
50
            'announcements' => Announcement::orderBy('created_at', 'desc')->get(),
51
            'ojs' => $ojs,
52
            'carousel' => Carousel::where('available', 1)->orderBy('updated_at', 'desc')->get()
53
        ]);
54
    }
55
56
57
    public function oldRedirect(Request $request)
58
    {
59
        $all_data=$request->all();
60
        $method=isset($all_data["method"]) ? $all_data["method"] : null;
61
        $id=isset($all_data["id"]) ? $all_data["id"] : null;
62
        if ($method=="showdetail" && !is_null($id)) {
63
            $problemModel=new ProblemModel();
64
            return ($problemModel->existPCode("NOJ$id")) ?Redirect::route('problem.detail', ['pcode' => "NOJ$id"]) : Redirect::route('problem.index');
65
        }
66
        return Redirect::route('home');
67
    }
68
}
69