3 days ago

Laravel component not recognising my variable.

Posted 3 days ago by hjortur17

Hi, I have a color variable in the session. But when I render my component (Flash) then it's just print's out this:

<?php echo e(session('flash.color')); ?>

Any idea why this is happening?

layout file
@if (session('flash.color') && session('flash.title') && session('flash.body'))
	<x-flash color="{{ session('flash.color') }}">
		<x-slot name="title">{{ session('flash.title') }}</x-slot>
		<x-slot name="body">{{ session('flash.body') }}</x-slot>

<div class="bg-{{ $color }}-100" role="alert">
	<div class="flex items-center">
		<div class="flex-1 px-2">
			<p class="text-base md:text-lg font-bold text-{{ $color }}-500">{{ $title }}</p>
			<p class="text-xs md:text-sm leading-relaxed">{{ $body }}</p>

if ($status == 200) {
	return redirect("/{$locale}/contact")->with('flash', [
		'color' => 'green',
		'title' => $sucess_title,
		'body' => $sucess_body,
} else if ($status == 403) {
	return redirect("/{$locale}/contact")->with('flash', [
		'color' => 'red',
		'title' => $error_title,
		'body' => $error_body,

Please sign in or create an account to participate in this conversation.