public function find($key, $default = null)
    {
        if ($key instanceof Mappable) {
            $key = $this->getEntityKey($key);
        }

        return array_first($this->items, function ($entity, $itemKey) use ($key) {
            return $this->getEntityKey($entity) == $key;
        }, $default);
    }
public function find($key, $default = null)
    {
        if ($key instanceof Mappable) {
            $key = $this->getEntityKey($key);
        }

        return array_first($this->items, function ($entity, $itemKey) use ($key) {
            return $this->getEntityKey($entity) == $key;
        }, $default);
    }
public function find ( $ key , $ default = null ) { if ( $ key instanceof Mappable ) { $ key = $ this -> getEntityKey ( $ key ) ; } return array_first ( $ this -> items , function ( $ entity , $ itemKey ) use ( $ key ) { return $ this -> getEntityKey ( $ entity ) == $ key ; } , $ default ) ; }
Find an entity in the collection by key.

@param mixed $key
@param mixed $default

@throws MappingException

@return \Analogue\ORM\Entity
Find an entity in the collection by key .