Skip to content
Advertisement

Unable to fetch data from Laravel Eloquent Relationships

i wanted access the value of content_type_id .i tried like $courseChapters['chapter_content']['content_type_id'] , $courseChapters['content_type_id'] , $courseChapters[0]['content_type_id'] & $courseChapters['chapterContent']['content_type_id'].All these shows the error ErrorException: Undefined index: content_type_id . I also tried everything in the foreach loop i’ve commented below. Nothing works. Can someone tell me how to fix this?

JavaScript
JavaScript

Heading ## dd($courseChapters); shows array like given below:

JavaScript

Advertisement

Answer

Like this to access the first

JavaScript

or like this to access all of them

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement