urlsnail/app/Providers/ViewServiceProvider.php

34 lines
686 B
PHP
Raw Permalink Normal View History

2024-05-25 22:27:39 +00:00
<?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;
};
}
);
}
}