These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Admin; |
||
13 | |||
14 | use Gitamin\Models\Project; |
||
15 | use Illuminate\Routing\Controller; |
||
16 | use Illuminate\Support\Facades\Session; |
||
17 | use Illuminate\Support\Facades\View; |
||
18 | |||
19 | class DashboardController extends Controller |
||
20 | { |
||
21 | /** |
||
22 | * Creates a new settings controller instance. |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | View Code Duplication | public function __construct() |
|
0 ignored issues
–
show
|
|||
27 | { |
||
28 | $this->subMenu = [ |
||
29 | 'overview' => [ |
||
30 | 'title' => 'Overview', |
||
31 | 'url' => route('admin.index'), |
||
32 | 'icon' => 'fa fa-wrench', |
||
33 | 'active' => false, |
||
34 | ], |
||
35 | 'general' => [ |
||
36 | 'title' => trans('admin.settings.general.general'), |
||
37 | 'url' => route('admin.settings.general'), |
||
38 | 'icon' => 'fa fa-gear', |
||
39 | 'active' => false, |
||
40 | ], |
||
41 | 'theme' => [ |
||
42 | 'title' => trans('admin.settings.theme.theme'), |
||
43 | 'url' => route('admin.settings.theme'), |
||
44 | 'icon' => 'fa fa-list-alt', |
||
45 | 'active' => false, |
||
46 | ], |
||
47 | 'stylesheet' => [ |
||
48 | 'title' => trans('admin.settings.stylesheet.stylesheet'), |
||
49 | 'url' => route('admin.settings.stylesheet'), |
||
50 | 'icon' => 'fa fa-magic', |
||
51 | 'active' => false, |
||
52 | ], |
||
53 | 'localization' => [ |
||
54 | 'title' => trans('admin.settings.localization.localization'), |
||
55 | 'url' => route('admin.settings.localization'), |
||
56 | 'icon' => 'fa fa-language', |
||
57 | 'active' => false, |
||
58 | ], |
||
59 | 'timezone' => [ |
||
60 | 'title' => trans('admin.settings.timezone.timezone'), |
||
61 | 'url' => route('admin.settings.timezone'), |
||
62 | 'icon' => 'fa fa-calendar', |
||
63 | 'active' => false, |
||
64 | ], |
||
65 | ]; |
||
66 | |||
67 | View::share([ |
||
68 | 'sub_title' => trans('admin.admin'), |
||
69 | 'sub_menu' => $this->subMenu, |
||
70 | ]); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Display a listing of the resource. |
||
75 | * |
||
76 | * @return \Illuminate\Http\Response |
||
77 | */ |
||
78 | public function indexAction() |
||
79 | { |
||
80 | $this->subMenu['overview']['active'] = true; |
||
81 | |||
82 | Session::flash('redirect_to', $this->subMenu['general']['url']); |
||
83 | |||
84 | $projects = Project::orderBy('created_at')->get(); |
||
85 | |||
86 | $projects = Project::get(); |
||
87 | $issues = []; |
||
88 | $subscribers = []; |
||
89 | |||
90 | return View::make('admin.index') |
||
91 | ->withPageTitle(trans('admin.admin')) |
||
92 | ->withProjects($projects) |
||
93 | ->withIssues($issues) |
||
94 | ->withSubscribers($subscribers) |
||
95 | ->withSubMenu($this->subMenu); |
||
96 | } |
||
97 | } |
||
98 |
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.