Completed
Push — master ( eb2586...ec2395 )
by Sherif
01:59
created

GroupController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Modules\Acl\Http\Controllers;
4
5
use App\Modules\Core\BaseClasses\BaseApiController;
6
use App\Modules\Acl\Repositories\GroupRepository;
7
use App\Modules\Core\Utl\CoreConfig;
8
use App\Modules\Acl\Http\Requests\AssignPermissions;
9
use App\Modules\Acl\Http\Requests\InsertGroup;
10
use App\Modules\Acl\Http\Requests\UpdateGroup;
11
12 View Code Duplication
class GroupController extends BaseApiController
0 ignored issues
show
Duplication introduced by
This class 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...
13
{
14
    /**
15
     * Init new object.
16
     *
17
     * @param   GroupRepository $repo
18
     * @param   CoreConfig      $config
19
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct(GroupRepository $repo, CoreConfig $config)
22
    {
23
        parent::__construct($repo, $config, 'App\Modules\Acl\Http\Resources\AclGroup');
24
    }
25
26
    /**
27
     * Insert the given model to storage.
28
     *
29
     * @param InsertGroup $request
30
     * @return \Illuminate\Http\Response
31
     */
32
    public function insert(InsertGroup $request)
33
    {
34
        return new $this->modelResource($this->repo->save($request->all()));
35
    }
36
37
    /**
38
     * Update the given model to storage.
39
     *
40
     * @param UpdateGroup $request
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function update(UpdateGroup $request)
44
    {
45
        return new $this->modelResource($this->repo->save($request->all()));
46
    }
47
48
    /**
49
     * Handle an assign permissions to group request.
50
     *
51
     * @param  AssignPermissions $request
52
     * @return \Illuminate\Http\Response
53
     */
54
    public function assignPermissions(AssignPermissions $request)
55
    {
56
        return new $this->modelResource($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')));
57
    }
58
}
59