belongsTo( 'App\Package' ); } public function user() { return $this->belongsTo( 'App\User' ); } public function creator() { return $this->belongsTo( 'App\User' , "creator_id" ); } public function transfers() { return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" ); } public function transferActive() { return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" )->whereNull( "to_date" ); } public function registerMediaCollections(): void { $this->addMediaCollection( 'main_image' ) ->useFallbackUrl( config( 'media-library.wm-cdn' ) . '/images/placeholder/blog-placeholder.jpg' ) ->useFallbackPath( public_path( '/images/placeholder/blog-placeholder.jpg' ) ) ->singleFile(); } public function registerMediaConversions( Media $media = null ) { $crop = $media->getCustomProperty( 'crop' ); $conversion = $this->addMediaConversion( 'thumbnail' ); $conversion = ! $crop ? $conversion : $conversion->manualCrop( $crop[ 'width' ] , $crop[ 'height' ] , $crop[ 'left' ] , $crop[ 'top' ] ); $conversion->nonQueued() ->performOnCollections( 'main_image' ); $this->addMediaConversion( 'thumbnail' ) ->width( 400 ) ->nonQueued() ->performOnCollections( 'images' ); } }