mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 07:45:22 +00:00
Update Collection models
This commit is contained in:
parent
5ebbe26145
commit
9141e70131
2 changed files with 32 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Pixelfed\Snowflake\HasSnowflakePrimary;
|
||||
|
||||
|
@ -16,8 +17,32 @@ class Collection extends Model
|
|||
*/
|
||||
public $incrementing = false;
|
||||
|
||||
public $fillable = ['profile_id', 'published_at'];
|
||||
|
||||
public function profile()
|
||||
{
|
||||
return $this->belongsTo(Profile::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(CollectionItem::class);
|
||||
}
|
||||
|
||||
public function posts()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Status::class,
|
||||
CollectionItem::class,
|
||||
'collection_id',
|
||||
'id',
|
||||
'id',
|
||||
'object_id',
|
||||
);
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
return url("/c/{$this->id}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,13 @@ class CollectionItem extends Model
|
|||
{
|
||||
use HasSnowflakePrimary;
|
||||
|
||||
public $fillable = [
|
||||
'collection_id',
|
||||
'object_type',
|
||||
'object_id',
|
||||
'order'
|
||||
];
|
||||
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue