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

EventRestAPIController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
dl 0
loc 68
rs 10
c 1
b 0
f 1
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 3 1
A store() 0 4 1
A __construct() 0 4 1
A destroy() 0 5 1
A show() 0 3 1
A update() 0 4 1
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers\API\Restful;
4
5
use Adminetic\Website\Models\Admin\Event;
6
use Adminetic\Website\Http\Requests\EventRequest;
7
use App\Http\Controllers\Controller;
8
use Adminetic\Website\Contracts\EventRepositoryInterface;
9
10
class EventRestAPIController extends Controller
11
{
12
13
    protected $eventRepositoryInterface;
14
15
    public function __construct(EventRepositoryInterface $eventRepositoryInterface)
16
    {
17
        $this->eventRepositoryInterface = $eventRepositoryInterface;
18
        $this->authorizeResource(Event::class, 'event');
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->eventRepositoryInterface->indexEvent(), 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json(...ace->indexEvent(), 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\EventRequest  $request
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function store(EventRequest $request)
38
    {
39
        $event = $this->eventRepositoryInterface->storeEvent($request);
40
        return response()->json($event, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($event, 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\Event  $event
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function show(Event $event)
50
    {
51
        return response()->json($event, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($event, 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\EventRequest  $request
58
     * @param  \Adminetic\Website\Models\Admin\Event  $event
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function update(EventRequest $request, Event $event)
62
    {
63
        $this->eventRepositoryInterface->updateEvent($request, $event);
64
        return response()->json($event, 200);
0 ignored issues
show
Bug Best Practice introduced by
The expression return response()->json($event, 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\Event  $event
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function destroy(Event $event)
74
    {
75
        $deleted_item = $event;
76
        $event->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