Completed
Push — master ( db6658...fecd46 )
by Eric
01:44
created

APIUserArticlesController::index()   A

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 Ergare17\Articles\Http\Controllers;
4
5
use Auth;
6
use Ergare17\Articles\Models\Article;
7
8
/**
9
 * Class APIUserArticlesController.
10
 *
11
 * @package App\Http\Controllers
12
 */
13
class APIUserArticlesController extends Controller
14
{
15
    /**
16
     * Show list of articles.
17
     *
18
     * @return \Illuminate\Database\Eloquent\Collection|static[]
19
     */
20
    public function index()
21
    {
22
        return Auth::user()->articles;
23
    }
24
25
    /**
26
     * Store article for logged user.
27
     *
28
     * @return \Illuminate\Database\Eloquent\Collection|static[]
29
     */
30
    public function store(UserStoreArticle $request)
31
    {
32
        $article = Article::create($request->only(['name','user_id','description']));
0 ignored issues
show
Bug introduced by
The method create() does not exist on Ergare17\Articles\Models\Article. 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...
33
        Auth::user()->articles()->save($article);
34
        return $article;
35
    }
36
37
}
38