mardi 4 décembre 2018

Laravel Update Controller Variable

Is there a way to update controller variable value from view

MainController.php

$pageData['count'] = 0;
$data = array('data' => $pageData);
return view('home', $data);

In my home view i included another view

<!-- Block 1-->
@include('home.prodbox', $prodData = $data['data'])

<!-- Block 2-->
@include('home.prodbox', $prodData = $data['data'])

In the first block foreach loop count starts with 0. Depends of data, loop runs multiple times and count will increase. So i want to pass the count of first block to second block Like if first block loop count is 4 then i want second block count to start from 5. So in prodbox i did it like this:

prodbox.blade.php

$tabcount = $data['count'];

And at the end of prodbox.blade.php file, I did this

$data['count'] = $tabcount;

But when second block runs it starts with 0 again. I set the data variable to latest count but why it always zero. Is there a way i update data from view to controller.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QcED1f
via IFTTT

Aucun commentaire:

Enregistrer un commentaire