Passed
Push — main ( 2e9e01...1bac82 )
by PRATIK
15:02
created

ClientRestAPIController::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers\API\Restful;
4
5
use App\Http\Controllers\Controller;
6
use Adminetic\Website\Models\Admin\Client;
7
use Adminetic\Website\Http\Requests\ClientRequest;
8
use Adminetic\Website\Contracts\ClientRepositoryInterface;
9
10
class ClientRestAPIController extends Controller
11
{
12
13
    protected $clientRepositoryInterface;
14
15
    public function __construct(ClientRepositoryInterface $clientRepositoryInterface)
16
    {
17
        $this->clientRepositoryInterface = $clientRepositoryInterface;
18
        $this->authorizeResource(Client::class, 'client');
19
    }
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return \Illuminate\Http\Response
25
     */
26
    public function index()
27
    {
28
        return response()->json($this->clientRepositoryInterface->indexClient(), 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json(...ce->indexClient(), 200) returns the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
29
    }
30
31
    /**
32
     * Store a newly created resource in storage.
33
     *
34
     * @param  \Adminetic\Website\Http\Requests\ClientRequest  $request
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function store(ClientRequest $request)
38
    {
39
        $client = $this->clientRepositoryInterface->storeClient($request);
40
        return response()->json($client, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($client, 200) returns the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
41
    }
42
43
    /**
44
     * Display the specified resource.
45
     *
46
     * @param  \Adminetic\Website\Models\Admin\Client  $client
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function show(Client $client)
50
    {
51
        return response()->json($client, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($client, 200) returns the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
52
    }
53
54
    /**
55
     * Update the specified resource in storage.
56
     *
57
     * @param  \Adminetic\Website\Http\Requests\ClientRequest  $request
58
     * @param  \Adminetic\Website\Models\Admin\Client  $client
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function update(ClientRequest $request, Client $client)
62
    {
63
        $this->clientRepositoryInterface->updateClient($request, $client);
64
        return response()->json($client, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($client, 200) returns the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
65
    }
66
67
    /**
68
     * Remove the specified resource from storage.
69
     *
70
     * @param  \Adminetic\Website\Models\Admin\Client  $client
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function destroy(Client $client)
74
    {
75
        $deleted_item = $client;
76
        $client->delete();
77
        return response()->json($deleted_item, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($deleted_item, 200) returns the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
78
    }
79
}
80