Move notes for attachments to different object. This sacrifices the original notes.

This commit is contained in:
James Cole
2018-03-19 15:28:35 +01:00
parent 6a1d39d5f8
commit 909f72e6be
9 changed files with 144 additions and 31 deletions

View File

@@ -49,7 +49,7 @@ class Attachment extends Model
'uploaded' => 'boolean',
];
/** @var array */
protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'notes', 'description', 'size', 'uploaded'];
protected $fillable = ['attachable_id', 'attachable_type', 'user_id', 'md5', 'filename', 'mime', 'title', 'description', 'size', 'uploaded'];
/**
* @param string $value
@@ -142,7 +142,7 @@ class Attachment extends Model
* @codeCoverageIgnore
* @return null|string
*/
public function getNotesAttribute($value)
public function getTitleAttribute($value)
{
if (null === $value || 0 === strlen($value)) {
return null;
@@ -152,18 +152,12 @@ class Attachment extends Model
}
/**
* @param $value
*
* @codeCoverageIgnore
* @return null|string
* Get all of the notes.
*/
public function getTitleAttribute($value)
public function notes()
{
if (null === $value || 0 === strlen($value)) {
return null;
}
return Crypt::decrypt($value);
return $this->morphMany(Note::class, 'noteable');
}
/**
@@ -196,16 +190,6 @@ class Attachment extends Model
$this->attributes['mime'] = Crypt::encrypt($value);
}
/**
* @codeCoverageIgnore
*
* @param string $value
*/
public function setNotesAttribute(string $value)
{
$this->attributes['notes'] = Crypt::encrypt($value);
}
/**
* @codeCoverageIgnore
*