Retrieve checked checkboxes from array, Laravel 5.2
<p>I have simple form:</p>

<pre><code>&lt;form action="some_action" method="post"&gt;
   &lt;input type="checkbox" name="data[]" value="Data 1"/&gt;
   &lt;input type="checkbox" name="data[]" value="Data 2"/&gt;
   &lt;input type="checkbox" name="data[]" value="Data 3"/&gt;
   &lt;button type="submit"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>Values stores in array, </p>

<pre><code>$data = new data();
$data-&gt;checkboxes = json_encode($request-&gt;all());
$data-&gt;save();
</code></pre>

<p>like </p>

<pre><code>0 =&gt; "Data 1",
1 =&gt; "Data 2",
2 =&gt; "Data 3"
</code></pre>

<p>Now, i need to retrieve checkbox state. I passed into view decoded json:</p>

<pre><code>$storedCheckboxes = json_decode($data-&gt;checkboxes);
return view('some.view')-&gt;with('storedCheckboxes', $storedCheckboxes);
</code></pre>

<p>And try to get it in blade:</p>

<pre><code>&lt;input name="data[]" type="checkbox" {{ old('data', $storedCheckboxes-&gt;checkboxes[0]) === 'Data 1' ? 'checked' : '' }}/&gt;
</code></pre>

<p>But i think it's wrong way, because in blade i should hardcode array position. And it works, but only if position present.</p>