Completed
Push — master ( 3a8db8...5050df )
by Sherif
01:59
created

RoleController::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Modules\Roles\Http\Controllers;
4
5
use App\Modules\Core\BaseClasses\BaseApiController;
6
use App\Modules\Roles\Repositories\RoleRepository;
7
use App\Modules\Roles\Http\Requests\AssignPermissions;
8
use App\Modules\Roles\Http\Requests\InsertRole;
9
use App\Modules\Roles\Http\Requests\UpdateRole;
10
11
class RoleController extends BaseApiController
12
{
13
    /**
14
     * Init new object.
15
     *
16
     * @param   RoleRepository $repo
17
     * @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...
18
     */
19
    public function __construct(RoleRepository $repo)
20
    {
21
        parent::__construct($repo, 'App\Modules\Roles\Http\Resources\Role');
22
    }
23
24
    /**
25
     * Insert the given model to storage.
26
     *
27
     * @param InsertRole $request
28
     * @return \Illuminate\Http\Response
29
     */
30
    public function insert(InsertRole $request)
31
    {
32
        return new $this->modelResource($this->repo->save($request->all()));
33
    }
34
35
    /**
36
     * Update the given model to storage.
37
     *
38
     * @param UpdateRole $request
39
     * @return \Illuminate\Http\Response
40
     */
41
    public function update(UpdateRole $request)
42
    {
43
        return new $this->modelResource($this->repo->save($request->all()));
44
    }
45
46
    /**
47
     * Handle an assign permissions to role request.
48
     *
49
     * @param  AssignPermissions $request
50
     * @return \Illuminate\Http\Response
51
     */
52
    public function assignPermissions(AssignPermissions $request)
53
    {
54
        return new $this->modelResource($this->repo->assignPermissions($request->get('role_id'), $request->get('permission_ids')));
55
    }
56
}
57