vendredi 30 septembre 2016

Laravel Undefined variable

I'm having a problem right now I can't display my likes in my view page. This is the line (like_counter) i want to show on my view blade but once I call it i get undefined variable like_counter.

    public function getLikeCounter($post_id) {
    $post = Post::find($post_id);
    $number = null;
    $like_counter = \DB::table('likes')->where('post_id', $post->id)->where('like',!$number)->count();
    return View::make('layouts.viewvideo', ['like_counter' => $like_counter]);
}

View:

<span class="badge"></span>

Routes:

Route::get('/counter/{post_id}', [
'uses' => 'PostController@getLikeCounter',
'as' => 'counter'

]);

Thank you for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire