从数组Laravel 5.2中检索已选中的复选框

I have simple form:

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

Values stores in array,

$data = new data();
$data->checkboxes = json_encode($request->all());
$data->save();

like

0 => "Data 1",
1 => "Data 2",
2 => "Data 3"

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

$storedCheckboxes = json_decode($data->checkboxes);
return view('some.view')->with('storedCheckboxes', $storedCheckboxes);

And try to get it in blade:

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

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

Set index for input name and then use it :

@foreach ($datas $key=>$data)

<input name="data[{{$key}}]" type="checkbox" {{old("data[$key])?"checked":''}}/>

@endforeach

Thanks Blake!

I tried to use in_array() before, but i confused with parameters. Now clear with it. Works as i need.

<input name="data[]" type="checkbox" @if (in_array('Data 1', $storedCheckboxes->checkboxes)) checked="checked" @endif />
<input name="data[]" type="checkbox" @if (in_array('Data 2', $storedCheckboxes->checkboxes)) checked="checked" @endif />
<input name="data[]" type="checkbox" @if (in_array('Data 3', $storedCheckboxes->checkboxes)) checked="checked" @endif />

So, i have all checkboxes displayed as i need.