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

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