CoursesController::edit()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 26
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 26
rs 8.5806
cc 4
eloc 23
nc 4
nop 0
1
<?php
2
3
class CoursesController extends \BaseController {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    public function __construct(Course $course)
6
    {
7
        $this->course = $course;
8
    }
9
10
    /**
11
     * Show the form for creating a new resource.
12
     *
13
     * @return Response
14
     */
15
    public function index()
16
    {
17
        $data = $this->course->all();
18
        return $data;
19
    }
20
21
    /**
22
     * Store a newly created resource in storage.
23
     *
24
     * @return Response
25
     */
26
    public function store()
27
    {
28
        //
29
    }
30
31
    /**
32
     * Display the specified resource.
33
     *
34
     * @param  int  $id
35
     * @return Response
36
     */
37
    public function show($id)
38
    {
39
        return Course::find($id)->get();
40
    }
41
42
    /**
43
     * Show the form for editing the specified resource.
44
     *
45
     * @param  int  $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
46
     * @return Response
47
     */
48
    public function edit()
49
    {
50
		$operation = Input::get('oper');
51
        switch ($operation) {
52
        case "add":
53
            $this->course->name = Input::get('name');
54
			$this->course->par = Input::get('par');
55
			$this->course->rating = Input::get('rating');
56
			$this->course->slope = Input::get('slope');
57
            $this->course->save();
58
            break;
59
        case "edit":
60
            $id = Input::get('id');
61
            $this->course = $this->course->find($id);
62
            $this->course->name = Input::get('name');
63
			$this->course->par = Input::get('par');
64
			$this->course->rating = Input::get('rating');
65
			$this->course->slope = Input::get('slope');
66
            $this->course->save();
67
            break;
68
        case "del":
69
            $id = Input::get('id');
70
            $this->course = $this->course->destroy($id);
71
            break;
72
        }
73
    }
74
75
    /**
76
     * Update the specified resource in storage.
77
     *
78
     * @param  int  $id
79
     * @return Response
80
     */
81
    public function update($id)
82
    {
83
        //
84
    }
85
86
    /**
87
     * Remove the specified resource from storage.
88
     *
89
     * @param  int  $id
90
     * @return Response
91
     */
92
    public function destroy($id)
93
    {
94
        //
95
    }
96
97
}