Skip to main content

Roaming Item

In some cases, you want to save data to a model, but you don't have a model available. For example, you might want to store Media files in a plugin or module, but there is no model.

Creating a roaming item

You can create a roaming item like this:

RoamingItem::query()->create([
'uuid' => Str::uuid(),
'payload' => [
'name' => 'Test name',
'function' => 'Test function',
]
]);

Saving metadata

You can also save other metadata to the roaming item:

RoamingItem::query()->create([
// ..
'name' => 'Test name',
'resource_name' => 'organizations',
'entity_name' => Organization::class,
'entity_id' => 1,
'sort_order' => 1,
'destroy_at' => now()->addDays(7),
]);

Delete

If the destroy_at field is set, the roaming item will marked for deletion after the specified date. This for example will be triggered when a AdvancedRepeater item is saved, but you can also trigger it manually:

RoamingItem::query()->where('destroy_at', '<=', now())->delete();