where('repair', 0); } public function package(): BelongsTo { return $this->belongsTo(Package::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function creator(): BelongsTo { return $this->belongsTo(User::class, "creator_id"); } public function transfersAll(): MorphMany { return $this->morphMany(Transfer::class, "transferable")->orderBy("id", "desc"); } public function transfers(): MorphMany { return $this->morphMany(Transfer::class, "transferable") ->where("status", StatusTypeEnum::APPROVED) ->orderBy("id", "desc"); } public function latestTransfer(): MorphOne { return $this->morphOne(Transfer::class, "transferable") ->where("status", StatusTypeEnum::APPROVED) ->orderBy("id", "desc")->latest(); } public function transferActive(): MorphMany { return $this->morphMany(Transfer::class, "transferable") ->where("status", StatusTypeEnum::APPROVED) ->whereNull("to_date") ->orderBy("id", "desc"); } public function registerMediaCollections(): void { $this->addMediaCollection('files') ->useFallbackUrl('/files/default_pastry.jpg') ->useFallbackPath(public_path('/files/default_pastry.jpg')); } /** * @throws InvalidManipulation */ public function registerMediaConversions(Media $media = null): void { $this->addMediaConversion('thumbnail') ->width(480) ->height(640) ->nonQueued() ->performOnCollections('files'); } protected static function getValidCollections(): array { return [ 'files' ]; } }