Support the ongoing development of Laravel.io →
Input Views Blade

Laravel 5.2

Hello I have this message in my controller:

public function postIndex(SaveProfileRequest $request) { $profile = Profile::create([ 'name' => $request->input('name') ]);

if($profile->id) {
    return redirect()->back()->with('message', [
        'type'=> 'success',
        'message' => 'Успешно записан нов профил!'

    ]);
}

return redirect()->back()->with('message', [
    'type'=> 'danger',
    'message' => 'Профилът не е записан!'
]);

I'm displaying it like this in my view:

@if(Session::has('message')) {{ Session::get('message.message')}} @endif

But it doesn't show in the type i have selected in the controller, how can I format it?

Thank you!

Last updated 3 years ago.
0
@if($message) {{ $message["message"] }} @endif
0

Not working. I got this Undefined variable: message (View: C:\xampp\htdocs\school_system\resources\views\messages.blade.php) (View: C:\xampp\htdocs\school_system\resources\views\messages.blade.php)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

yolita15 yolita15 Joined 16 Feb 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.