mirror of
https://github.com/LinkStackOrg/LinkStack.git
synced 2025-03-22 06:20:07 +01:00
Enhance AppServiceProvider with custom validation rules and Livewire script customization
This commit is contained in:
parent
3b6a8ef109
commit
6d022a409c
@ -7,6 +7,8 @@ use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Livewire\Livewire;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -27,7 +29,10 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Use Bootstrap for pagination
|
||||
Paginator::useBootstrap();
|
||||
|
||||
// Custom validation rule: isunique
|
||||
Validator::extend('isunique', function ($attribute, $value, $parameters, $validator) {
|
||||
$value = strtolower($value);
|
||||
$query = DB::table($parameters[0])->whereRaw("LOWER({$attribute}) = ?", [$value]);
|
||||
@ -38,10 +43,19 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
return $query->count() === 0;
|
||||
});
|
||||
|
||||
// Custom validation rule: exturl
|
||||
Validator::extend('exturl', function ($attribute, $value, $parameters, $validator) {
|
||||
$allowed_schemes = ['http', 'https', 'mailto', 'tel'];
|
||||
return in_array(parse_url($value, PHP_URL_SCHEME), $allowed_schemes, true);
|
||||
});
|
||||
|
||||
// Add namespace for blocks
|
||||
View::addNamespace('blocks', base_path('blocks'));
|
||||
|
||||
// Customize Livewire script route
|
||||
Livewire::setScriptRoute(function ($handle) {
|
||||
return Route::get(asset('assets/vendor/livewire/livewire.js'), $handle);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LivewireServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
$assetUrl = url('');
|
||||
config(['livewire.asset_url' => $assetUrl]);
|
||||
}
|
||||
// public function register()
|
||||
// {
|
||||
// $assetUrl = asset('/vendor/livewire/livewire/dist/livewire.js');
|
||||
// config(['livewire.asset_url' => $assetUrl]);
|
||||
// }
|
||||
}
|
@ -21,7 +21,6 @@
|
||||
<base href="{{ url()->current() }}" />
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
{{-- <script src="{{ asset('assets/js/detect-dark-mode.js') }}"></script> --}}
|
||||
<script src="{{ asset('assets/js/jquery.min.js') }}"></script>
|
||||
|
||||
@include('layouts.analytics')
|
||||
@ -508,7 +507,6 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
|
||||
{{-- <! –– #### begin update detection #### ––> --}}
|
||||
@if(auth()->user()->role == 'admin')
|
||||
@push('sidebar-scripts')
|
||||
<script>
|
||||
var isVisible = true;
|
||||
|
||||
@ -541,26 +539,30 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
}
|
||||
</script>
|
||||
|
||||
@if (env('JOIN_BETA') == true)
|
||||
<script>
|
||||
window.onload = async function() {
|
||||
@if (env('JOIN_BETA') == true)
|
||||
<script>
|
||||
(async function() {
|
||||
async function updateBetaVersion() {
|
||||
var Vbeta = await externalFileGetContents('{{"{$betaServer}vbeta.json"}}');
|
||||
|
||||
var isVisible = true;
|
||||
|
||||
$('#beta-version').text(Vbeta);
|
||||
|
||||
document.getElementById('beta-version').textContent = Vbeta;
|
||||
|
||||
var updateElements = document.getElementsByClassName('update-icon-update');
|
||||
|
||||
for (var i = 0; i < updateElements.length; i++) {
|
||||
updateElements[i].style.display = isVisible ? 'block' : 'none';
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
@else
|
||||
<script>
|
||||
window.onload = async function() {
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', updateBetaVersion);
|
||||
document.addEventListener('livewire:navigated', updateBetaVersion);
|
||||
})();
|
||||
</script>
|
||||
@else
|
||||
<script>
|
||||
(async function() {
|
||||
async function updateVersionIcons() {
|
||||
var Vgit = await externalFileGetContents('{{$versionServer}}');
|
||||
var Vlocal = `{{ trim($Vlocal) }}`;
|
||||
|
||||
@ -576,11 +578,13 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
for (var i = 0; i < normalElements.length; i++) {
|
||||
normalElements[i].style.display = isVisible ? 'none' : 'block';
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@endpush
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', updateVersionIcons);
|
||||
document.addEventListener('livewire:navigated', updateVersionIcons);
|
||||
})();
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="nav-link" id="mail-drop"
|
||||
@ -1173,7 +1177,7 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
<script src="{{ asset('assets/js/plugins/setting.js') }}"></script>
|
||||
|
||||
<!-- Slider-tab Script -->
|
||||
<script src="{{ asset('assets/js/plugins/slider-tabs.js') }}"></script>
|
||||
{{-- <script src="{{ asset('assets/js/plugins/slider-tabs.js') }}"></script> --}}
|
||||
|
||||
<!-- Form Wizard Script -->
|
||||
<script src="{{ asset('assets/js/plugins/form-wizard.js') }}"></script>
|
||||
@ -1182,11 +1186,11 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
<script src="{{ asset('assets/vendor/aos/dist/aos.js') }}"></script>
|
||||
|
||||
<!-- App Script -->
|
||||
<script src="{{ asset('assets/js/hope-ui.js') }}" defer data-navigate-track></script>
|
||||
<script src="{{ asset('assets/js/hope-ui.js') }}" defer></script>
|
||||
|
||||
<!-- Flatpickr Script -->
|
||||
<script src="{{ asset('assets/vendor/flatpickr/dist/flatpickr.min.js') }}"></script>
|
||||
<script src="{{ asset('assets/js/plugins/flatpickr.js') }}" defer></script>
|
||||
{{-- <script src="{{ asset('assets/vendor/flatpickr/dist/flatpickr.min.js') }}"></script>
|
||||
<script src="{{ asset('assets/js/plugins/flatpickr.js') }}" defer></script> --}}
|
||||
|
||||
<script src="{{ asset('assets/js/plugins/prism.mini.js') }}"></script>
|
||||
|
||||
@ -1233,24 +1237,18 @@ MODAL; // <-- Indentation breaks my code editor :/
|
||||
<script src="{{ asset('assets/js/main-dashboard.js') }}"></script>
|
||||
|
||||
@stack('sidebar-scripts')
|
||||
|
||||
{{-- @livewireScriptConfig
|
||||
<script data-navigate-once="true">window.livewireScriptConfig.progressBar = true;</script> --}}
|
||||
<script src="{{ asset('assets/vendor/livewire/livewire.js') }}" data-update-uri="/livewire/update" data-navigate-once="true"></script>
|
||||
<script>
|
||||
|
||||
{{-- <script>
|
||||
document.addEventListener("livewire:navigated", () => {
|
||||
if (typeof Alpine !== 'undefined' && Alpine.start) {
|
||||
console.log("Alpine.js is running!");
|
||||
} else {
|
||||
console.log("Alpine.js is not running.");
|
||||
Alpine.start();
|
||||
}
|
||||
if (document.getElementById('SvgjsSvg1001')) {
|
||||
// Your code to run if the element exists
|
||||
console.log('Element SvgjsSvg1001 exists!');
|
||||
} else {
|
||||
// Your code to run if the element does not exist
|
||||
// console.log('Element SvgjsSvg1001 does not exist.');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("alpine:init",()=>{console.log("Alpine initialized")})
|
||||
|
||||
</script>
|
||||
</script> --}}
|
||||
@livewireScripts
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user