Add a couple service providers

This commit is contained in:
Annika Backstrom 2024-05-25 23:27:39 +01:00
parent 0e8d56f2af
commit 6c514f9a96
Signed by: annika
GPG Key ID: 3561F004DE1D9AFE
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,10 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
protected $namespace = 'App\\Http\\Controllers';
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// https://laravel-tricks.com/tricks/a-new-at-action-directive
Blade::if(
'action', function ($action) {
if (Route::getCurrentRoute()->getActionMethod() == $action) {
return $action;
};
}
);
}
}

View File

@ -2,4 +2,6 @@
return [ return [
App\Providers\AppServiceProvider::class, App\Providers\AppServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\ViewServiceProvider::class,
]; ];