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

GalleryRestAPIController::store()   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 1
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 Adminetic\Website\Models\Admin\Gallery;
6
use Adminetic\Website\Http\Requests\GalleryRequest;
7
use App\Http\Controllers\Controller;
8
use Adminetic\Website\Contracts\GalleryRepositoryInterface;
9
10
class GalleryRestAPIController extends Controller
11
{
12
13
    protected $galleryRepositoryInterface;
14
15
    public function __construct(GalleryRepositoryInterface $galleryRepositoryInterface)
16
    {
17
        $this->galleryRepositoryInterface = $galleryRepositoryInterface;
18
        $this->authorizeResource(Gallery::class, 'gallery');
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->galleryRepositoryInterface->indexGallery(), 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json(...e->indexGallery(), 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\GalleryRequest  $request
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function store(GalleryRequest $request)
38
    {
39
        $gallery = $this->galleryRepositoryInterface->storeGallery($request);
40
        return response()->json($gallery, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($gallery, 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\Gallery  $gallery
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function show(Gallery $gallery)
50
    {
51
        return response()->json($gallery, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($gallery, 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\GalleryRequest  $request
58
     * @param  \Adminetic\Website\Models\Admin\Gallery  $gallery
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function update(GalleryRequest $request, Gallery $gallery)
62
    {
63
        $this->galleryRepositoryInterface->updateGallery($request, $gallery);
64
        return response()->json($gallery, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($gallery, 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\Gallery  $gallery
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function destroy(Gallery $gallery)
74
    {
75
        $deleted_item = $gallery;
76
        $gallery->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