It's clear how to set and get attributes when it's about one field. But how can I merge two input fields using attribute mutator?
For example I have publish_date
and publish_time
, which I insert in the DB together and want to set attribute publish_date
to become publish_date
+ publish_time
.
You can grab other attributes from the attributes array on the model.
public function setPublishDateAttribute($value)
{
$this->attributes['publish_date'] = $value + $this->attributes['publish_time'];
}