ethar
2 months ago
396
10
Laravel

print eloquent result in blade

Posted 2 months ago by ethar

i try to print this result in blade using foreach

[
    {
        "active_courses_id": 3,
        "student_course": [
            {
                "id": 3,
                "course_id": 4,
                "course": {
                    "id": 4,
                    "title_ar": "Flutter Course",
                    "img": "[email protected]_7.png"
                }
            }
        ]
    },
    {
        "active_courses_id": 4,
        "student_course": [
            {
                "id": 4,
                "course_id": 5,
                "course": {
                    "id": 5,
                    "title_ar": "E-Commerce Course",
                    "img": "[email protected]_4.png"
                }
            }
        ]
    }
]

in blade

@foreach($studentCourse as $courses)
       <h6>{{ $courses->student_course->course->title_ar }}</h6>
@endforeach

but i got an error

ErrorException

Trying to get property 'course' of non-object (View:

Please sign in or create an account to participate in this conversation.