samedi 25 août 2018

Distinct Values in Laravel

Hello Friends I am using the following query :

$cur_date = date('Y-m-d');
   $clientTemp = DB::table('clients')->where('quotations.exp_date','<',$cur_date)
     ->join('quotations','quotations.customer_id','=','clients.id')
      ->get()
       ->map(function ($clientTemp) {
        return [
            'id' => $clientTemp->id,
            'hash' => $clientTemp->hash,
            'name' => $clientTemp->first_name.' '.$clientTemp->last_name,
            'email' => $clientTemp->email,
            'mobile' => $clientTemp->mobile
        ];
    });

I am getting this data from two tables :

1. Qutoations and 2. Clients.

In quotations table if the exp_date is less than current date then the details will be fetched from client table.

But there is possibility then there are more than 1 rows in quotation table but I want to fetch only one table from that for which customer_id is unique. How can I fetch unique row with same customer_id from quotations table



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire