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