|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD; |
|
4
|
|
|
|
|
5
|
|
|
use Backpack\Basset\Facades\Basset; |
|
6
|
|
|
use Backpack\CRUD\app\Http\Middleware\EnsureEmailVerification; |
|
|
|
|
|
|
7
|
|
|
use Backpack\CRUD\app\Http\Middleware\ThrottlePasswordRecovery; |
|
8
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel; |
|
9
|
|
|
use Backpack\CRUD\app\Library\Database\DatabaseSchema; |
|
10
|
|
|
use Backpack\CRUD\app\Library\Uploaders\Support\UploadersRepository; |
|
11
|
|
|
use Illuminate\Contracts\Debug\ExceptionHandler; |
|
12
|
|
|
use Illuminate\Routing\Router; |
|
13
|
|
|
use Illuminate\Support\Collection; |
|
14
|
|
|
use Illuminate\Support\Facades\Blade; |
|
15
|
|
|
use Illuminate\Support\ServiceProvider; |
|
16
|
|
|
use Illuminate\Support\Str; |
|
17
|
|
|
use Illuminate\View\Compilers\BladeCompiler; |
|
18
|
|
|
|
|
19
|
|
|
class BackpackServiceProvider extends ServiceProvider |
|
20
|
|
|
{ |
|
21
|
|
|
use Stats; |
|
22
|
|
|
|
|
23
|
|
|
protected $commands = [ |
|
24
|
|
|
app\Console\Commands\Install::class, |
|
25
|
|
|
app\Console\Commands\AddMenuContent::class, |
|
26
|
|
|
app\Console\Commands\AddCustomRouteContent::class, |
|
27
|
|
|
app\Console\Commands\Version::class, |
|
28
|
|
|
app\Console\Commands\CreateUser::class, |
|
29
|
|
|
app\Console\Commands\PublishBackpackMiddleware::class, |
|
30
|
|
|
app\Console\Commands\PublishView::class, |
|
31
|
|
|
app\Console\Commands\Addons\RequireDevTools::class, |
|
32
|
|
|
app\Console\Commands\Addons\RequireEditableColumns::class, |
|
33
|
|
|
app\Console\Commands\Addons\RequirePro::class, |
|
34
|
|
|
app\Console\Commands\Themes\RequireThemeTabler::class, |
|
35
|
|
|
app\Console\Commands\Themes\RequireThemeCoreuiv2::class, |
|
36
|
|
|
app\Console\Commands\Themes\RequireThemeCoreuiv4::class, |
|
37
|
|
|
app\Console\Commands\Fix::class, |
|
38
|
|
|
app\Console\Commands\PublishHeaderMetas::class, |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
// Indicates if loading of the provider is deferred. |
|
42
|
|
|
protected $defer = false; |
|
43
|
|
|
|
|
44
|
|
|
// Where the route file lives, both inside the package and in the app (if overwritten). |
|
45
|
|
|
public $routeFilePath = '/routes/backpack/base.php'; |
|
46
|
|
|
|
|
47
|
|
|
// Where custom routes can be written, and will be registered by Backpack. |
|
48
|
|
|
public $customRoutesFilePath = '/routes/backpack/custom.php'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Perform post-registration booting of services. |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
public function boot(Router $router) |
|
|
|
|
|
|
56
|
|
|
{ |
|
57
|
|
|
$this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); |
|
58
|
|
|
$this->loadConfigs(); |
|
59
|
|
|
$this->registerMiddlewareGroup($this->app->router); |
|
|
|
|
|
|
60
|
|
|
$this->setupRoutes($this->app->router); |
|
61
|
|
|
$this->setupCustomRoutes($this->app->router); |
|
|
|
|
|
|
62
|
|
|
$this->publishFiles(); |
|
63
|
|
|
$this->sendUsageStats(); |
|
64
|
|
|
|
|
65
|
|
|
Basset::addViewPath(realpath(__DIR__.'/resources/views')); |
|
66
|
|
|
|
|
67
|
|
|
Basset::map('bp-jquery', 'https://unpkg.com/[email protected]/dist/jquery.min.js', ['integrity' => 'sha384-i61gTtaoovXtAbKjo903+O55Jkn2+RtzHtvNez+yI49HAASvznhe9sZyjaSHTau9', 'crossorigin' => 'anonymous']); |
|
68
|
|
|
Basset::map('bp-popper-js', 'https://unpkg.com/@popperjs/[email protected]/dist/umd/popper.min.js', ['integrity' => 'sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3', 'crossorigin' => 'anonymous']); |
|
69
|
|
|
Basset::map('bp-summernote-css', 'https://unpkg.com/[email protected]/dist/summernote-lite.min.css', ['integrity' => 'sha384-vmPR5F5DxvnVZxuw9+hxaSj8MDX3rP49GZu/JvPS1qYD2xeg+0TGJUJ/H6e/HTkV', 'crossorigin' => 'anonymous']); |
|
70
|
|
|
Basset::map('bp-summernote-woof', 'https://unpkg.com/[email protected]/dist/font/summernote.woff2', ['integrity' => 'sha384-jin6VSG0kKkHctWc/DhVx2PL8YqVcnWvrAcqrTkLdi9evxi77MNjsgSUqbNGWijo', 'crossorigin' => 'anonymous']); |
|
71
|
|
|
Basset::map('bp-datatables-js', 'https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js', ['integrity' => 'sha384-t11ZTRbO9om+k0pVXmc3c8SsIHonT3oUvoi3FxMm1c9DVQwl9VbTNv3+UjbUrI6Z', 'crossorigin' => 'anonymous']); |
|
72
|
|
|
Basset::map('bp-datatables-bootstrap-js', 'https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js', ['integrity' => 'sha384-bHpoWS7HfBjbqWmqPFVsEwT0EyCKgMw/hbKswCjYLSLS+TyPUAG51MTMIXgy/4Pl', 'crossorigin' => 'anonymous']); |
|
73
|
|
|
Basset::map('bp-datatables-bootstrap-css', 'https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css', ['integrity' => 'sha384-GADhaOJCr6lsUqdHJnYcH/QaARzVT92beGzAYxLTSoxUorHjQZci1FW+X9BqbnE3', 'crossorigin' => 'anonymous']); |
|
74
|
|
|
Basset::map('bp-datatables-responsive-js', 'https://cdn.datatables.net/responsive/2.4.0/js/dataTables.responsive.min.js', ['integrity' => 'sha384-yYqZ2Jue83rlzHS23Jp/xwZjRZ9KQCACGR5lhhWFtDIQeBMwAuav+irRqSKrucSP', 'crossorigin' => 'anonymous']); |
|
75
|
|
|
Basset::map('bp-datatables-responsive-css', 'https://cdn.datatables.net/responsive/2.4.0/css/responsive.dataTables.min.css', ['integrity' => 'sha384-cWgz6YKDgXz/mTomsnOIXd/1s0iivK+FhwVdmzN0ErdazMmt4RieKmZXMWdwScEm', 'crossorigin' => 'anonymous']); |
|
76
|
|
|
Basset::map('bp-datatables-fixedheader-js', 'https://cdn.datatables.net/fixedheader/3.3.1/js/dataTables.fixedHeader.min.js', ['integrity' => 'sha384-PeR7ate8YuUE8EYJp3d9zNrgSm9jFJL1b2Hrb8Za0RtVj6YMU8IZlyBwlRjiXq0i', 'crossorigin' => 'anonymous']); |
|
77
|
|
|
Basset::map('bp-datatables-fixedheader-css', 'https://cdn.datatables.net/fixedheader/3.3.1/css/fixedHeader.dataTables.min.css', ['integrity' => 'sha384-g0QDiyi3I9zPzO1O8mvkZd0/MWDKDs8Lk+pHQo3+kkTJEFTdzDCwjqIuoOG+yG0q', 'crossorigin' => 'anonymous']); |
|
78
|
|
|
Basset::map('bp-datatables-buttons-bs5-css', 'https://cdn.datatables.net/buttons/2.3.3/css/buttons.bootstrap5.min.css', ['integrity' => 'sha384-vLlNBaHuV6cqBlVjiJITSKkzOaeomPYdKV54KsyxIF88PDfOKqDRzlHSe5FVMe/4', 'crossorigin' => 'anonymous']); |
|
79
|
|
|
Basset::map('bp-datatables-dt-buttons-bs5-js', 'https://cdn.datatables.net/buttons/2.3.3/js/dataTables.buttons.min.js', ['integrity' => 'sha384-4UCu2Y40paen66DRD9HqMQTQDFzPOPrHQQ3Hj3il7NOYMVE9+8PKV9YqrNjOvB+G', 'crossorigin' => 'anonymous']); |
|
80
|
|
|
Basset::map('bp-datatables-buttons-bs5-js', 'https://cdn.datatables.net/buttons/2.3.3/js/buttons.bootstrap5.min.js', ['integrity' => 'sha384-ydNsKc6RC3ZCjn9sUZuBlPsIf/bBKmjNuYZZzBTvNag/JKDcIlRstd/eU+ZifNxM', 'crossorigin' => 'anonymous']); |
|
81
|
|
|
Basset::map('bp-datatables-jszip', 'https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js', ['integrity' => 'sha384-yib/J8n+cev8VyEYY+4A3nSvnqCRhEkxUQhVFp8X+YuIXd0qhT3rTYXqel0zWzni', 'crossorigin' => 'anonymous']); |
|
82
|
|
|
Basset::map('bp-datatables-pdfmake', 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.18/pdfmake.min.js', ['integrity' => 'sha384-7B0GkWcyEmGJnsHkE0Z0cCpXaUS9i1tFM1/e0jAKoxA2YkI2XYaZdCOJo0kBBsS5', 'crossorigin' => 'anonymous']); |
|
83
|
|
|
Basset::map('bp-datatables-pdfmake-fonts', 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.18/vfs_fonts.js', ['integrity' => 'sha384-Zu5dDR1DhOW4Qpz55vgv84xMQSt0V2nX/rGj309pIyhOnc2KHssTcYszIjiYUjYL', 'crossorigin' => 'anonymous']); |
|
84
|
|
|
Basset::map('bp-datatables-html5-button', 'https://cdn.datatables.net/buttons/2.3.2/js/buttons.html5.min.js', ['integrity' => 'sha384-+KP6ruIqPlKDSU+EJ+oMlSh7cUCDWe2rHFaGVL4iHG4plXJaco2DetEl6yOrugqf', 'crossorigin' => 'anonymous']); |
|
85
|
|
|
Basset::map('bp-datatables-print-button', 'https://cdn.datatables.net/buttons/2.3.2/js/buttons.print.min.js', ['integrity' => 'sha384-5MVvNT5w7ht9uU89ZuYPDHs3Yap4hV/h/cPjiKBHdbS2pDKuY4ADmve/XwXN5oPQ', 'crossorigin' => 'anonymous']); |
|
86
|
|
|
Basset::map('bp-datatables-colvis-button', 'https://cdn.datatables.net/buttons/2.3.2/js/buttons.colVis.min.js', ['integrity' => 'sha384-iWhT+VbS/XoLnEHwlRhpwgeNPjEFIs88MypVWxe99IVGqXljIX4vdFLr3fAbRGHM', 'crossorigin' => 'anonymous']); |
|
87
|
|
|
Basset::map('bp-urijs', 'https://unpkg.com/[email protected]/src/URI.min.js', ['integrity' => 'sha384-VS1T95+I9NZNIjvlP0D/3HRlU1sKmoBzh71Pt08ckCdxEM2++7QEdbbp/3gi20js', 'crossorigin' => 'anonymous']); |
|
88
|
|
|
Basset::map('bp-highlight-js', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js', ['integrity' => 'sha512-gU7kztaQEl7SHJyraPfZLQCNnrKdaQi5ndOyt4L4UPL/FHDd/uB9Je6KDARIqwnNNE27hnqoWLBq+Kpe4iHfeQ==', 'crossorigin' => 'anonymous']); |
|
89
|
|
|
Basset::map('bp-highlight-css', 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/base16/dracula.min.css', ['integrity' => 'sha512-GfRggx2Wc+POEPR0asMTNTyNug3rWJ9Jp4wxnHZ5VApMOUJRK4cEaRriXsx5tV1DakKHQWQ2noCbuzFiPJaYqA==', 'crossorigin' => 'anonymous']); |
|
90
|
|
|
Basset::map('bp-animate-css', 'https://unpkg.com/[email protected]/animate.compat.css', ['integrity' => 'sha384-B6emdNLLuHwwngyCsBGzzo6MQPmSygQu5cG4lfUfdSxzj0FJVJZu+7GOmB8/NHpd', 'crossorigin' => 'anonymous']); |
|
91
|
|
|
Basset::map('bp-noty-css', 'https://unpkg.com/[email protected]/lib/noty.css', ['integrity' => 'sha384-J/zBMo8aKN23nuimkvPbkLpGS1Uf1eCha++IoQfNVUpYCjvkuzLqO9nc4wizNAsv', 'crossorigin' => 'anonymous']); |
|
92
|
|
|
Basset::map('bp-lineawesome-css', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/css/line-awesome.min.css', ['integrity' => 'sha512-vebUliqxrVkBy3gucMhClmyQP9On/HAWQdKDXRaAlb/FKuTbxkjPKUyqVOxAcGwFDka79eTF+YXwfke1h3/wfg==', 'crossorigin' => 'anonymous']); |
|
93
|
|
|
Basset::map('bp-lineawesome-regular-400', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-regular-400.woff2', ['integrity' => 'sha384-2MTGaE1Ew+cNL5I7ilrE0E2sXLiuf90OL5DDceb5boJQOSLbVZCEHWpUPpvdOF4Z', 'crossorigin' => 'anonymous']); |
|
94
|
|
|
Basset::map('bp-lineawesome-solid-900', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-solid-900.woff2', ['integrity' => 'sha384-6Y7zlEnVxM1wRcJx7qtpAK54L2QoP4CcAaosx1EKa3QOLvq0LjT7Fus7E9IDidgR', 'crossorigin' => 'anonymous']); |
|
95
|
|
|
Basset::map('bp-lineawesome-brands-400', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-brands-400.woff2', ['integrity' => 'sha384-4EZZRKjFRNbc6sX193USv6Is1dJHSHzcGtijtyeUV2KQFRhVgpeWsrebTKu7RKEl', 'crossorigin' => 'anonymous']); |
|
96
|
|
|
Basset::map('bp-lineawesome-regular-400-woff', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-regular-400.woff', ['integrity' => 'sha384-Pu6x4bfCQDro/gELWySVvZ04SlesuYt1QlQH2zvv1i43+7E6HkUIGGOixPLtP3XX', 'crossorigin' => 'anonymous']); |
|
97
|
|
|
Basset::map('bp-lineawesome-solid-900-woff', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-solid-900.woff', ['integrity' => 'sha384-Ik+er7DjVwGt6ex3J05QtimAVRCq1JxCWf+t5n7fW80EAQS99uIIk+FJfIRy8sSN', 'crossorigin' => 'anonymous']); |
|
98
|
|
|
Basset::map('bp-lineawesome-brands-400-woff', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-brands-400.woff', ['integrity' => 'sha384-gamww7YJnsFRoFVACJb6kLAoK2emK2ZIuoZgyvBM4kaEPEu3xDE/ivmXQmrYKp+l', 'crossorigin' => 'anonymous']); |
|
99
|
|
|
Basset::map('bp-lineawesome-regular-400-ttf', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-regular-400.ttf', ['integrity' => 'sha384-1zzwN3v7UDtBGkTNjIFcNTy1U3dQTa5nix6OaV0CY5YXqxhlXDm0dum9bWOfpbqF', 'crossorigin' => 'anonymous']); |
|
100
|
|
|
Basset::map('bp-lineawesome-solid-900-ttf', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-solid-900.ttf', ['integrity' => 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-solid-900.ttf', 'crossorigin' => 'anonymous']); |
|
101
|
|
|
Basset::map('bp-lineawesome-brands-400-ttf', 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-brands-400.ttf', ['integrity' => 'https://cdnjs.cloudflare.com/ajax/libs/line-awesome/1.3.0/line-awesome/fonts/la-brands-400.ttf', 'crossorigin' => 'anonymous']); |
|
102
|
|
|
Basset::map('bp-summernote-js', 'https://unpkg.com/[email protected]/dist/summernote-lite.min.js', ['integrity' => 'sha384-fq3mhgSZ+13XGKx7olcZUFWes9hDmAR3b/WnNLKH6fRFsHonf6CGG+Dj1wypCgLq', 'crossorigin' => 'anonymous']); |
|
103
|
|
|
Basset::map('bp-noty-js', 'https://unpkg.com/[email protected]/lib/noty.min.js', ['integrity' => 'sha384-z7oxDqgQB0ThPzpmEjy9pcQT5oLRWvagLjZypnMIdKqBBLLvKNINZdifoEEPmrn1', 'crossorigin' => 'anonymous']); |
|
104
|
|
|
Basset::map('bp-sweet-alert-js', 'https://unpkg.com/[email protected]/dist/sweetalert.min.js', ['integrity' => 'sha384-RIQuldGV8mnjGdob13cay/K1AJa+LR7VKHqSXrrB5DPGryn4pMUXRLh92Ev8KlGF', 'crossorigin' => 'anonymous']); |
|
105
|
|
|
Basset::map('bp-bootstrap4-js', 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.min.js', ['integrity' => 'sha512-7rusk8kGPFynZWu26OKbTeI+QPoYchtxsmPeBqkHIEXJxeun4yJ4ISYe7C6sz9wdxeE1Gk3VxsIWgCZTc+vX3g==', 'crossorigin' => 'anonymous']); |
|
106
|
|
|
Basset::map('bp-bootstrap5-js', 'https://unpkg.com/[email protected]/dist/js/bootstrap.min.js', ['integrity' => 'sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V', 'crossorigin' => 'anonymous']); |
|
107
|
|
|
|
|
108
|
|
|
foreach (config('backpack.ui.styles', []) as $style) { |
|
109
|
|
|
if (is_array($style)) { |
|
110
|
|
|
foreach ($style as $file) { |
|
111
|
|
|
Basset::map($file); |
|
112
|
|
|
} |
|
113
|
|
|
} else { |
|
114
|
|
|
Basset::map($style); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
foreach (config('backpack.ui.scripts', []) as $script) { |
|
119
|
|
|
if (is_array($script)) { |
|
120
|
|
|
foreach ($script as $file) { |
|
121
|
|
|
Basset::map($file); |
|
122
|
|
|
} |
|
123
|
|
|
} else { |
|
124
|
|
|
Basset::map($script); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Register any package services. |
|
131
|
|
|
* |
|
132
|
|
|
* @return void |
|
133
|
|
|
*/ |
|
134
|
|
|
public function register() |
|
135
|
|
|
{ |
|
136
|
|
|
// load the macros |
|
137
|
|
|
include_once __DIR__.'/macros.php'; |
|
138
|
|
|
|
|
139
|
|
|
$this->loadViewsWithFallbacks('crud'); |
|
140
|
|
|
$this->loadViewsWithFallbacks('ui', 'backpack.ui'); |
|
141
|
|
|
$this->loadViewNamespace('widgets', 'backpack.ui::widgets'); |
|
142
|
|
|
$this->loadViewComponents(); |
|
143
|
|
|
|
|
144
|
|
|
$this->registerBackpackErrorViews(); |
|
145
|
|
|
|
|
146
|
|
|
// Bind the CrudPanel object to Laravel's service container |
|
147
|
|
|
$this->app->scoped('crud', function ($app) { |
|
|
|
|
|
|
148
|
|
|
return new CrudPanel(); |
|
149
|
|
|
}); |
|
150
|
|
|
|
|
151
|
|
|
$this->app->scoped('DatabaseSchema', function ($app) { |
|
|
|
|
|
|
152
|
|
|
return new DatabaseSchema(); |
|
153
|
|
|
}); |
|
154
|
|
|
|
|
155
|
|
|
$this->app->singleton('BackpackViewNamespaces', function ($app) { |
|
|
|
|
|
|
156
|
|
|
return new ViewNamespaces(); |
|
157
|
|
|
}); |
|
158
|
|
|
|
|
159
|
|
|
// Bind the widgets collection object to Laravel's service container |
|
160
|
|
|
$this->app->singleton('widgets', function ($app) { |
|
|
|
|
|
|
161
|
|
|
return new Collection(); |
|
162
|
|
|
}); |
|
163
|
|
|
|
|
164
|
|
|
$this->app->scoped('UploadersRepository', function ($app) { |
|
|
|
|
|
|
165
|
|
|
return new UploadersRepository(); |
|
166
|
|
|
}); |
|
167
|
|
|
|
|
168
|
|
|
// register the helper functions |
|
169
|
|
|
$this->loadHelpers(); |
|
170
|
|
|
|
|
171
|
|
|
// register the artisan commands |
|
172
|
|
|
$this->commands($this->commands); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public function registerMiddlewareGroup(Router $router) |
|
176
|
|
|
{ |
|
177
|
|
|
$middleware_key = config('backpack.base.middleware_key'); |
|
178
|
|
|
$middleware_class = config('backpack.base.middleware_class'); |
|
179
|
|
|
|
|
180
|
|
|
if (! is_array($middleware_class)) { |
|
181
|
|
|
$router->pushMiddlewareToGroup($middleware_key, $middleware_class); |
|
182
|
|
|
|
|
183
|
|
|
return; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
foreach ($middleware_class as $middleware_class) { |
|
187
|
|
|
$router->pushMiddlewareToGroup($middleware_key, $middleware_class); |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
// register internal backpack middleware for throttling the password recovery functionality |
|
191
|
|
|
// but only if functionality is enabled by developer in config |
|
192
|
|
|
if (config('backpack.base.setup_password_recovery_routes')) { |
|
193
|
|
|
$router->aliasMiddleware('backpack.throttle.password.recovery', ThrottlePasswordRecovery::class); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
// register the email verification middleware, if the developer enabled it in the config. |
|
197
|
|
|
if (config('backpack.base.setup_email_verification_routes', false) && config('backpack.base.setup_email_verification_middleware', true)) { |
|
198
|
|
|
$router->pushMiddlewareToGroup($middleware_key, EnsureEmailVerification::class); |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function publishFiles() |
|
203
|
|
|
{ |
|
204
|
|
|
$backpack_views = [__DIR__.'/resources/views' => resource_path('views/vendor/backpack')]; |
|
205
|
|
|
$backpack_lang_files = [__DIR__.'/resources/lang' => app()->langPath().'/vendor/backpack']; |
|
|
|
|
|
|
206
|
|
|
$backpack_config_files = [__DIR__.'/config' => config_path()]; |
|
207
|
|
|
|
|
208
|
|
|
// sidebar content views, which are the only views most people need to overwrite |
|
209
|
|
|
$backpack_menu_contents_view = [ |
|
210
|
|
|
__DIR__.'/resources/views/ui/inc/menu_items.blade.php' => resource_path('views/vendor/backpack/ui/inc/menu_items.blade.php'), |
|
211
|
|
|
]; |
|
212
|
|
|
$backpack_custom_routes_file = [__DIR__.$this->customRoutesFilePath => base_path($this->customRoutesFilePath)]; |
|
213
|
|
|
|
|
214
|
|
|
// calculate the path from current directory to get the vendor path |
|
215
|
|
|
$vendorPath = dirname(__DIR__, 3); |
|
216
|
|
|
$gravatar_assets = [$vendorPath.'/creativeorange/gravatar/config' => config_path()]; |
|
217
|
|
|
|
|
218
|
|
|
// establish the minimum amount of files that need to be published, for Backpack to work; there are the files that will be published by the install command |
|
219
|
|
|
$minimum = array_merge( |
|
220
|
|
|
// $backpack_views, |
|
221
|
|
|
// $backpack_lang_files, |
|
222
|
|
|
$backpack_config_files, |
|
223
|
|
|
$backpack_menu_contents_view, |
|
224
|
|
|
$backpack_custom_routes_file, |
|
225
|
|
|
$gravatar_assets |
|
226
|
|
|
); |
|
227
|
|
|
|
|
228
|
|
|
// register all possible publish commands and assign tags to each |
|
229
|
|
|
$this->publishes($backpack_config_files, 'config'); |
|
230
|
|
|
$this->publishes($backpack_lang_files, 'lang'); |
|
231
|
|
|
$this->publishes($backpack_views, 'views'); |
|
232
|
|
|
$this->publishes($backpack_menu_contents_view, 'menu_contents'); |
|
233
|
|
|
$this->publishes($backpack_custom_routes_file, 'custom_routes'); |
|
234
|
|
|
$this->publishes($gravatar_assets, 'gravatar'); |
|
235
|
|
|
$this->publishes($minimum, 'minimum'); |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* Define the routes for the application. |
|
240
|
|
|
* |
|
241
|
|
|
* @param Router $router |
|
242
|
|
|
* @return void |
|
243
|
|
|
*/ |
|
244
|
|
|
public function setupRoutes(Router $router) |
|
|
|
|
|
|
245
|
|
|
{ |
|
246
|
|
|
// by default, use the routes file provided in vendor |
|
247
|
|
|
$routeFilePathInUse = __DIR__.$this->routeFilePath; |
|
248
|
|
|
|
|
249
|
|
|
// but if there's a file with the same name in routes/backpack, use that one |
|
250
|
|
|
if (file_exists(base_path().$this->routeFilePath)) { |
|
251
|
|
|
$routeFilePathInUse = base_path().$this->routeFilePath; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
$this->loadRoutesFrom($routeFilePathInUse); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* Load custom routes file. |
|
259
|
|
|
* |
|
260
|
|
|
* @param Router $router |
|
261
|
|
|
* @return void |
|
262
|
|
|
*/ |
|
263
|
|
|
public function setupCustomRoutes(Router $router) |
|
|
|
|
|
|
264
|
|
|
{ |
|
265
|
|
|
// if the custom routes file is published, register its routes |
|
266
|
|
|
if (file_exists(base_path().$this->customRoutesFilePath)) { |
|
267
|
|
|
$this->loadRoutesFrom(base_path().$this->customRoutesFilePath); |
|
268
|
|
|
} |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
public function loadViewNamespace($domain, $namespace) |
|
272
|
|
|
{ |
|
273
|
|
|
ViewNamespaces::addFor($domain, $namespace); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
public function loadViewsWithFallbacks($dir, $namespace = null) |
|
277
|
|
|
{ |
|
278
|
|
|
$customFolder = resource_path('views/vendor/backpack/'.$dir); |
|
279
|
|
|
$vendorFolder = realpath(__DIR__.'/resources/views/'.$dir); |
|
280
|
|
|
$namespace = $namespace ?? $dir; |
|
281
|
|
|
|
|
282
|
|
|
// first the published/overwritten views (in case they have any changes) |
|
283
|
|
|
if (file_exists($customFolder)) { |
|
284
|
|
|
$this->loadViewsFrom($customFolder, $namespace); |
|
285
|
|
|
} |
|
286
|
|
|
// then the stock views that come with the package, in case a published view might be missing |
|
287
|
|
|
$this->loadViewsFrom($vendorFolder, $namespace); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
protected function mergeConfigsFromDirectory($dir) |
|
291
|
|
|
{ |
|
292
|
|
|
$configs = scandir(__DIR__."/config/backpack/$dir/"); |
|
293
|
|
|
$configs = array_diff($configs, ['.', '..']); |
|
294
|
|
|
|
|
295
|
|
|
if (! count($configs)) { |
|
296
|
|
|
return; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
foreach ($configs as $configFile) { |
|
300
|
|
|
$this->mergeConfigFrom( |
|
301
|
|
|
__DIR__."/config/backpack/$dir/$configFile", |
|
302
|
|
|
"backpack.$dir.".substr($configFile, 0, strrpos($configFile, '.')) |
|
303
|
|
|
); |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
public function loadConfigs() |
|
308
|
|
|
{ |
|
309
|
|
|
// use the vendor configuration file as fallback |
|
310
|
|
|
$this->mergeConfigFrom(__DIR__.'/config/backpack/crud.php', 'backpack.crud'); |
|
311
|
|
|
$this->mergeConfigFrom(__DIR__.'/config/backpack/base.php', 'backpack.base'); |
|
312
|
|
|
$this->mergeConfigFrom(__DIR__.'/config/backpack/ui.php', 'backpack.ui'); |
|
313
|
|
|
$this->mergeConfigsFromDirectory('operations'); |
|
314
|
|
|
|
|
315
|
|
|
// add the root disk to filesystem configuration |
|
316
|
|
|
app()->config['filesystems.disks.'.config('backpack.base.root_disk_name')] = [ |
|
317
|
|
|
'driver' => 'local', |
|
318
|
|
|
'root' => base_path(), |
|
319
|
|
|
]; |
|
320
|
|
|
|
|
321
|
|
|
/* |
|
322
|
|
|
* Backpack login differs from the standard Laravel login. |
|
323
|
|
|
* As such, Backpack uses its own authentication provider, password broker and guard. |
|
324
|
|
|
* |
|
325
|
|
|
* THe process below adds those configuration values on top of whatever is in config/auth.php. |
|
326
|
|
|
* Developers can overwrite the backpack provider, password broker or guard by adding a |
|
327
|
|
|
* provider/broker/guard with the "backpack" name inside their config/auth.php file. |
|
328
|
|
|
* Or they can use another provider/broker/guard entirely, by changing the corresponding |
|
329
|
|
|
* value inside config/backpack/base.php |
|
330
|
|
|
*/ |
|
331
|
|
|
|
|
332
|
|
|
// add the backpack_users authentication provider to the configuration |
|
333
|
|
|
app()->config['auth.providers'] = app()->config['auth.providers'] + |
|
334
|
|
|
[ |
|
335
|
|
|
'backpack' => [ |
|
336
|
|
|
'driver' => 'eloquent', |
|
337
|
|
|
'model' => config('backpack.base.user_model_fqn'), |
|
338
|
|
|
], |
|
339
|
|
|
]; |
|
340
|
|
|
|
|
341
|
|
|
// add the backpack_users password broker to the configuration |
|
342
|
|
|
$laravelAuthPasswordBrokers = app()->config['auth.passwords']; |
|
343
|
|
|
$laravelFirstPasswordBroker = is_array($laravelAuthPasswordBrokers) && current($laravelAuthPasswordBrokers) ? |
|
344
|
|
|
current($laravelAuthPasswordBrokers)['table'] : |
|
345
|
|
|
''; |
|
346
|
|
|
|
|
347
|
|
|
$backpackPasswordBrokerTable = config('backpack.base.password_resets_table') ?? |
|
348
|
|
|
config('auth.passwords.users.table') ?? |
|
349
|
|
|
$laravelFirstPasswordBroker; |
|
350
|
|
|
|
|
351
|
|
|
app()->config['auth.passwords'] = $laravelAuthPasswordBrokers + |
|
352
|
|
|
[ |
|
353
|
|
|
'backpack' => [ |
|
354
|
|
|
'provider' => 'backpack', |
|
355
|
|
|
'table' => $backpackPasswordBrokerTable, |
|
356
|
|
|
'expire' => config('backpack.base.password_recovery_token_expiration', 60), |
|
357
|
|
|
'throttle' => config('backpack.base.password_recovery_throttle_notifications'), |
|
358
|
|
|
], |
|
359
|
|
|
]; |
|
360
|
|
|
|
|
361
|
|
|
// add the backpack_users guard to the configuration |
|
362
|
|
|
app()->config['auth.guards'] = app()->config['auth.guards'] + |
|
363
|
|
|
[ |
|
364
|
|
|
'backpack' => [ |
|
365
|
|
|
'driver' => 'session', |
|
366
|
|
|
'provider' => 'backpack', |
|
367
|
|
|
], |
|
368
|
|
|
]; |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
public function loadViewComponents() |
|
372
|
|
|
{ |
|
373
|
|
|
$this->app->afterResolving(BladeCompiler::class, function () { |
|
374
|
|
|
Blade::componentNamespace('Backpack\\CRUD\\app\\View\\Components', 'backpack'); |
|
375
|
|
|
}); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
/** |
|
379
|
|
|
* Load the Backpack helper methods, for convenience. |
|
380
|
|
|
*/ |
|
381
|
|
|
public function loadHelpers() |
|
382
|
|
|
{ |
|
383
|
|
|
require_once __DIR__.'/helpers.php'; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* Get the services provided by the provider. |
|
388
|
|
|
* |
|
389
|
|
|
* @return array |
|
390
|
|
|
*/ |
|
391
|
|
|
public function provides() |
|
392
|
|
|
{ |
|
393
|
|
|
return ['crud', 'widgets', 'BackpackViewNamespaces', 'DatabaseSchema', 'UploadersRepository']; |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
private function registerBackpackErrorViews() |
|
397
|
|
|
{ |
|
398
|
|
|
// register the backpack error when the exception handler is resolved from the container |
|
399
|
|
|
$this->callAfterResolving(ExceptionHandler::class, function ($handler) { |
|
|
|
|
|
|
400
|
|
|
if (! Str::startsWith(request()->path(), config('backpack.base.route_prefix'))) { |
|
401
|
|
|
return; |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
// parse the namespaces set in config |
|
405
|
|
|
[$themeNamespace, $themeFallbackNamespace] = (function () { |
|
406
|
|
|
$themeNamespace = config('backpack.ui.view_namespace'); |
|
407
|
|
|
$themeFallbackNamespace = config('backpack.ui.view_namespace_fallback'); |
|
408
|
|
|
|
|
409
|
|
|
return [ |
|
410
|
|
|
Str::endsWith($themeNamespace, '::') ? substr($themeNamespace, 0, -2) : substr($themeNamespace, 0, -1), |
|
411
|
|
|
Str::endsWith($themeFallbackNamespace, '::') ? substr($themeFallbackNamespace, 0, -2) : substr($themeFallbackNamespace, 0, -1), |
|
412
|
|
|
]; |
|
413
|
|
|
})(); |
|
414
|
|
|
|
|
415
|
|
|
$viewFinderHints = app('view')->getFinder()->getHints(); |
|
416
|
|
|
|
|
417
|
|
|
// here we are going to generate the paths array containing: |
|
418
|
|
|
// - theme paths |
|
419
|
|
|
// - fallback theme paths |
|
420
|
|
|
// - ui path |
|
421
|
|
|
$themeErrorPaths = $viewFinderHints[$themeNamespace] ?? []; |
|
422
|
|
|
$themeErrorPaths = $themeNamespace === $themeFallbackNamespace ? $themeErrorPaths : |
|
423
|
|
|
array_merge($viewFinderHints[$themeFallbackNamespace] ?? [], $themeErrorPaths); |
|
424
|
|
|
$uiErrorPaths = [base_path('vendor/backpack/crud/src/resources/views/ui')]; |
|
425
|
|
|
$themeErrorPaths = array_merge($themeErrorPaths, $uiErrorPaths); |
|
426
|
|
|
|
|
427
|
|
|
// merge the paths array with the view.paths defined in the application |
|
428
|
|
|
app('config')->set('view.paths', array_merge($themeErrorPaths, config('view.paths', []))); |
|
429
|
|
|
}); |
|
430
|
|
|
} |
|
431
|
|
|
} |
|
432
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths