getDynamicRelationship($key)) { return $relationship; } // Dynamically retrieve the encryptable attribute $value = $this->getDynamicEncrypted($key); if (is_null($value) || ! is_string($value)) { // Fallback to the default Eloquent dynamic getter $value = parent::__get($key); } // Dynamically juggle the attribute. // This is always called so that even decrypted values // can be casted after decrypting. return $this->getDynamicJuggle($key, $value); } /** * Dynamically set attributes. * * @param string $key * @param mixed $value */ public function __set($key, $value) { // Dynamically set the encryptable attribute if (! empty($value) && $this->setDynamicEncryptable($key, $value)) { return; } // Fallback to the default Eloquent dynamic setter parent::__set($key, $value); // Dynamically juggle the attribute. $this->setDynamicJuggle($key, $value); } /** * Get the messages for the instance. * * @return Illuminate\Contracts\Support\MessageBag */ public function getMessageBag() { return $this->getErrors(); } }