Completed
Push — master ( 2c87a7...c05784 )
by claudio
04:06
created

GroupsController::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace plunner\Http\Controllers\Companies\Groups;
4
5
use plunner\Company;
6
use plunner\Group;
7
use plunner\Http\Controllers\Controller;
8
use plunner\Http\Requests\Companies\GroupRequest;
9
10
11
class GroupsController extends Controller
12
{
13
    /**
14
     * ExampleController constructor.
15
     */
16 22
    public function __construct()
17
    {
18 22
        config(['auth.model' => \plunner\Company::class]);
19 22
        config(['jwt.user' => \plunner\Company::class]);
20 22
        $this->middleware('jwt.authandrefresh:mode-cn');
21 22
    }
22
23
    /**
24
     * Display a listing of the resource.
25
     *
26
     * @return \Illuminate\Http\Response
27
     */
28 2
    public function index()
29
    {
30
        //
31
        /**
32
         * @var $company Company
33
         */
34 2
        $company = \Auth::user();
35 2
        return $company->groups;
0 ignored issues
show
Documentation introduced by
The property groups does not exist on object<plunner\Company>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
36
    }
37
38
    /**
39
     * Store a newly created resource in storage.
40
     *
41
     * @param  GroupRequest  $request
42
     * @return \Illuminate\Http\Response
43
     */
44 6
    public function store(GroupRequest $request)
45
    {
46 6
        $company = \Auth::user();
47 6
        $input = $request->all();
48 6
        $group = $company->groups()->create($input);
49 6
        return $group;
50
    }
51
52
    /**
53
     * Display the specified resource.
54
     *
55
     * @param  int  $id
56
     * @return \Illuminate\Http\Response
57
     */
58 6
    public function show($id)
59
    {
60 6
        $group = Group::findOrFail($id);
61 4
        $this->authorize($group);
62 2
        return $group;
63
    }
64
65
    /**
66
     * Update the specified resource in storage.
67
     *
68
     * @param  GroupRequest  $request
69
     * @param  int  $id
70
     * @return \Illuminate\Http\Response
71
     */
72 2
    public function update(GroupRequest $request, $id)
73
    {
74 2
        $group = Group::findOrFail($id);
75 2
        $this->authorize($group);
76 2
        $input = $request->all();
77 2
        $group->update($input);
78 2
        return $group;
79
    }
80
81
    /**
82
     * Remove the specified resource from storage.
83
     *
84
     * @param  int  $id
85
     * @return \Illuminate\Http\Response
86
     */
87 4
    public function destroy($id)
88
    {
89 4
        $group = Group::findOrFail($id);
90 4
        $this->authorize($group);
91 2
        $group->delete();
92 2
        return $group;
93
    }
94
}
95