PageController::home()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php namespace Mascame\Artificer\Http\Controllers;
2
3
use App;
4
use Mascame\Artificer\Options\AdminOption;
5
use Redirect;
6
7
class PageController extends BaseController
8
{
9
10
    public function home()
11
    {
12
        $hiddenModels = AdminOption::get('models.hidden');
13
14
        $nonHiddenModels = array_diff(array_keys($this->modelObject->schema->models), $hiddenModels);
15
16
        $firstModel = head($nonHiddenModels);
17
18
        return Redirect::route('admin.model.all',
0 ignored issues
show
Bug introduced by
The method route() does not seem to exist on object<redirect>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
            array('slug' => $this->modelObject->schema->models[$firstModel]['route']));
20
    }
21
22
    public function install()
23
    {
24
        $this->modelObject = App::make('artificer-model');
25
26
        try {
27
            $user = \User::firstOrFail();
28
29
            // We check if there are users
30
            if ($user) {
31
                App::abort(404);
32
            }
33
34
        } catch (\Exception $e) {
35
            $this->shareMainViewData();
36
37
            $user = new \User();
38
            $user->role = 'admin';
39
40
            \Auth::login($user);
41
42
            return \View::make($this->getView('install'))
43
                ->with('plugins', App::make('ArtificerPluginManager')->getAll());
44
//			dd('install process... here we will scan models, maybe help with config and first user setup');
45
        }
46
47
48
    }
49
50
}