π’ Notifications in Squehub
The Notification class in app/core/Notification.php handles one-time flash messages such as
success, error, info, and warning. Messages are stored in session and
automatically cleared after being retrieved.
π¦ Namespace
To use this feature, include the namespace at the top of your file:
use App\Core\Notification;π Methods
Notification::flash('type', 'message')β Store a message of a given type in session.Notification::get('type')β Retrieve a single message and auto-remove it.Notification::all()β Retrieve all available types at once.
π¨ Usage in Blade-like View
Use @hasNotification() in your views to display flash messages conditionally:
@hasNotification('success')
<p style="color: green;">{{ $message }}. Redirecting in 3s...</p>
@endhasNotification
@hasNotification('info')
<p style="color: orange;">{{ $message }}</p>
@endhasNotification
@hasNotification('error')
<p style="color: red;">{{ $message }}</p>
@endhasNotificationπ§± Global Layout Integration
You can show flash messages site-wide by adding this snippet to your layout (e.g. layouts/main.squehub.php):
@hasNotification('success')
<div class="alert alert-success">{{ $message }}</div>
@endhasNotification
@hasNotification('error')
<div class="alert alert-danger">{{ $message }}</div>
@endhasNotification
@hasNotification('info')
<div class="alert alert-info">{{ $message }}</div>
@endhasNotificationπ Example in Controller
use App\Core\Notification;
Notification::flash('success', 'User created successfully!');
redirect()->to('/dashboard');π€ Displaying All Notifications
You can retrieve and display all messages manually if needed:
foreach (Notification::all() as $type => $message) {
echo "<div class='alert alert-$type'>$message</div>";
}β Summary
- Use
Notification::flash()to store feedback after an action. - Use
@hasNotification()in views to check and display messages. - All messages auto-expire after display.

