I am trying to access the properties of an array from a view. A controller is passing the array to that view. For some reason am not able to access the the array properties.
Error Message:
Trying to get property 'message' of non-object (View: /path/to/file/message.blade.php)
View code + where error is occurring:
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{$message->title}}</div>
<div class="card-body">
{{$message->message}}
</div>
</div>
</div>
</div>
</div>
@endsection
Controller code that is returning the above view:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\User;
class becomeorganiser extends Controller
{
public function becomeorganiser(){
$user = Auth::user();
$user->organiser = 1;
$user->save();
$message = [];
$message['title'] = 'Success!';
$message['message'] = 'You are now an event organiser<br>You now have access the oragnisers control panel in your navigation bar!';
return view('message', $message);
}
}
If I do {{print_r($message)}}
The contents is printed out. To be clear I cannot access either the title or message properties
What am I doing wrong?