File: D:/HostingSpaces/bomacon/bomacon.nl/app/Components/ComponentType/SaveState/HasSaveStateTrait.php
<?php
namespace App\Components\ComponentType\SaveState;
trait HasSaveStateTrait
{
/** @var SaveStateInterface */
private $saveStateInstance;
/**
* Mutator for the saveStateInstance model attribute
*
* @param $value
*/
public function setSaveStateInstanceAttribute($value)
{
if(! is_a($value, SaveStateInterface::class)) throw new \InvalidArgumentException('The attribute instance must be a subclass of "'.SaveStateInterface::class.'"');
$this->saveStateInstance = $value;
$this->attributes['save_state'] = serialize($this->save_state_instance);
}
/**
* Accessor for the saveStateInstance model attribute
*/
public function getSaveStateInstanceAttribute()
{
return $this->saveStateInstance;
}
}