How to display the category name by its id value in another table?

There are tables
Cars - contains id, make_id, model_id
Makes - id, name

public function index() {
 $cars = Car::select(['id', 'make_id', 'model_id', 'year', 'start_bid', 'odometer'])->get();
 $makes = Make::all();
 return view('main', compact('cars', 'makes'));

<div class="row">
 @foreach ($cars as $article)
 <div class="col-3 car">
 <a href="{{ route('carsShow', ['id'=>$article->id]) }}">
 <div class="box ratio4_3">
 <div class="box-content grey">
 <img src>
 <div class="box-text">
 <div class="box-title">{{$article->make_id}} {{$article->model_id}}</div>
 <div class="box-descr w100 flex">
 the <div><span>{{ number_format($article->start_bid,0,",' ') }} ₽</span> </div>
 the <div>{{$article->year}}, </div>
 the <div>{{ number_format($article->odometer,0,",' ') }} km</div>


now $article->make_id is displayed as 1, you need to do to display the name of the brand of car Makes from a table according to the received $article->make_id
June 3rd 19 at 19:37
2 answers
June 3rd 19 at 19:39
Your issue is devoted to a documentation section describing different types of relations in the database and how to work with them in the context of the eloquent ORM:
June 3rd 19 at 19:41
// Car model
public function make()
 return $this->hasOne(Make::class);

// Controller
$cars = Car::with('make')->get();

// View
@foreach ($cars as $car)
 {{ $car->make->name }}

Find more questions by tags Laravel