Trying to get property 'id' of non-object
Hi All,
I am working on a project for an AmpCompare website and I am having issues with my code. I have recently moved to using a different method to call me results as the "Lazy" way I called it before had some issues with mapping id's correctly. I am now using the Load() function to try and load in results which are related to the product.
This is what it should do.
- Display all comments related to the selected product.
View Page @extends('layouts.app') @section('page_title') Amp Compare | {{$product -> make }} {{ $product -> model }} {{ $product -> watt }} @endsection @section('page_heading')
{{$product -> make }} {{ $product -> model }} {{ $product -> watt }}
@endsection @section('content'){{$product -> make }} {{ $product -> model }} {{ $product -> watt }}
{{$product -> genre }}
{{$product -> description }}
{{$product -> updated_at }} {{ $product -> star_rating }}
<div class="back-button">
<p><a class="button" href="/">Back</a></p>
</div>
@if(Auth::check())
<h4 style="float: right">Create a new Comment <a class="button" href="/comment/{{ $product -> id }}/create/"><ion-icon name="create"></ion-icon></a></h4>
@else
@endif
@foreach ($product as $c)
<div><span><h4>{{ $c -> id }}</h4></span></div>
<div><span><p>{{ $c -> comments }}</p></span></div>
<div><p>{{ $c -> likes }}<a class="button" href="/comment/{{ $c -> id }}/like/"><ion-icon name="md-heart"></ion-icon></a>
<a class="button" href="/comment/{{ $c -> id }}/dislike"><ion-icon name="md-heart-empty"></ion-icon></a></p></div>
<div>
@if( Auth::id() == $c -> user_id or Auth::user() -> isAdmin() )
<div><a class="button" href="/comment/{{ $c -> id }}/edit"><ion-icon name="create"></ion-icon></a></div>
<div><a class="button" href="/comment/{{ $c -> id }}/delete"><ion-icon name="trash"></ion-icon></a></div>
@else
@endif
</div>
@endforeach
"There is also pagination on this page however this is also broken so I will fix it after I am able to successfully call the results that I need"
Controller
No worries.
Change this
@foreach ($product->comments as $c)
Please or to participate in this conversation.