classes/Collections/Elements.php
public function get($key, $default = null)
    {
        $this->hydrate();

        // Create an Element instance using the data for the key
        if ($this->has($key)) {
            return new $this->model(array_merge($this->items[$key], ['key' => $key]));
        }

        // If the key doesn't exist but a default was passed in, return it
        if ($default) {
            return $default;
        }

        // if the key doesn't exist, but running locally, throw an exception
        if (App::isLocal()) {
            throw new Exception("Element key '{$key}' is not declared in elements.yaml.");
        }

        // Otherwise, like if key doesn't exist and running on production,
        // return an empty Element, whose ->toString() will return an empty string.
        Log::error("Element key '{$key}' is not declared in elements.yaml.");
        return new $this->model();
    }
public function get($key, $default = null)
    {
        $this->hydrate();

        // Create an Element instance using the data for the key
        if ($this->has($key)) {
            return new $this->model(array_merge($this->items[$key], ['key' => $key]));
        }

        // If the key doesn't exist but a default was passed in, return it
        if ($default) {
            return $default;
        }

        // if the key doesn't exist, but running locally, throw an exception
        if (App::isLocal()) {
            throw new Exception("Element key '{$key}' is not declared in elements.yaml.");
        }

        // Otherwise, like if key doesn't exist and running on production,
        // return an empty Element, whose ->toString() will return an empty string.
        Log::error("Element key '{$key}' is not declared in elements.yaml.");
        return new $this->model();
    }
public function get ( $ key , $ default = null ) { $ this -> hydrate ( ) ; // Create an Element instance using the data for the key if ( $ this -> has ( $ key ) ) { return new $ this -> model ( array_merge ( $ this -> items [ $ key ] , [ 'key' => $ key ] ) ) ; } // If the key doesn't exist but a default was passed in, return it if ( $ default ) { return $ default ; } // if the key doesn't exist, but running locally, throw an exception if ( App :: isLocal ( ) ) { throw new Exception ( "Element key '{$key}' is not declared in elements.yaml." ) ; } // Otherwise, like if key doesn't exist and running on production, // return an empty Element, whose ->toString() will return an empty string. Log :: error ( "Element key '{$key}' is not declared in elements.yaml." ) ; return new $ this -> model ( ) ; }
Get an element given it's key

@param  string  $key
@return Bkwld\Decoy\Models\Element
Get an element given it s key