meta ); if ( array_key_exists( $key, $meta ) ){ return $meta[ $key ]; } return null; } /** * Adds the key-value pair into the serialized data set. * * @param string|int $key * @param string|int|float|array|bool|null $value * * @return void */ public function write( $key, $value ){ $meta = unserialize( $this->meta ); $meta[ $key ] = $value; $meta = serialize( $meta ); $this->meta = $meta; $this->save(); } /** * Get the serialized value of the meta info. * * @return string */ public function readRaw(){ return $this->meta; } /** * Set (override) the entire meta with an unmodified string. * * @param string $serialized * * @return void */ public function writeRaw( $serialized ){ $this->meta = $serialized; $this->save(); } /** * Get the universal identifier of the model. * * @return \Ramsey\Uuid\Uuid */ public function getUUID(){ return $this->uuid; } /** * Set the universal identifier of the model (can only be set once). * * @return void */ public function setUuid(){ if( is_null($this->uuid) || $this->uuid === "" ){ $this->uuid = Uuid::uuid4(); } } /** * Ask if the model has a universal identifier. * * @return bool */ public function hasUuid(){ return ( isset($this->uuid) && $this->uuid !== "" ); } /** * Set the universal identifier via existing UUID. * * @param \Ramsey\Uuid\Uuid $uuid * * @return void */ public function setRawUuid( Uuid $uuid ){ $this->uuid = $uuid; $this->save(); } /** * Add the UUID and Meta columns to the table. * * @param \Illuminate\Database\Schema\Blueprint * * @return void */ public static function formTable( Blueprint $table ){ $table->uuid('uuid'); $table->text('meta'); } public static function route(){} }