tigerManagementDb = new TigerManagement(); } /** * 取得老虎資訊的列表 * 排序、分頁均未實現 * @return array: 返回老虎列表的陣列 */ public function getTigers() { // 取得參數 // 調用資料庫(或者其他業務邏輯) $tigers = $this->tigerManagementDb->select(['id', 'tigerName'])->get()->toArray(); // 整理返回值並返回 return $tigers; } /** * 取得單一老虎資訊 * * @param integer $id : 老虎的自增量 * * @return array: 返回老虎資訊的陣列 */ public function getTigerById($id) { // 取得參數 // 調用資料庫(或者其他業務邏輯) $tigers = $this->tigerManagementDb->select(['id', 'tigerName'])->where('id', $id)->first()->toArray(); // 整理返回值並返回 return $tigers; } /** * 新增老虎 * * @param string $tigerName : 老虎名字 * * @return bool: 返回新增的操作結果 */ public function insertTiger($tigerName) { // 取得參數 // 調用資料庫(或者其他業務邏輯) $res = $this->tigerManagementDb ->insert(['tigerName' => $tigerName]); // 整理返回值並返回 return $res; } /** * 修改老虎 * * @param integer $id : 老虎的自增量 * @param string $tigerName : 老虎名字 * * @return bool: 返回修改的操作結果 */ public function modifyTiger($id, $tigerName) { // 取得參數 // 調用資料庫(或者其他業務邏輯) $res = $this->tigerManagementDb ->where('id', $id) ->update(['tigerName' => $tigerName]); // 整理返回值並返回 return $res; } /** * 刪除老虎 * * @param integer $id : 老虎的自增量 * * @return bool: 返回刪除的操作結果 */ public function deleteTigerById($id) { // 取得參數 // 調用資料庫(或者其他業務邏輯) $res = $this->tigerManagementDb ->where('id', $id) ->delete(); // 整理返回值並返回 return $res; } }