More updates as a result of no longer using Orchestra/Asset

This commit is contained in:
Deon George 2024-07-04 17:41:31 +10:00
parent 4b541857d7
commit fd3487f9b0
2 changed files with 57 additions and 59 deletions

View File

@ -3,7 +3,6 @@
namespace Leenooks\Controllers; namespace Leenooks\Controllers;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Redirect; use Redirect;
use Session; use Session;
@ -57,6 +56,6 @@ class SwitchUserController extends Controller
if ($user = Session::pull('orig_user')) if ($user = Session::pull('orig_user'))
Auth::login($user); Auth::login($user);
return Redirect::to(RouteServiceProvider::HOME); return Redirect::to('/home');
} }
} }

View File

@ -5,7 +5,6 @@ namespace Leenooks\Providers;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Orchestra\Support\Facades\Asset;
class CustomBladeServiceProvider extends ServiceProvider class CustomBladeServiceProvider extends ServiceProvider
{ {
@ -37,48 +36,49 @@ class CustomBladeServiceProvider extends ServiceProvider
} }
$return = collect(); $return = collect();
$urls = collect(); $css = collect();
$js = collect();
switch ($type) { switch ($type) {
case 'datatables': case 'datatables':
switch ($content) { switch ($content) {
case 'css': case 'css':
// Base // Base
$urls->put($type,'https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css'); $css->put($type,'https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css');
foreach ($arguments as $option) { foreach ($arguments as $option) {
$key = $type.':'.$option; $key = $type.':'.$option;
switch ($option) { switch ($option) {
case 'bootstrap4': case 'bootstrap4':
$urls->put($key,'/plugin/dataTables/dataTables.bootstrap4.css'); $css->put($key,'/plugin/dataTables/dataTables.bootstrap4.css');
break; break;
case 'buttons': case 'buttons':
$urls->put($key,'https://cdn.datatables.net/buttons/1.6.5/css/buttons.dataTables.min.css'); $css->put($key,'https://cdn.datatables.net/buttons/1.6.5/css/buttons.dataTables.min.css');
break; break;
case 'fixedheader': case 'fixedheader':
$urls->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/css/fixedHeader.dataTables.min.css'); $css->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/css/fixedHeader.dataTables.min.css');
break; break;
case 'rowgroup': case 'rowgroup':
$urls->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/css/rowGroup.dataTables.min.css'); $css->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/css/rowGroup.dataTables.min.css');
break; break;
case 'responsive': case 'responsive':
$urls->put($key,'http://cdn.datatables.net/responsive/2.2.6/css/responsive.dataTables.min.css'); $css->put($key,'http://cdn.datatables.net/responsive/2.2.6/css/responsive.dataTables.min.css');
break; break;
case 'searchpanes': case 'searchpanes':
$urls->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/css/searchPanes.dataTables.min.css'); $css->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/css/searchPanes.dataTables.min.css');
break; break;
case 'searchpanes-left': case 'searchpanes-left':
$urls->put('searchpanes:searchpanes-left','/plugin/dataTables/leftSearchPanes.css'); $css->put('searchpanes:searchpanes-left','/plugin/dataTables/leftSearchPanes.css');
break; break;
case 'select': case 'select':
$urls->put($key,'https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css'); $css->put($key,'https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css');
break; break;
default: default:
@ -90,40 +90,40 @@ class CustomBladeServiceProvider extends ServiceProvider
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js'); $js->put($type,'https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js');
foreach ($arguments as $option) { foreach ($arguments as $option) {
$key = $type.':'.$option; $key = $type.':'.$option;
switch ($option) { switch ($option) {
case 'bootstrap4': case 'bootstrap4':
$urls->put($key,'/plugin/dataTables/dataTables.bootstrap4.js'); $js->put($key,'/plugin/dataTables/dataTables.bootstrap4.js');
break; break;
case 'buttons': case 'buttons':
$urls->put($key,'https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js'); $js->put($key,'https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js');
$urls->put($key.'html5','https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js'); $js->put($key.'html5','https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js');
$urls->put($key.'jszip','https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js'); $js->put($key.'jszip','https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js');
break; break;
case 'fixedheader': case 'fixedheader':
$urls->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/js/dataTables.fixedHeader.min.js'); $js->put($key,'https://cdn.datatables.net/fixedheader/3.1.7/js/dataTables.fixedHeader.min.js');
break; break;
case 'responsive': case 'responsive':
$urls->put($key,'https://cdn.datatables.net/responsive/2.2.6/js/dataTables.responsive.min.js'); $js->put($key,'https://cdn.datatables.net/responsive/2.2.6/js/dataTables.responsive.min.js');
break; break;
case 'rowgroup': case 'rowgroup':
$urls->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/js/dataTables.rowGroup.min.js'); $js->put($key,'https://cdn.datatables.net/rowgroup/1.1.2/js/dataTables.rowGroup.min.js');
break; break;
case 'searchpanes': case 'searchpanes':
$urls->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/js/dataTables.searchPanes.min.js'); $js->put($key,'https://cdn.datatables.net/searchpanes/1.2.1/js/dataTables.searchPanes.min.js');
break; break;
case 'select': case 'select':
$urls->put($key,'https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js'); $js->put($key,'https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js');
break; break;
default: default:
@ -137,11 +137,11 @@ class CustomBladeServiceProvider extends ServiceProvider
case 'datepick': case 'datepick':
switch ($content) { switch ($content) {
case 'css': case 'css':
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css'); $css->put($type,'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css');
break; break;
case 'js': case 'js':
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js'); $js->put($type,'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js');
} }
break; break;
@ -149,7 +149,7 @@ class CustomBladeServiceProvider extends ServiceProvider
case 'debounce': case 'debounce':
switch ($content) { switch ($content) {
case 'js': case 'js':
$urls->put($type,'js/debounce.js'); $js->put($type,'js/debounce.js');
} }
break; break;
@ -158,49 +158,49 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://code.highcharts.com/highcharts.js'); $js->put($type,'https://code.highcharts.com/highcharts.js');
foreach ($arguments as $option) { foreach ($arguments as $option) {
$key = $type.':'.$option; $key = $type.':'.$option;
switch ($option) { switch ($option) {
case '3d': case '3d':
$urls->put($key,'https://code.highcharts.com/highcharts-3d.js'); $js->put($key,'https://code.highcharts.com/highcharts-3d.js');
$urls->put($key.'mouseover','/plugin/highcharts/3dmouseover.js'); $js->put($key.'mouseover','/plugin/highcharts/3dmouseover.js');
break; break;
case 'data': case 'data':
$urls->put($key,'https://code.highcharts.com/modules/data.js'); $js->put($key,'https://code.highcharts.com/modules/data.js');
break; break;
case 'defaults': case 'defaults':
$urls->put($key,'/plugin/highcharts/defaults.js'); $js->put($key,'/plugin/highcharts/defaults.js');
break; break;
case 'drilldown': case 'drilldown':
$urls->put($key,'https://code.highcharts.com/modules/drilldown.js'); $js->put($key,'https://code.highcharts.com/modules/drilldown.js');
break; break;
case 'export': case 'export':
$urls->put($key,'https://code.highcharts.com/modules/exporting.js'); $js->put($key,'https://code.highcharts.com/modules/exporting.js');
$urls->put($key.'data','https://code.highcharts.com/modules/export-data.js'); $js->put($key.'data','https://code.highcharts.com/modules/export-data.js');
break; break;
case 'funnel': case 'funnel':
$urls->put($key,'https://code.highcharts.com/modules/funnel.js'); $js->put($key,'https://code.highcharts.com/modules/funnel.js');
break; break;
case 'heatmap': case 'heatmap':
$urls->put($key,'https://code.highcharts.com/modules/heatmap.js'); $js->put($key,'https://code.highcharts.com/modules/heatmap.js');
break; break;
case 'solidguage': case 'solidguage':
$urls->put($key,'https://code.highcharts.com/highcharts-more.js'); $js->put($key,'https://code.highcharts.com/highcharts-more.js');
$urls->put($key.'accessiblity','https://code.highcharts.com/modules/accessibility.js'); $js->put($key.'accessiblity','https://code.highcharts.com/modules/accessibility.js');
$urls->put($key.'solid-guage','https://code.highcharts.com/modules/solid-gauge.js'); $js->put($key.'solid-guage','https://code.highcharts.com/modules/solid-gauge.js');
break; break;
case 'theme-dark': case 'theme-dark':
$urls->put($key,'https://code.highcharts.com/themes/dark-unica.js'); $js->put($key,'https://code.highcharts.com/themes/dark-unica.js');
break; break;
default: default:
@ -215,17 +215,17 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://code.highcharts.com/stock/highstock.js'); $js->put($type,'https://code.highcharts.com/stock/highstock.js');
foreach ($arguments as $option) { foreach ($arguments as $option) {
$key = $type.':'.$option; $key = $type.':'.$option;
switch ($option) { switch ($option) {
case 'data': case 'data':
$urls->put($key,'https://code.highcharts.com/stock/modules/data.js'); $js->put($key,'https://code.highcharts.com/stock/modules/data.js');
break; break;
case 'export': case 'export':
$urls->put($key,'https://code.highcharts.com/stock/modules/exporting.js'); $js->put($key,'https://code.highcharts.com/stock/modules/exporting.js');
break; break;
default: default:
@ -240,19 +240,19 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'css': case 'css':
// Base // Base
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css'); $css->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css');
break; break;
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js'); $js->put($type,'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js');
foreach ($arguments as $option) { foreach ($arguments as $option) {
$key = $type.':'.$option; $key = $type.':'.$option;
switch ($option) { switch ($option) {
case 'autofocus': case 'autofocus':
$urls->put($key,'plugin/select2/fix-autofocus.js'); $js->put($key,'plugin/select2/fix-autofocus.js');
break; break;
default: default:
@ -267,13 +267,13 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'css': case 'css':
// Base // Base
$urls->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css'); $css->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css');
break; break;
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js'); $js->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js');
} }
break; break;
@ -282,13 +282,13 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'css': case 'css':
// Base // Base
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-bs4.css'); $css->put($type,'https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-bs4.css');
break; break;
case 'js': case 'js':
// Base // Base
$urls->put($type,'https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-bs4.js'); $js->put($type,'https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-bs4.js');
} }
break; break;
@ -297,8 +297,8 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($content) { switch ($content) {
case 'js': case 'js':
// Base // Base
$urls->put('validate','https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/jquery.validate.min.js'); $js->put('validate','https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/jquery.validate.min.js');
$urls->put('validate.additional','https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/additional-methods.min.js'); $js->put('validate.additional','https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/additional-methods.min.js');
} }
break; break;
@ -307,13 +307,12 @@ class CustomBladeServiceProvider extends ServiceProvider
throw new \Exception(sprintf('Unknown Expression: [%s]',$expression)); throw new \Exception(sprintf('Unknown Expression: [%s]',$expression));
} }
if ($urls->count()) if ($js->count())
return $urls->map(function($item,$key) { $return = $return->merge($js->map(fn($item)=>sprintf('<script type="text/javascript" src="%s">',$item)));
$dependancy='';
if (str_contains($key,':'))
[$dependancy,$key] = explode(':',$key);
return "<?php Asset::add('$key','$item','$dependancy'); ?>"; if ($css->count())
})->join(''); $return = $return->merge($css->map(fn($item)=>sprintf('<link rel="stylesheet" href="%s">',$item)));
return $return->join('');
} }
} }