jeudi 27 mai 2021

Laravel query builder relationships

how can I make join to tables if they have one to many relationships using QueryBuilder I want to do it like Eloquent for example

$result = $this->model::with('members')->select($columns)
            ->latest()
            ->paginate($perPage);

return this result

 "id" => 3701
 "user_id" => 3842
 "cycle_name" => null
 "members_number" => 5
 "code" => "UZFf"
 "start_date" => "2021-05-01"
 "end_date" => "2021-09-01"
 "total_amount" => "5000"
 "amount_per_month" => "1000"
 "public" => 1
 "status" => null
 "created_at" => "2021-05-27 02:14:44"
 "updated_at" => "2021-05-27 02:14:44"
 "is_active" => "yes"
 "is_visible" => "yes"
 "cycle_type_id" => 1
 "collecting_member" => null
 "members" => array:2 [▼
      0 => array:25 [▶]
      1 => array:25 [▶]

how can I perform this operation using query builder I mean to get property in the parent object represent the many relationship



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire