0
I’m trying to relate these tables:
The goal is to show:
Nome,Descrição,Parcela,Valor
Model Cliente:
class Cliente extends Model
{
public function recebtos()
{
return $this->hasMany('App\Recebto','id_cliente');
}
}
Model Recebto:
class Recebto extends Model
{
public function cliente()
{
return $this->belongsTo('App\Cliente','id_cliente');
}
public function parcelas()
{
return $this->hasMany('App\RecebtoParcela','id_recebto');
}
}
Model Parcelas:
class RecebtoParcela extends Model
{
public function recebto()
{
return $this->belongsTo('App\Recebto','id_recebto');
}
}
No Controller:
class RecebtoController extends Controller
{
public function index()
{
$recebtos = Recebto::paginate(15);
return view('recebtos.index',compact('recebtos'));
}
Only this way, if a receipt has more than one portion, only one of them appears in the view. What can I do to have all the plots shown?
I need to know the
view
as you did, because it’s so miss you put toowith
in both relationships.– novic