Your code does not stack up
You are passing $test_name to the view and then iterating over $data
So, with the code you show, I can't see how you get that error and not undefined $data
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Im creating a dashboard using laravel, now i want to call the test results that i already stored in my database but it keeps showing this error
syntax error, unexpected double-quoted string "test_name", expecting identifier or variable or "{" or "$" (View: C:\xampp\htdocs\autoDash\resources\views\results\overview_details.blade.php)
I already use dump and dd to debug it and it shows that the data is already there but everytime that i want to show it in my view page with a foreach function, it always shows this error. how can i fix this?
Here is my controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ResultsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// View the overview page
$data=[];
$data=DB::table('test_name')->get();
// dd($data);
return view ('results/overview_details',['test_name'=>$data]);
}
Here is my view
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@extends('layout/main')
@section('title', "Test Results")
@section('contents')
<div class='container'>
<div class="row">
<div class="col-12">
<h1 class="mt-3 mb-3">Overview Details</h1>
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{url('/')}}">Overview</a></li>
<li class="breadcrumb-item active" aria-current="page">Overview Details</li>
</ol>
</nav>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Test Case</th>
<th scope="col">Configuration</th>
<th scope="col">Version No.</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
@foreach ($data as $value)
<tr>
<th scope="row" class='col-3'><a href="/details">{{$value->test_name}}</a></th>
<td class='col-4'>{{$value->config}}</td>
<td class='col-2'>{{$value->version}}</td>
</tr>
@endforeach
</tbody>
And here is my routes:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ResultsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// View the overview page
$data=[];
$data=DB::table('test_name')->get();
// dd($data);
return view ('results/overview_details',['test_name'=>$data]);
}
And im working on laravel 8.29.0
Please or to participate in this conversation.