1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Modules\Acl\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Modules\Core\BaseClasses\BaseApiController; |
6
|
|
|
use App\Modules\Acl\Repositories\OauthClientRepository; |
7
|
|
|
use App\Modules\Core\Utl\CoreConfig; |
8
|
|
|
use App\Modules\Core\Http\Resources\General as GeneralResource; |
9
|
|
|
use App\Modules\Acl\Http\Requests\InsertOauthClient; |
10
|
|
|
use App\Modules\Acl\Http\Requests\UpdateOauthClient; |
11
|
|
|
|
12
|
|
|
class OauthClientController extends BaseApiController |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Init new object. |
16
|
|
|
* |
17
|
|
|
* @param OauthClientRepository $repo |
18
|
|
|
* @param CoreConfig $config |
19
|
|
|
* @return void |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct(OauthClientRepository $repo, CoreConfig $config) |
22
|
|
|
{ |
23
|
|
|
parent::__construct($repo, $config, 'App\Modules\Acl\Http\Resources\OauthClient'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Insert the given model to storage. |
28
|
|
|
* |
29
|
|
|
* @param InsertOauthClient $request |
30
|
|
|
* @return \Illuminate\Http\Response |
31
|
|
|
*/ |
32
|
|
|
public function insert(InsertOauthClient $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 UpdateOauthClient $request |
41
|
|
|
* @return \Illuminate\Http\Response |
42
|
|
|
*/ |
43
|
|
|
public function update(UpdateOauthClient $request) |
44
|
|
|
{ |
45
|
|
|
return new $this->modelResource($this->repo->save($request->all())); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Revoke the given client. |
50
|
|
|
* |
51
|
|
|
* @param integer $clientId Id of the client |
52
|
|
|
* @return \Illuminate\Http\Response |
53
|
|
|
*/ |
54
|
|
|
public function revoke($clientId) |
55
|
|
|
{ |
56
|
|
|
return new GeneralResource($this->repo->revoke($clientId)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Un revoke the given client. |
61
|
|
|
* |
62
|
|
|
* @param integer $clientId Id of the client |
63
|
|
|
* @return \Illuminate\Http\Response |
64
|
|
|
*/ |
65
|
|
|
public function unRevoke($clientId) |
66
|
|
|
{ |
67
|
|
|
return new GeneralResource($this->repo->unRevoke($clientId)); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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.