jeudi 23 juin 2016

Undfined variable 'posts' - Laravel 5

In my ShowController, I returned a view with variable posts, like

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Depress;
use DB;
use App\Http\Requests;

class ShowController extends Controller
{
    public function showPost(Request $request)
    {
        $posts = Depress::all();
        return view('homeview')->with('posts', $posts);
    }
}

And in my, homeview.blade.php ,

 @foreach($posts as $post)
        <div class="panel panel-default">
            <div class="panel-heading"></div>
            <div class="panel-body">
                
            </div>
        </div>
 @endforeach

But, it's showing, Undfined Variable: posts

Can anyone please help ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire