update model to use parent_id
This commit is contained in:
@@ -11,14 +11,34 @@ class Media extends Model
|
|||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = ['parent_id', 'filename', 'path', 'type', 'metadata', 'size'];
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'parent_id',
|
||||||
|
'filename',
|
||||||
|
'path',
|
||||||
|
'type',
|
||||||
|
'metadata',
|
||||||
|
'size'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'metadata' => 'array',
|
'metadata' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the original media of this variation.
|
* Get the original media of this variation.
|
||||||
|
*
|
||||||
|
* @return BelongsTo
|
||||||
*/
|
*/
|
||||||
public function parent(): BelongsTo
|
public function parent(): BelongsTo
|
||||||
{
|
{
|
||||||
@@ -27,11 +47,11 @@ class Media extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the variations for the media.
|
* Get the variations for the media.
|
||||||
|
*
|
||||||
|
* @return HasMany
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public function variations(): HasMany
|
public function variations(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Media::class, 'original_media_id');
|
return $this->hasMany(Media::class, 'parent_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user