Add a couple service providers
This commit is contained in:
parent
0e8d56f2af
commit
6c514f9a96
10
app/Providers/RouteServiceProvider.php
Normal file
10
app/Providers/RouteServiceProvider.php
Normal 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';
|
||||
}
|
33
app/Providers/ViewServiceProvider.php
Normal file
33
app/Providers/ViewServiceProvider.php
Normal 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;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -2,4 +2,6 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\ViewServiceProvider::class,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user