I json_encode URL data before send it to database. Now I am retriving those data in view page. But I need to json_decode
it to get url link smootly. But in some part of code I couldn't do it.
My foreach for the url json_decode(link) not working and returns laravel error. The error is: Undefined variable: links (View: /var/www/html/laravel/resources/views/welcome.blade.php)
<tbody>
@foreach($estates as $estate)
<tr>
<td>{{$estate->company_name}}</td>
<?php
$links = json_decode($estate->link);
$hrefs = "";
foreach($links as $link){
$hrefs .= '<a href="'.$link.'" } target="_blank">{{$estate->name}}</a><br/>';
}
$hrefs .= "";
?>
<td>{{$estate->address}}</td>
<td>{{$estate->price}}</td>
<td>{{$estate->hows_old}}</td>
<td>{{$estate->extend}}</td>
<td>{{$estate->rooms}}</td>
<td>{{$estate->balcon_m2}}</td>
<td>{{$estate->old}}</td>
<td>{{$estate->entery}}</td>
</tr>
@endforeach
</tbody>
without json_decode estate->link
is like this:
`http://localhost/[%22https:////www.31sumai.com//pid//about//%22,%22https:////www.31sumai.com//%22,%22https:////www.31sumai.com//mfr//K1503//%22,%22https:////www.31sumai.com//mfr//K1503//%22,%22http:////maps.google.com//maps?q=34.69465,135.519178%22,%22https:\/\/www.31sumai.com\/mfr\/K1503\/juko.htm]`
Here is the controller codes:
$estates = Estates::get();
$data['estates'] = $estates;
return view('welcome', $data);
Thanks for helping me out.