Laravel View With Json Value

View Json Value In laravel View :

Controller file :

  public function index()
    {
        //
        $students = Student::get()->toJson(JSON_PRETTY_PRINT);
         // return response($students, 200);
         return view('student.List')->with('students', json_decode($students,true));
    }

View File :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
@foreach($students as $students)
    <tr class="odd pointer">
        <td class=" ">{{$students["id"]}}</td>
        <td class=" ">{{$students["name"]}}</td>
    </tr>
@endforeach
</body>
</html>

Published by

Unknown's avatar

Nusrat Faria

I Am A Web Developer And A Android Developer. This Is My Personal Blog So Noted My Work For Helping People .

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.