More updates for laravel 11
This commit is contained in:
@@ -5,15 +5,18 @@ namespace App\Providers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Notifications\ChannelManager;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
use App\Events\Echomail as EchomailEvent;
|
||||
use App\Events\Matrix\Message;
|
||||
use App\Listeners\EchomailListener;
|
||||
use App\Listeners\Matrix\MessageListener;
|
||||
use App\Notifications\Channels\{EchomailChannel,MatrixChannel,NetmailChannel};
|
||||
use App\Models\{Echomail,Netmail};
|
||||
use App\Models\{Echomail,Netmail,User};
|
||||
use App\Traits\SingleOrFail;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -51,10 +54,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
static::bootSingleOrFail();
|
||||
|
||||
// Add our page assets
|
||||
Blade::directive('pa',function($expression) {
|
||||
return sprintf('<?php PageAssets::asset(\'%s\') ?>',$expression);
|
||||
});
|
||||
|
||||
Auth::viaRequest('matrix-token',function (Request $request) {
|
||||
return (config('matrix.hs_token') && ($request->bearerToken() === config('matrix.hs_token'))) ? TRUE : NULL;
|
||||
});
|
||||
|
||||
// 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()));
|
||||
|
||||
Event::listen(
|
||||
Message::class,
|
||||
MessageListener::class,
|
||||
@@ -62,7 +76,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
// @todo This should be detected automatically?
|
||||
Event::listen(
|
||||
\App\Events\Echomail::class,
|
||||
EchomailEvent::class,
|
||||
EchomailListener::class,
|
||||
);
|
||||
}
|
||||
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
//'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
// 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()));
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* The controller namespace for the application.
|
||||
*
|
||||
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
// protected $namespace = 'App\\Http\\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user