Skip to content

Instantly share code, notes, and snippets.

@jasonlbeggs
Created March 6, 2021 01:05
Show Gist options
  • Save jasonlbeggs/68a5a5fef5cb35369811a44fd5bcaefc to your computer and use it in GitHub Desktop.
Save jasonlbeggs/68a5a5fef5cb35369811a44fd5bcaefc to your computer and use it in GitHub Desktop.

Laravel Jetstream Banners

If you're using Laravel Jetstream with Livewire or Intertia.js, the scaffolding includes a banner notification component in the app layout that you can utilize from your own views/Livewire/Inertia.js components. Notifications can be dispatched using Laravel's session.

<?php

// ...

class ExampleComponent extends Component
{
    public function submit() 
    {
        // Do some stuff...
        
        session()->flash('flash.banner', 'Yay for free components!');
        session()->flash('flash.bannerStyle', 'success');
        
        return $this->redirect('/');
    }
}

screenshot

The banners support 'success' and 'danger' styles out of the box. If you'd like to customize the look of the component, run php artisan vendor:publish --tag=jetstream-views to publish the Jetstream views. Then, edit the resources/views/vendor/jetstream/components/banner.blade.php file if you're using Livewire or the resources/js/Jetstream/Banner.vue file if you're using Inertia.js!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment