title: Laravel select one image from every row from database
body: <p>I have 2 tables in my database , one with cars and one with images for cars..is a one to many relationship..A car can have multiple images , but I want to select for every car just one image. The 2 tables are
  Car table:</p>
  <pre><code> Schema::create('cars', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;string('model');
          $table-&gt;integer('seats');
          $table-&gt;string('fuel');
          $table-&gt;integer('year');
          $table-&gt;string('color');
          $table-&gt;string('gearbox');
          $table-&gt;integer('price');
          $table-&gt;string('coinType');
          $table-&gt;timestamps();
      });
  
  Images table:
  
      Schema::create('images', function (Blueprint $table) {
                  $table-&gt;id();
                  $table-&gt;integer('car_id');
                  $table-&gt;string('file_name');
                  $table-&gt;timestamps();
              });
  
      class Car extends Model
  {
      protected $fillable = [
          'model',
          'seats',
          'fuel',
          'year',
          'color',
          'gearbox',
          'price',
          'coinType',
      ];
  
      public function images()
      {
          return $this-&gt;hasMany(Image::class);
      }
  
  
  Image model:
  
  
      class Image extends Model
  {
      protected $fillable = [
          'car_id',
          'file_name'
      ];
      
      public function car()
      {
          return $this-&gt;belongsTo(Car::class);
      }
  </code></pre>
  <p>I tried to make a join between tables like that:</p>
  <pre><code>$images = Image::join('cars', 'images.car_id', '=', 'car.id')
      -&gt;select('images.file_name')
      -&gt;first();
  </code></pre>
  <p>But I get only the first row from that table. I need some help here, Thank you</p>