2021-06-05 09:26:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2023-03-04 14:13:14 +00:00
|
|
|
use App\Extensions\PaymentGateways\PayPal\PayPalSettings;
|
2023-01-25 21:32:59 +00:00
|
|
|
use App\Models\UsefulLink;
|
2023-02-07 15:35:04 +00:00
|
|
|
use App\Settings\MailSettings;
|
2023-01-05 17:01:42 +00:00
|
|
|
use Exception;
|
2021-06-05 09:26:32 +00:00
|
|
|
use Illuminate\Pagination\Paginator;
|
2022-02-08 08:46:33 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2021-06-05 09:26:32 +00:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2021-07-28 16:22:12 +00:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
2021-06-05 09:26:32 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2023-03-04 14:13:14 +00:00
|
|
|
|
2021-06-05 09:26:32 +00:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
Paginator::useBootstrap();
|
|
|
|
Schema::defaultStringLength(191);
|
2021-07-28 16:22:12 +00:00
|
|
|
|
|
|
|
Validator::extend('multiple_date_format', function ($attribute, $value, $parameters, $validator) {
|
|
|
|
$ok = true;
|
|
|
|
$result = [];
|
|
|
|
|
|
|
|
// iterate through all formats
|
|
|
|
foreach ($parameters as $parameter) {
|
|
|
|
//validate with laravels standard date format validation
|
|
|
|
$result[] = $validator->validateDateFormat($attribute, $value, [$parameter]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//if none of result array is true. it sets ok to false
|
2023-02-06 19:42:17 +00:00
|
|
|
if (!in_array(true, $result)) {
|
2021-07-28 16:22:12 +00:00
|
|
|
$ok = false;
|
2023-02-06 19:42:17 +00:00
|
|
|
$validator->setCustomMessages(['multiple_date_format' => 'The format must be one of ' . implode(',', $parameters)]);
|
2021-07-28 16:22:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $ok;
|
|
|
|
});
|
2022-01-24 11:12:50 +00:00
|
|
|
|
2023-01-26 22:26:00 +00:00
|
|
|
try {
|
|
|
|
if (Schema::hasColumn('useful_links', 'position')) {
|
|
|
|
$useful_links = UsefulLink::where("position", "like", "%topbar%")->get()->sortby("id");
|
|
|
|
view()->share('useful_links', $useful_links);
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2023-02-06 19:42:17 +00:00
|
|
|
Log::error("Couldnt find useful_links. Probably the installation is not completet. " . $e);
|
2023-01-25 21:32:59 +00:00
|
|
|
}
|
|
|
|
|
2023-02-07 15:35:04 +00:00
|
|
|
$settings = $this->app->make(MailSettings::class);
|
|
|
|
$settings->setConfig();
|
2021-06-05 09:26:32 +00:00
|
|
|
}
|
|
|
|
}
|