attributes['time_answer'] = $value ? date('H:i:s', strtotime($value)) : null; } /** * The answer, read from the column this row's type maps to. A type * outside the mapping reads the string column. * * The name is inherited from the definition the row was stamped from: * there is nothing "default" about an answer a record actually gave. */ public function getDefaultAnswerAttribute() { $answerColumn = getCustomFieldValueKey($this->type); return $this->{$answerColumn}; } /** * The company the answer was stamped with. */ public function company(): BelongsTo { return $this->belongsTo(Company::class, 'company_id'); } /** * The definition this answers. */ public function customField(): BelongsTo { return $this->belongsTo(CustomField::class, 'custom_field_id'); } /** * The record the answer belongs to, whatever type it is. */ public function customFieldValuable(): MorphTo { return $this->morphTo(); } }