PHP code example of ebess / laravel-inertia-shared-data-provider

1. Go to this page and download the library: Download ebess/laravel-inertia-shared-data-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ebess / laravel-inertia-shared-data-provider example snippets


    protected $middlewareGroups = [
        'web' => [
            // ...
            \Ebess\LaravelInertiaSharedDataProvider\Http\Middleware\InertiaSharedData::class,
            \App\Http\Middleware\HandleInertiaRequests::class,
        ],
    ];

use Ebess\LaravelInertiaSharedDataProvider\Contracts\InertiaSharedDataProvider;

class FooBarSharedDataProvider implements InertiaSharedDataProvider
{
    public function provide(Request $request): array
    {
        return [
            'foo' => 'bar',
        ];
    }
}

use Ebess\LaravelInertiaSharedDataProvider\Contracts\InertiaSharedDataProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->tag(
            FooBarSharedDataProvider::class,
            InertiaSharedDataProvider::TAG_NAME
        );
    }
}