model->with($relationships)->select($select); if (isset($data['status']) && ! empty($data['status']) && $data['status'] != 'full') { $model = $model->where("status", match (strtolower($data['status'])) { 'pending' => 1, 'close' => 0, default => 1 }); } if (count($withCount) > 0) { $model = $model->withCount($withCount); } if (isset($data['page']) && $data['page']) { return $model->paginate(15); } return $model->get(); } public function findBy(string $key = '', string $value) { if (empty($key) || empty($value)) { return false; } return $this->model->where($key, $value)->first(); } }