Skip to content

HasFileponds ​

Namespace: Unusualify\Modularous\Entities\Traits\HasFileponds

Tracks Filepond temporary file uploads associated with a model. Uses Core\ChangeRelationships internally to flag which Filepond collections changed during a save cycle so downstream listeners (e.g., FilepondManager) can process or clean up uploads.


Dependencies ​

Automatically uses Core\ChangeRelationships (mixed in via use ChangeRelationships).


Relationship ​

php
public function fileponds(): MorphMany  // → Filepond model

If $filepondableClass is set on the model, the morph source is proxied through that class.


Properties ​

PropertyTypeDescription
$deletedFilepondsCollectionFilepond records that were removed in the current save cycle
$newFilepondsCollectionFilepond records added in the current save cycle
$filepondableClassstring|nullOptional proxy class — use when the model's Filepond records are owned by a related class

Methods ​

MethodSignatureDescription
getFileponds(): Filepond[]Returns all Filepond records for this model
hasFilepond(?string $role = null): boolChecks whether any (or a specific-role) Filepond exists
addFilepondsAsChanged(Collection $fileponds): voidMerges records into changedRelationships['fileponds']
setDeletedFilepondsAsChanged(Collection $fileponds): voidReplaces the deleted-fileponds tracking collection
mergeDeletedFilepondsAsChanged(Collection $fileponds): voidMerges into the deleted-fileponds tracking collection
setNewFilepondsAsChanged(Collection $fileponds): voidSets the new-fileponds tracking collection
hasDeletedFileponds(): boolReturns true if any Filepond records were deleted this cycle
hasNewFileponds(): boolReturns true if any Filepond records were added this cycle
getDeletedFileponds(): CollectionReturns the deleted-fileponds collection
getNewFileponds(): CollectionReturns the new-fileponds collection
getFilepondableClass(): ModelReturns the effective proxy model (or $this)

Usage ​

php
use Unusualify\Modularous\Entities\Traits\HasFileponds;

class Article extends Model
{
    use HasFileponds;
}

// Access all Filepond records
$article->fileponds()->get();
$article->getFileponds();

// Check existence
$article->hasFilepond();              // any role
$article->hasFilepond('gallery');     // specific role

// Track changes (used internally by form submission pipeline)
$article->addFilepondsAsChanged($newPonds);
$article->hasDeletedFileponds();      // true if any were removed
$article->getDeletedFileponds();