pixelfed/app/Collection.php

51 lines
893 B
PHP
Raw Permalink Normal View History

2018-10-17 18:20:58 +00:00
<?php
namespace App;
2019-07-16 05:23:16 +00:00
use Illuminate\Support\Str;
2018-10-17 18:20:58 +00:00
use Illuminate\Database\Eloquent\Model;
use App\HasSnowflakePrimary;
2018-10-17 18:20:58 +00:00
class Collection extends Model
{
2019-04-26 01:56:04 +00:00
use HasSnowflakePrimary;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
2019-07-16 05:23:16 +00:00
public $fillable = ['profile_id', 'published_at'];
2019-07-18 03:10:42 +00:00
public $dates = ['published_at'];
2019-02-03 21:47:50 +00:00
public function profile()
{
return $this->belongsTo(Profile::class);
}
2019-07-16 05:23:16 +00:00
public function items()
{
return $this->hasMany(CollectionItem::class);
}
public function posts()
{
return $this->hasManyThrough(
Status::class,
CollectionItem::class,
'collection_id',
'id',
'id',
2019-07-18 05:22:17 +00:00
'object_id'
2019-07-16 05:23:16 +00:00
);
}
public function url()
{
return url("/c/{$this->id}");
}
2018-10-17 18:20:58 +00:00
}