I have a model like this
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
//
protected $table = 'event_invoice';
public function payments(){
return $this->hasMany('App\paymentrecieved','invoiceid');
}
public function comments(){
return $this->hasMany('App\comments','invoiceid');
}
}
Now if I want to get the invoice with all the payments and comments, How should I write the call
I did like this
$invoice = Invoice::where('Id','=',$id)->payments()->comments()->get();
Its throwing error
Call to undefined method Illuminate\Database\Query\Builder::payments()
Thanks & regards
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire