Completed
Pull Request — master (#63)
by Phecho
04:21
created

MomentController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 22
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 22
loc 22
rs 9.2
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 * 
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Http\Controllers\Dashboard;
13
14
use Gitamin\Models\Moment;
15
use Illuminate\Routing\Controller;
16
use Illuminate\Support\Facades\View;
17
18
class MomentController extends Controller
19
{
20
    /**
21
     * Display a listing of the resource.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25
26
    /**
27
     * Array of sub-menu items.
28
     *
29
     * @var array
30
     */
31
    protected $subMenu = [];
32
33
    /**
34
     * Creates a new moment controller instance.
35
     *
36
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
37
     */
38 View Code Duplication
    public function __construct()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $this->subMenu = [
41
            'moments' => [
42
                'title'  => trans('dashboard.projects.yours'),
43
                'url'    => route('dashboard.moments.index'),
44
                'icon'   => 'fa fa-sliders',
45
                'active' => false,
46
            ],
47
            'project_update' => [
48
                'title'  => trans('dashboard.projects.starred'),
49
                'url'    => route('dashboard.moments.index'),
50
                'icon'   => 'fa fa-edit',
51
                'active' => false,
52
            ],
53
        ];
54
55
        View::share([
56
            'sub_menu'  => $this->subMenu,
57
            'sub_title' => trans_choice('dashboard.moments.moments', 2),
58
        ]);
59
    }
60
61
    public function index()
62
    {
63
        $moments = Moment::recent()->get();
0 ignored issues
show
Bug introduced by
The method recent() does not exist on Gitamin\Models\Moment. Did you maybe mean scopeRecent()?

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...
64
        $this->subMenu['moments']['active'] = true;
65
66
        return View::make('dashboard.moments.index')
67
            ->withPageTitle('Moments')
68
            ->withMoments($moments)
69
            ->withSubMenu($this->subMenu);
70
    }
71
}
72