Collection.php 893 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App;
  3. use Illuminate\Support\Str;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\HasSnowflakePrimary;
  6. class Collection extends Model
  7. {
  8. use HasSnowflakePrimary;
  9. /**
  10. * Indicates if the IDs are auto-incrementing.
  11. *
  12. * @var bool
  13. */
  14. public $incrementing = false;
  15. public $fillable = ['profile_id', 'published_at'];
  16. public $dates = ['published_at'];
  17. public function profile()
  18. {
  19. return $this->belongsTo(Profile::class);
  20. }
  21. public function items()
  22. {
  23. return $this->hasMany(CollectionItem::class);
  24. }
  25. public function posts()
  26. {
  27. return $this->hasManyThrough(
  28. Status::class,
  29. CollectionItem::class,
  30. 'collection_id',
  31. 'id',
  32. 'id',
  33. 'object_id'
  34. );
  35. }
  36. public function url()
  37. {
  38. return url("/c/{$this->id}");
  39. }
  40. }