APIUserEventsController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Acacha\Events\Http\Controllers;
4
5
use Acacha\Events\Http\Requests\UserStoreEvent;
6
use Acacha\Events\Models\Event;
7
use Auth;
8
9
/**
10
 * Class APIUserEventsController.
11
 *
12
 * @package App\Http\Controllers
13
 */
14
class APIUserEventsController extends Controller
15
{
16
    /**
17
     * Show list of events.
18
     *
19
     * @return \Illuminate\Database\Eloquent\Collection|static[]
20
     */
21
    public function index()
22
    {
23
        return Auth::user()->events;
24
    }
25
26
    /**
27
     * Store event for logged user.
28
     *
29
     * @return \Illuminate\Database\Eloquent\Collection|static[]
30
     */
31
    public function store(UserStoreEvent $request)
32
    {
33
        $event = Event::create($request->only(['name','user_id','description']));
0 ignored issues
show
Bug introduced by
The method create() does not exist on Acacha\Events\Models\Event. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
34
        Auth::user()->events()->save($event);
35
        return $event;
36
    }
37
38
}
39