MergeDeleteTrait
Merge/Delete Trait
Common methods merging one record into another, then deleting the first record.
Table of Contents
Methods
- findMergeRecords() : Query<string|int, mixed>
- Gets the list of available records for determining which record to merge to.
- getMergeStats() : array<string, array<string, string|int>>
- Get merge stats for a record to be deleted.
- mergeDelete() : bool
- Allows to merge associated records from one attribute to another, then delete the old record.
Methods
findMergeRecords()
Gets the list of available records for determining which record to merge to.
public
findMergeRecords(Query<string|int, mixed> $query[, array<string|int, mixed> $options = [] ]) : Query<string|int, mixed>
This is a custom finder.
Parameters
- $query : Query<string|int, mixed>
-
The query object to modify.
- $options : array<string|int, mixed> = []
-
The options either specific to this finder, or to pass through. There should be an 'sourceId' option to exclude.
Return values
Query<string|int, mixed> —Return the modified query object.
getMergeStats()
Get merge stats for a record to be deleted.
public
getMergeStats(int $id) : array<string, array<string, string|int>>
Parameters
- $id : int
-
The id of the record.
Return values
array<string, array<string, string|int>> —The list of stats.
mergeDelete()
Allows to merge associated records from one attribute to another, then delete the old record.
public
mergeDelete(int $sourceId, int $targetId) : bool
Parameters
- $sourceId : int
-
The record id to delete.
- $targetId : int
-
The record id to move the associated records to.
Tags
Return values
bool —If the save was successfull.