AuthorsController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A posts() 0 5 1
A validator() 0 6 1
1
<?php
2
3
namespace App\Http\Controllers\Api\V1;
4
5
use Illuminate\Http\Request;
6
7
use App\Models\Post;
8
use App\Models\Author;
9
10
use Validator;
11
12
class AuthorsController extends BaseController
13
{
14
    protected $model = \App\Models\Author::class;
15
16
17
    /**
18
     * Get author by ID w/ its posts.
19
     *
20
     * @param int $id
21
     * @return \Illuminate\Http\Response
22
     */
23
    public function posts($id)
24
    {
25
        $author = Author::with('posts')->findOrFail($id);
26
27
        return $author;
28
    }
29
30
    /**
31
     * Get store validator.
32
     *
33
     * @param \Illuminate\Http\Request $request
34
     * @return \Illuminate\Validation\Validator
35
     */
36
    protected function validator(Request $request)
37
    {
38
        return Validator::make($request->all(), [
39
            'first_name' => 'required|alpha|max:255',
40
            'last_name' => 'required|alpha|max:255',
41
            'about' => 'required|max:255',
42
            //
43
        ]);
44
    }
45
}
46