0
0
0ldn0mad2019-09-24 01:01:01
Laravel
0ldn0mad, 2019-09-24 01:01:01

How to pass the visit counter to the template?

Tell me how to transfer this counter to the blade template?

public function countInput(Request $request)
  {
    $count = Cookie::get('count', 1);
    Cookie::forever('count', ++$count);
    return response("Число вхождений: {$count}")->withCookie(cookie('count', $count));
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2019-09-24
@glaphire

https://laravel.com/docs/5.8/requests#cookies
Output Cookie::get('cookiename') in the template.
You can also transfer via Cookie::queue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question