whitecube / nova-page

Static pages content management for Laravel Nova
https://whitecube.github.io/nova-page
MIT License
238 stars 41 forks source link

Register templates into the Laravel service container as well #48

Closed zippoxer closed 4 years ago

zippoxer commented 4 years ago

This PR introduces two changes to make it more comfortable to work with options:

  1. Registers templates to the Laravel service container, so you can use Laravel's dependency injection (and also automatic facades) to comfortably access your global options from controllers and such.

    This happens when you call Manager::register.

    Here's an example that works in this PR:

    Route::get('/', function (FooterOptions $footerOptions) {
        return view('home', [
            'copyright' => $footerOptions->copyright
        ]);
    });
  2. Added registerOption function, an alias for register('option', ...), to make it more obvious and easy to remember.

voidgraphics commented 4 years ago

Hey, neat idea! Thanks