Completed
Pull Request — master (#2905)
by
unknown
02:26
created

HasAssets::headerJs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 12
loc 12
rs 9.8666
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
     *
82
     * @return array|void
83
     */
84
    public static function baseCss($css = null)
85
    {
86
        if (!is_null($css)) {
87
            static::$baseCss = $css;
88
89
            return;
90
        }
91
92
        $skin = config('admin.skin', 'skin-blue-light');
93
94
        array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");
95
96
        return static::$baseCss;
97
    }
98
99
    /**
100
     * Add js or get all js.
101
     *
102
     * @param null $js
103
     *
104
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
105
     */
106 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...
107
    {
108
        if (!is_null($js)) {
109
            self::$js = array_merge(self::$js, (array) $js);
110
111
            return;
112
        }
113
114
        static::$js = array_merge(static::baseJs(), static::$js, (array) $js);
115
116
        return view('admin::partials.js', ['js' => array_unique(static::$js)]);
117
    }
118
119
    /**
120
     * @param null $js
121
     *
122
     * @return array|void
123
     */
124
    public static function baseJs($js = null)
125
    {
126
        if (!is_null($js)) {
127
            static::$baseJs = $js;
128
129
            return;
130
        }
131
132
        return static::$baseJs;
133
    }
134
135
    /**
136
     * @param string $script
137
     *
138
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
139
     */
140
    public static function script($script = '')
141
    {
142
        if (!empty($script)) {
143
            self::$script = array_merge(self::$script, (array) $script);
144
145
            return;
146
        }
147
148
        return view('admin::partials.script', ['script' => array_unique(self::$script)]);
149
    }
150
151
    /**
152
     * @return string
153
     */
154
    public function jQuery()
155
    {
156
        return admin_asset(static::$jQuery);
157
    }
158
}
159