I have a JSON file that needs decoding as it has {"Text" and then the actual message I send, inside my DB it stores under "content". I am trying to decode it to have clean data inside my table.
I have tried to make my controller decode it but it doesn't seem to do anything nor give me an error. I have attached a photo so you can see what I mean. I am not getting any errors with my controller but it just doesn't seem to have any effect either. I need to define the variable content inside my controller but if I change from return view details, message => $message to details, content => content I get non-object errors (Since decode it is now an array).
My Controller:
<?php namespace App\Http\Controllers; use App\Message; use App\Suggestion; use Carbon\Carbon; use Google\Auth\ApplicationDefaultCredentials; use Google\Cloud\PubSub\PubSubClient; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Http\Request; use Illuminate\Routing\Controller as BaseController; use Illuminate\Support\Facades\Storage; use Propaganistas\LaravelPhone\PhoneNumber; class DetailsController extends BaseController { public function index($id) { $message = Message::find($id); $content = json_decode($message->content,TRUE); return view('details', ['message' => $message]); } } `
My Blade file is just a table which most important part is:
<td>{{$message->type}}</td> <td>{{$message->content}}</td> <td>{{$message->response}}</td> <td>{{$message->id}}</td> Once I can convert this into an array I can explode it into more respectable columns, I have attached an image of the UI so you can see what I'm trying to do
$body = json_decode($response->getBody(),true);? The$response->getBody()part seems wrong, from where is this data coming from? You have areturnon the line before this, so this code won't be executed.