I am trying to increase the speed of my **Laravel 5.4** sql query by using joins, which I've never used before. I currently have the query working and returning results, my issue is that I get like each results around 8 times. Ex: I get the same 2001 Chevrolet Silverado 8 times in my array. If anybody could help me out I would really appreciate it. Thanks

My query + collection:

```
$tmp = DB::table('inventories'
            )->join(
                'vehicles', 'vehicles.id', '=', 'inventories.id'
            )->join(
                'vimages', 'vimages.vehicle_id', '=', 'inventories.id'
            )->where(
                'inventories.dealer_id', '=', $dealer_id
            )->where(
                'inventories.is_active', '=', 1
            )->where(
                'inventories.is_deleted','=', 0
            )->select(
                'inventories.stock_number','inventories.vehicle_id','vehicles.year','vehicles.make','vehicles.model','vehicles.vin','inventories.vehicle_status',
                'inventories.cost','inventories.search_meta','vimages.name'
        );

        $data = collect();
        $pmt = $tmp->get();
        // return json_encode( $pmt );

        // logger( sprintf('# of rows returned: %s', $pmt->count() ) );

        $pmt->each( function($row) use(&$data) {
          // logger( sprintf('Row    : %s', $row->toJson() ));

            $data->push( array(
                'stock_number' => $row->stock_number,
                'vehicle_id' => $row->vehicle_id,
                'year' => $row->year,
                'make' => $row->make,
                'model' => $row->model,
                // 'trim' => $row->trim,
                'vin' => $row->vin,
                'status' => $row->vehicle_status,
                // 'purchase_price' => $row->purchase_price,
                'cost' => $row->cost,
                // 'retail_price' => $row->retail_price,
                'search_meta' => $row->search_meta,
                // 'images' => $row->getFirstImage()
                'images' => $row->name
                // 'interior_color' => $row->vehicle()->first()->interior_color,
                // 'exterior_color' => $row->vehicle()->first()->exterior_color,
                // 'firstImg' => $row->getFirstImage()
                // 'images' => Vimage::select('vehicle_id','name'
                //                 )->where(
                //                     'dealer_id', '=', $row->dealer_id
                //                 )->where(
                //                     'vehicle_id', '=', $row->vehicle_id
                //                 )->limit(1)->get()
            ));

        });

```

Example of my array:
<https://i.imgur.com/FOphST8.png>