Save workspace changes
This commit is contained in:
41
.deploy/artwork-evolution-release/app/Models/PostTarget.php
Normal file
41
.deploy/artwork-evolution-release/app/Models/PostTarget.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Polymorphic-style target attached to a Post.
|
||||
* For v1: target_type = 'artwork', target_id = artworks.id
|
||||
*/
|
||||
class PostTarget extends Model
|
||||
{
|
||||
protected $table = 'post_targets';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'post_id',
|
||||
'target_type',
|
||||
'target_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
const CREATED_AT = 'created_at';
|
||||
const UPDATED_AT = null;
|
||||
|
||||
public function post(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Post::class);
|
||||
}
|
||||
|
||||
/** Resolved Artwork when target_type = 'artwork' */
|
||||
public function artwork(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Artwork::class, 'target_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user