2018-11-15 10:45:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2024-12-04 02:54:10 +00:00
|
|
|
use Illuminate\Foundation\AliasLoader;
|
2024-06-09 23:18:59 +00:00
|
|
|
use Illuminate\Http\Request;
|
2021-11-26 13:36:57 +00:00
|
|
|
use Illuminate\Notifications\ChannelManager;
|
2024-06-09 23:18:59 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2024-11-04 07:25:49 +00:00
|
|
|
use Illuminate\Support\Facades\Blade;
|
2024-06-11 04:17:03 +00:00
|
|
|
use Illuminate\Support\Facades\Event;
|
2024-11-04 07:25:49 +00:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2021-11-26 13:36:57 +00:00
|
|
|
use Illuminate\Support\Facades\Notification;
|
2024-12-05 21:33:24 +00:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2018-11-15 10:45:49 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
2024-11-04 07:25:49 +00:00
|
|
|
use App\Events\Echomail as EchomailEvent;
|
2024-06-11 04:17:03 +00:00
|
|
|
use App\Events\Matrix\Message;
|
2024-12-04 02:54:10 +00:00
|
|
|
use App\Helpers\PageAssets;
|
2024-06-11 04:17:03 +00:00
|
|
|
use App\Listeners\EchomailListener;
|
|
|
|
use App\Listeners\Matrix\MessageListener;
|
|
|
|
use App\Notifications\Channels\{EchomailChannel,MatrixChannel,NetmailChannel};
|
2024-12-05 21:33:24 +00:00
|
|
|
use App\Models\{Echomail,Netmail,System,User};
|
2024-11-08 12:31:21 +00:00
|
|
|
use App\Traits\Single;
|
2021-07-16 06:55:26 +00:00
|
|
|
|
2018-11-15 10:45:49 +00:00
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
2024-11-08 12:31:21 +00:00
|
|
|
use Single;
|
2021-07-16 06:55:26 +00:00
|
|
|
|
2021-05-22 14:38:19 +00:00
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2021-11-26 13:36:57 +00:00
|
|
|
Notification::resolved(function (ChannelManager $service) {
|
2023-07-23 07:27:52 +00:00
|
|
|
$service->extend('echomail', function ($app) {
|
|
|
|
return new EchomailChannel($app->make(Echomail::class));
|
|
|
|
});
|
|
|
|
|
2021-11-26 13:36:57 +00:00
|
|
|
$service->extend('netmail', function ($app) {
|
|
|
|
return new NetmailChannel($app->make(Netmail::class));
|
|
|
|
});
|
2024-06-11 04:17:03 +00:00
|
|
|
|
|
|
|
$service->extend('matrix', function ($app) {
|
|
|
|
return new MatrixChannel($app->make(Echomail::class));
|
|
|
|
});
|
2021-11-26 13:36:57 +00:00
|
|
|
});
|
2021-05-22 14:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2024-11-08 12:31:21 +00:00
|
|
|
static::bootSingle();
|
2024-06-09 23:18:59 +00:00
|
|
|
|
2024-11-04 07:25:49 +00:00
|
|
|
// Add our page assets
|
|
|
|
Blade::directive('pa',function($expression) {
|
|
|
|
return sprintf('<?php PageAssets::asset(\'%s\') ?>',$expression);
|
|
|
|
});
|
|
|
|
|
2024-06-09 23:18:59 +00:00
|
|
|
Auth::viaRequest('matrix-token',function (Request $request) {
|
|
|
|
return (config('matrix.hs_token') && ($request->bearerToken() === config('matrix.hs_token'))) ? TRUE : NULL;
|
|
|
|
});
|
2024-06-11 04:17:03 +00:00
|
|
|
|
2024-11-04 07:25:49 +00:00
|
|
|
// Mailer Admin
|
|
|
|
Gate::define('admin',fn(User $o)=>($o->admin === TRUE));
|
|
|
|
|
|
|
|
// ZC of a Zone
|
|
|
|
Gate::define('zc',fn(User $o)=>(($o->admin === TRUE) || $o->ZC()));
|
|
|
|
|
2024-06-11 04:17:03 +00:00
|
|
|
Event::listen(
|
|
|
|
Message::class,
|
|
|
|
MessageListener::class,
|
|
|
|
);
|
|
|
|
|
|
|
|
// @todo This should be detected automatically?
|
|
|
|
Event::listen(
|
2024-11-04 07:25:49 +00:00
|
|
|
EchomailEvent::class,
|
2024-06-11 04:17:03 +00:00
|
|
|
EchomailListener::class,
|
|
|
|
);
|
2024-12-04 02:54:10 +00:00
|
|
|
|
|
|
|
// Custom Aliases
|
|
|
|
$loader = AliasLoader::getInstance();
|
|
|
|
$loader->alias('PageAssets',PageAssets::class);
|
2024-12-05 21:33:24 +00:00
|
|
|
|
|
|
|
Route::model('so',System::class);
|
2021-05-22 14:38:19 +00:00
|
|
|
}
|
2018-11-15 10:45:49 +00:00
|
|
|
}
|