Passed
Push — develop ( a18085...de8258 )
by Francisco
14:47
created

CourseController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 11
loc 11
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Judite\Models\Course;
6
use Illuminate\Support\Facades\DB;
7
8
class CourseController extends Controller
9
{
10
    /**
11
     * Create a new controller instance.
12
     */
13
    public function __construct()
14
    {
15
        $this->middleware('auth');
16
        $this->middleware('can.student');
17
        $this->middleware('student.verified');
18
    }
19
20
    /**
21
     * Display a listing of the resource.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25 View Code Duplication
    public function index()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $courses = DB::transaction(function () {
28
            return Course::orderedList()->get();
29
        });
30
31
        $courses = $courses->groupBy(function ($course) {
32
            return $course->present()->getOrdinalYear();
33
        });
34
35
        return view('courses.index', compact('courses'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('courses.index', compact('courses')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
36
    }
37
}
38