public function destroy($id = null)
    {
        // ID has to be defined
        if (!isset($id)) {
            throw new \InvalidArgumentException('Undefined ID to destroy', 400);
        }

        // Perform before hook
        $this->beforeDestroy($id);

        // Update the model
        $result = $this->db()->table($this->table)->where($this->primaryKey, $id)->limit(1)->delete();

        // Return false on failures
        if (!$result) {
            throw new \Exception('Could not destroy the model', 500);
        }

        // Perform after hook
        $this->afterDestroy($id);

        // Return the destroyed model ID, or false on fail
        return $id;
    }
public function destroy($id = null)
    {
        // ID has to be defined
        if (!isset($id)) {
            throw new \InvalidArgumentException('Undefined ID to destroy', 400);
        }

        // Perform before hook
        $this->beforeDestroy($id);

        // Update the model
        $result = $this->db()->table($this->table)->where($this->primaryKey, $id)->limit(1)->delete();

        // Return false on failures
        if (!$result) {
            throw new \Exception('Could not destroy the model', 500);
        }

        // Perform after hook
        $this->afterDestroy($id);

        // Return the destroyed model ID, or false on fail
        return $id;
    }
public function destroy ( $ id = null ) { // ID has to be defined if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to destroy' , 400 ) ; } // Perform before hook $ this -> beforeDestroy ( $ id ) ; // Update the model $ result = $ this -> db ( ) -> table ( $ this -> table ) -> where ( $ this -> primaryKey , $ id ) -> limit ( 1 ) -> delete ( ) ; // Return false on failures if ( ! $ result ) { throw new \ Exception ( 'Could not destroy the model' , 500 ) ; } // Perform after hook $ this -> afterDestroy ( $ id ) ; // Return the destroyed model ID, or false on fail return $ id ; }
Destroys a model

@return bool|array Deleted model ID, or false
Destroys a model