*/ protected $fillable = [ 'media_id', 'private', ]; /** * The default attributes. * * @var string[] */ protected $attributes = [ 'private' => false, ]; /** * Get the media for this attachment. * * @return BelongsTo */ public function media(): BelongsTo { return $this->belongsTo(Media::class); } /** * Get associated Media object. * * @return null|Media */ public function getMedia(): ?Media { return Cache::remember("attachment:{$this->id}:media", now()->addDays(28), function () { return $this->media()->first(); }); } }