Test Setup Failed
Push — master ( c48a36...2ef870 )
by Oliver
04:00
created

NestedModelsServiceProvider::macros()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Webfactor\Laravel\Backpack\NestedModels;
4
5
use Illuminate\Database\Schema\Blueprint;
6
use Illuminate\Routing\Router;
7
use Illuminate\Support\ServiceProvider;
8
9
class NestedModelsServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Perform post-registration booting of services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        // LOAD THE VIEWS
19
        $this->loadViewsFrom(resource_path('views/vendor/webfactor/nestedmodels'), 'nestedmodels');
20
        $this->loadViewsFrom(realpath(__DIR__.'/../views'), 'nestedmodels');
21
22
        $this->macros();
23
24
        $this->publish();
25
    }
26
27
    /**
28
     * Register any package services.
29
     *
30
     * @return void
31
     */
32
    public function register()
33
    {
34
        //
35
    }
36
37
    public function publish()
38
    {
39
        $this->publishes([__DIR__.'/../views' => resource_path('views/vendor/webfactor/nestedmodels')], 'views');
40
41
        $this->publishes([__DIR__.'/../public' => public_path('vendor/webfactor')], 'public');
42
    }
43
44
45
    public function macros()
46
    {
47
        Blueprint::macro('tree', function () {
48
            $this->unsignedInteger('parent_id')->nullable()->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<Webfactor\Laravel...dModelsServiceProvider>.

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...
49
            $this->unsignedInteger('lft')->default(0)->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<Webfactor\Laravel...dModelsServiceProvider>.

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...
50
            $this->unsignedInteger('rgt')->default(0)->index();
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<Webfactor\Laravel...dModelsServiceProvider>.

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...
51
            $this->unsignedInteger('depth')->default(0);
0 ignored issues
show
Bug introduced by
The method unsignedInteger() does not seem to exist on object<Webfactor\Laravel...dModelsServiceProvider>.

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...
52
53
            $this->foreign('parent_id')->references('id')->on($this->table)
0 ignored issues
show
Bug introduced by
The property table does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The method foreign() does not seem to exist on object<Webfactor\Laravel...dModelsServiceProvider>.

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...
54
                ->onUpdate('cascade')->onDelete('cascade');
55
        });
56
57
        Router::macro('tree', function($uri, $action) {
0 ignored issues
show
Unused Code introduced by
The parameter $uri is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
            //TODO
59
        });
60
    }
61
}