getPdo(); $sql = "SELECT * FROM apps;"; $sth = $pdo->prepare($sql); $sth->execute(); $res = $sth->fetchAll(\PDO::FETCH_ASSOC); $appList = []; foreach ($res as $dbEntry) { $app = new App(); $app->load($dbEntry); $appList[] = $app; } return collect($appList); } public function findById($id): ?App { $pdo = app('db')->getPdo(); $sql = "SELECT * FROM apps WHERE `id` = :id;"; $sth = $pdo->prepare($sql); $sth->execute([":id" => $id]); $res = $sth->fetch(\PDO::FETCH_ASSOC); if(is_null($res)) { return null; } $app = new App(); $app->load($res); return $app; } }