This relation only fetch the user and not the company. For that you need two relations
// Ticket
public function user()
{
return $this->belongsTo('App\Models\User', 'user_id', 'id');
}
// User
public function company()
{
return $this->belongsTo('App\Models\Company', 'company_id', 'id');
}
Now you can fetch both relations
$tickets = Ticket::with('user.company')->get();
foreach($tickets as $ticket) {
echo $ticket->user->name;
echo $ticket->user->company->name;
}
This is basic relationship stuff in Laravel. I would recommend you to take another look at the documentation and use the example used there ;)
Documentation: https://laravel.com/docs/5.5/eloquent-relationships