Completed
Push — master ( 46416a...42773f )
by Song
02:05
created

HasAssets::jQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Traits;
4
5
trait HasAssets
6
{
7
    /**
8
     * @var array
9
     */
10
    public static $script = [];
11
12
    /**
13
     * @var array
14
     */
15
    public static $css = [];
16
17
    /**
18
     * @var array
19
     */
20
    public static $js = [];
21
22
    /**
23
     * @var array
24
     */
25
    public static $baseCss = [
26
        'vendor/laravel-admin/AdminLTE/bootstrap/css/bootstrap.min.css',
27
        'vendor/laravel-admin/font-awesome/css/font-awesome.min.css',
28
        'vendor/laravel-admin/laravel-admin/laravel-admin.css',
29
        'vendor/laravel-admin/nprogress/nprogress.css',
30
        'vendor/laravel-admin/sweetalert2/dist/sweetalert2.css',
31
        'vendor/laravel-admin/nestable/nestable.css',
32
        'vendor/laravel-admin/toastr/build/toastr.min.css',
33
        'vendor/laravel-admin/bootstrap3-editable/css/bootstrap-editable.css',
34
        'vendor/laravel-admin/google-fonts/fonts.css',
35
        'vendor/laravel-admin/AdminLTE/dist/css/AdminLTE.min.css',
36
    ];
37
38
    /**
39
     * @var array
40
     */
41
    public static $baseJs = [
42
        'vendor/laravel-admin/AdminLTE/bootstrap/js/bootstrap.min.js',
43
        'vendor/laravel-admin/AdminLTE/plugins/slimScroll/jquery.slimscroll.min.js',
44
        'vendor/laravel-admin/AdminLTE/dist/js/app.min.js',
45
        'vendor/laravel-admin/jquery-pjax/jquery.pjax.js',
46
        'vendor/laravel-admin/nprogress/nprogress.js',
47
        'vendor/laravel-admin/nestable/jquery.nestable.js',
48
        'vendor/laravel-admin/toastr/build/toastr.min.js',
49
        'vendor/laravel-admin/bootstrap3-editable/js/bootstrap-editable.min.js',
50
        'vendor/laravel-admin/sweetalert2/dist/sweetalert2.min.js',
51
        'vendor/laravel-admin/laravel-admin/laravel-admin.js',
52
    ];
53
54
    /**
55
     * @var string
56
     */
57
    public static $jQuery = 'vendor/laravel-admin/AdminLTE/plugins/jQuery/jQuery-2.1.4.min.js';
58
59
    /**
60
     * Add css or get all css.
61
     *
62
     * @param null $css
63
     *
64
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
65
     */
66 View Code Duplication
    public static function css($css = null)
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...
67
    {
68
        if (!is_null($css)) {
69
            self::$css = array_merge(self::$css, (array)$css);
70
71
            return;
72
        }
73
74
        static::$css = array_merge(static::$css, static::baseCss(), (array)$css);
75
76
        return view('admin::partials.css', ['css' => array_unique(static::$css)]);
77
    }
78
79
    /**
80
     * @param null $css
81
     * @return array|void
82
     */
83
    public static function baseCss($css = null)
84
    {
85
        if (!is_null($css)) {
86
            static::$baseCss = $css;
87
88
            return;
89
        }
90
91
        $skin = config('admin.skin', 'skin-blue-light');
92
93
        array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");
94
95
        return static::$baseCss;
96
    }
97
98
    /**
99
     * Add js or get all js.
100
     *
101
     * @param null $js
102
     *
103
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
104
     */
105 View Code Duplication
    public static function js($js = null)
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...
106
    {
107
        if (!is_null($js)) {
108
            self::$js = array_merge(self::$js, (array)$js);
109
110
            return;
111
        }
112
113
        static::$js = array_merge(static::baseJs(), static::$js, (array)$js);
114
115
        return view('admin::partials.js', ['js' => array_unique(static::$js)]);
116
    }
117
118
    /**
119
     * @param null $js
120
     * @return array|void
121
     */
122
    public static function baseJs($js = null)
123
    {
124
        if (!is_null($js)) {
125
            static::$baseJs = $js;
126
127
            return;
128
        }
129
130
        return static::$baseJs;
131
    }
132
133
    /**
134
     * @param string $script
135
     *
136
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
137
     */
138
    public static function script($script = '')
139
    {
140
        if (!empty($script)) {
141
            self::$script = array_merge(self::$script, (array)$script);
142
143
            return;
144
        }
145
146
        return view('admin::partials.script', ['script' => array_unique(self::$script)]);
147
    }
148
149
    /**
150
     * @return string
151
     */
152
    public function jQuery()
153
    {
154
        return admin_asset(static::$jQuery);
155
    }
156
}