GroupPost.php 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\HasSnowflakePrimary;
  6. use App\Services\HashidService;
  7. use App\Profile;
  8. use App\Status;
  9. class GroupPost extends Model
  10. {
  11. use HasSnowflakePrimary, HasFactory;
  12. /**
  13. * Indicates if the IDs are auto-incrementing.
  14. *
  15. * @var bool
  16. */
  17. public $incrementing = false;
  18. protected $fillable = [
  19. 'remote_url',
  20. 'group_id',
  21. 'profile_id',
  22. 'type',
  23. 'caption',
  24. 'visibility',
  25. 'is_nsfw'
  26. ];
  27. public function mediaPath()
  28. {
  29. return 'public/g/_v1/' . $this->group_id . '/' . $this->id;
  30. }
  31. public function group()
  32. {
  33. return $this->belongsTo(Group::class);
  34. }
  35. public function status()
  36. {
  37. return $this->belongsTo(Status::class);
  38. }
  39. public function profile()
  40. {
  41. return $this->belongsTo(Profile::class);
  42. }
  43. public function url()
  44. {
  45. return '/groups/' . $this->group_id . '/p/' . $this->id;
  46. }
  47. }