2021-04-16 01:00:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2023-01-23 16:06:07 +01:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
2021-04-16 01:00:00 +02:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use Illuminate\Pagination\Paginator;
|
2023-01-23 16:06:07 +01:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2024-06-20 12:24:54 +02:00
|
|
|
use Illuminate\Support\Facades\View;
|
2021-04-16 01:00:00 +02:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2023-01-23 16:06:07 +01:00
|
|
|
Paginator::useBootstrap();
|
|
|
|
Validator::extend('isunique', function ($attribute, $value, $parameters, $validator) {
|
|
|
|
$value = strtolower($value);
|
|
|
|
$query = DB::table($parameters[0])->whereRaw("LOWER({$attribute}) = ?", [$value]);
|
|
|
|
|
|
|
|
if (isset($parameters[1])) {
|
|
|
|
$query->where($parameters[1], '!=', $parameters[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $query->count() === 0;
|
|
|
|
});
|
2024-02-07 19:15:30 +01:00
|
|
|
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);
|
|
|
|
});
|
2024-06-20 12:24:54 +02:00
|
|
|
View::addNamespace('blocks', base_path('blocks'));
|
2021-04-16 01:00:00 +02:00
|
|
|
}
|
|
|
|
}
|