Laravel Tutorials

Quick Tip: Laravel Jetstream Banners

Published
Quick Tip: Laravel Jetstream Banners image

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('/');
}
}

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 banner.blade.php file if you're using Livewire:

resources/views/vendor/jetstream/components/banner.blade.php

or the resources/js/Jetstream/Banner.vue file if you're using Inertia.js!

Jason Beggs photo

TALL stack (Tailwind CSS, Alpine.js, Laravel, and Livewire) consultant and owner of designtotailwind.com.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article