I keep getting this undefined variable error. I am trying to display all the charities to the users, I am doing the exact same function for the 'charityowners' type of user and it is working for them.
Route:
Route::get('charities', 'HomeController@displayCharities');
Home Controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Auth;
use Image;
use App\Charities;
class HomeController extends Controller
{
public function displayCharities()
{
$charities = Charities::all();
return view('charities', ['charities' => $charities]);
}
}
View:
<table class="table">
<tr>
<td> <strong> Name </strong> </td>
<td> <strong> Image </strong> </td>
<td> <strong> Description </strong> </td>
<td> <strong> Action </strong> </td>
</tr>
@foreach($charities as $charity)
<tr>
<td> {{ $charity->name }} </td>
<td> Not Available </td>
<td> {{ $charity->description }} </td>
</tr>
@endforeach
</table>
The error I keep getting is:
ErrorException in d9249250b321fd33ae875d6ca2417a0420928492.php line 39: Undefined variable: charities (View: C:\wamp64\www\EasyDonationNew\laravelesources\views\charities.blade.php)
What am I missing??