|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use App\View\WidgetFactory;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
if($this->app->environment('production')) {
|
|
|
|
\URL::forceScheme('https');
|
|
|
|
}
|
|
|
|
|
|
|
|
\Route::bind('user', function ($value) {
|
|
|
|
// Hack to have the URL case insensitive (also needed a vendor patch for login)
|
|
|
|
$u = User::whereRaw('LOWER(name)=LOWER(?)', [$value])->first();
|
|
|
|
// it may also be the _id directly
|
|
|
|
if (!$u && is_numeric($value)) $u = User::find((int)$value);
|
|
|
|
if (!$u) abort(404);
|
|
|
|
return $u;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
$this->app->singleton(WidgetFactory::class, function () {
|
|
|
|
return new WidgetFactory();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|