TagController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Modules\Blog\Http\Controllers\Api;
2
3
use Illuminate\Routing\Controller;
4
use Illuminate\Support\Facades\App;
5
use Illuminate\Support\Facades\Response;
6
use Modules\Blog\Http\Requests\CreateTagRequest;
7
use Modules\Blog\Repositories\TagRepository;
8
9
class TagController extends Controller
10
{
11
    /**
12
     * @var TagRepository
13
     */
14
    private $tag;
15
16
    public function __construct(TagRepository $tag)
17
    {
18
        $this->tag = $tag;
19
    }
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return Response
25
     */
26
    public function index()
27
    {
28
        return $this->tag->all();
29
    }
30
31
    /**
32
     * Show the form for creating a new resource.
33
     *
34
     * @return Response
35
     */
36
    public function create()
37
    {
38
        return \View::make('collection.create');
39
    }
40
41
    /**
42
     * Store a newly created resource in storage.
43
     *
44
     * @param  CreateTagRequest $request
45
     * @return Response
46
     */
47
    public function store(CreateTagRequest $request)
48
    {
49
        $tag = $this->tag->createForLanguage(App::getLocale(), $request->name);
50
51
        return Response::json($tag);
52
    }
53
54
    /**
55
     * Find the resource by name
56
     *
57
     * @param $name
58
     * @return Response
59
     */
60
    public function findByName($name)
61
    {
62
        return Response::json($this->tag->findByName($name));
63
    }
64
}
65