7 months ago

Passing Variable to Blade Causes increment() to Increment DB Field Twice

Posted 7 months ago by grigelionis

In my Blade file article.blade.php I include another view with a variable.


@include('frontend/header', ['page_title' => 'hello' ])


public function hitCollector($article_id)
    $data["article"] = DB::table('selected_articles')
        ->where('published', 1)
        ->where('id', $article_id)

    $data["article_title"] = "this is title";

    //collecting hit
        ->where('id', $article_id)

    return view('frontend/article', $data);

As a result, I am getting DB field 'clicks' increased twice (+2) but not (+1) for given records. I noticed that doubling stops only if I am removing the ['page_title' => 'hello'] part from my Blade inclusion line.

I've checked network tab for any 301, 302 redirects - nothing, just one single 200 response without doubling requests. And yes, no async calls triggered from header, i am running only foreach loope there through passed data.

This is frontend/article.blade.php

And this is frontend/header.blade.php

Any ideas? Bug?

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