src/Repository.php
public function destroy(Entity $entity)
    {
        $requiredClass = Convention::nameToClass($this->getEntityName(), Convention::ENTITY_MASK);
        if (!$entity instanceof $requiredClass) {
            throw new Exception\RepositoryException(
                "Entity must be instance of ". $requiredClass . "!"
            );
        }

        $reflection = $entity::getReflection();
        if (!$reflection->hasPrimary()) {
            throw new Exception\RepositoryException(
                "Can not delete entity without primary property!"
            );
        }

        $primaryName = $reflection->getPrimaryProperty()->getName();

        try {
            return $this->query()->deleteOne($entity->{$primaryName})->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
public function destroy(Entity $entity)
    {
        $requiredClass = Convention::nameToClass($this->getEntityName(), Convention::ENTITY_MASK);
        if (!$entity instanceof $requiredClass) {
            throw new Exception\RepositoryException(
                "Entity must be instance of ". $requiredClass . "!"
            );
        }

        $reflection = $entity::getReflection();
        if (!$reflection->hasPrimary()) {
            throw new Exception\RepositoryException(
                "Can not delete entity without primary property!"
            );
        }

        $primaryName = $reflection->getPrimaryProperty()->getName();

        try {
            return $this->query()->deleteOne($entity->{$primaryName})->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
public function destroy ( Entity $ entity ) { $ requiredClass = Convention :: nameToClass ( $ this -> getEntityName ( ) , Convention :: ENTITY_MASK ) ; if ( ! $ entity instanceof $ requiredClass ) { throw new Exception \ RepositoryException ( "Entity must be instance of " . $ requiredClass . "!" ) ; } $ reflection = $ entity :: getReflection ( ) ; if ( ! $ reflection -> hasPrimary ( ) ) { throw new Exception \ RepositoryException ( "Can not delete entity without primary property!" ) ; } $ primaryName = $ reflection -> getPrimaryProperty ( ) -> getName ( ) ; try { return $ this -> query ( ) -> deleteOne ( $ entity -> { $ primaryName } ) -> run ( $ this -> connection ) ; } catch ( Exception \ QueryException $ e ) { throw new Exception \ RepositoryException ( $ e -> getMessage ( ) ) ; } }
Delete single record

@param Entity $entity

@return boolean

@throws Exception\RepositoryException
Delete single record