hasMany('ClassName', 'ForeignKey', 'LocalKey');
That's pretty much everything you need.
Mind that ClassName
must include namespace if that's the case.
Your models look fine.
How about trying this in your view:
@foreach($leads as $lead)
@foreach($lead->notes as $note) ...
Hi luciendub,
Do you have both models defined? Could you please put here your models definition?
I found the problem after a good night sleep! I had mispelled Note (Notes) in my Note.php model file. So I removed the "s" and used
@foreach($leads as $lead)
@foreach($lead->notes as $note)
{{$note->contenudelanote}}
@endforeach
@endforeach
as proposed.
Thank you
and here is my Note.php model
<?php
use Illuminate\Database\Eloquent\Collection;
class Note extends \Eloquent {
protected $table = 'notes';
protected $fillable = [];
public function leads()
{
return $this->belongsTo('Lead');
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community