-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjson-encode-decode.php
38 lines (27 loc) · 1.62 KB
/
json-encode-decode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
//In Controller
$other_info = json_encode([
'field_name' => $request->field_name,
]);
//In Blade Template
<?php $other_info = json_decode(other_info, true) ?>
<?php $jersey_size = $other_info['field_name']; ?>
<label>Label Name</label> <br>
<label class="checkbox-inline">
<input type="checkbox" value="M"name="field_name"
{{ ($field_name == 'statement') ? 'checked' : '' }}>
</label>
#Example
//In Controller
$other_info = json_encode([
'jersey_size' => $request->jersey_size
]);
//In Blade Template
<?php $other_info = json_decode(auth()->user()->other_info, true) ?>
<?php $jersey_size = $other_info['jersey_size']; ?>
<label>Jersey Size</label> <br>
<label class="checkbox-inline">
<input type="checkbox" value="M"name="jersey_size"
{{ ($jersey_size == 'M') ? 'checked' : '' }}>
M
</label>