Good afternoon, sorry if I had any similar questions, I searched extensively both here and in English and found nothing similar,
I have the following Template in the database
contract
id
due_date
contract_service
id
price
contract_id
type_id
service
id
name
desc
base_price
The templates are Contract, ContractService, Service, follow their respective relationships:
class Contract extends Model
{
public function service() {
return $this->hasMany('App\ContractService');
}
}
class ContractService extends Model
{
public function type() {
return $this->belongsTo('App\Service', 'type_id');
}
}
class Service extends Model
{
}
In laravel I look for the name of the contract services in this way (for being hasMany)
$contract->service[0]->type->name
Is there any way to reduce this extensive relationship and do something like this?
$contract->service[0]->name
The service table is where I save the type of Services to be rendered, it would be something like conctract_service_description (which OpenCart uses using inner_join if I'm not mistaken).