passing data by form use post method to the table
ErrorException thrown with message "Trying to get property of non-object (View: C:\xampp\htdocs\goodluck\resources\views\layout\show.blade.php)"
show your show.blade.php file please
@extends('layout.index')
@section('title')
show Page one
@stop
@section('content')
<h1>{{$card->title }}</h1>
<ul class="list-group">
@foreach($card->notes as $note)
<li>
<h3>
{{$note->body}}
</h3>
</li>
@endforeach
</ul>
<t3>add new note</t3>
<hr>
<form method="post" action="/show/{card}/notes">
<div class="form-group">
<textarea name="body" title="body" class="form-control"></textarea>
<div class="form-group ">
<button type="submit" class="btn-default">add some text</button>
</div>
</div>
</form>
</div>
@stop
show your controller please
do you have that relationship in your Card model?
public function notes()
{
return $this->hasMany(Note::class);
}
and did you include relation in your controller
$card=Card::with('notes')->get();
class Card extends Model
{
public function notes(){
return $this ->hasMany(Note::class);
}
}
show your controller method please
@Ramazan now show your controller method code please
Please or to participate in this conversation.