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

ImageRestAPIController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers\API\Restful;
4
5
use Adminetic\Website\Models\Admin\Image;
6
use Adminetic\Website\Http\Requests\ImageRequest;
7
use App\Http\Controllers\Controller;
8
use Adminetic\Website\Contracts\ImageRepositoryInterface;
9
10
class ImageRestAPIController extends Controller
11
{
12
13
    protected $imageRepositoryInterface;
14
15
    public function __construct(ImageRepositoryInterface $imageRepositoryInterface)
16
    {
17
        $this->imageRepositoryInterface = $imageRepositoryInterface;
18
        $this->authorizeResource(Image::class, 'image');
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->imageRepositoryInterface->indexImage(), 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json(...ace->indexImage(), 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\ImageRequest  $request
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function store(ImageRequest $request)
38
    {
39
        $image = $this->imageRepositoryInterface->storeImage($request);
40
        return response()->json($image, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($image, 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\Image  $image
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function show(Image $image)
50
    {
51
        return response()->json($image, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($image, 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\ImageRequest  $request
58
     * @param  \Adminetic\Website\Models\Admin\Image  $image
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function update(ImageRequest $request, Image $image)
62
    {
63
        $this->imageRepositoryInterface->updateImage($request, $image);
64
        return response()->json($image, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($image, 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\Image  $image
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function destroy(Image $image)
74
    {
75
        $deleted_item = $image;
76
        $image->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