eloquent-driver
eloquent-driver copied to clipboard
Support mapping of entry data to database columns
This is a WIP.
This PR makes it possible to store the contents of data
handles in alternative columns in your database, eg you may want to store my_key
in a column called my_column
.
The benefit of this is it allows you to index that column separately which can speed up database operations.
Mapping can be added by adding a hook on the eloquent entry class, and updating the array $payload
. This array is a mapping of data handles to database columns (note that only root-level data keys are supported).
Entry::hook('data-column-mappings', function (array $payload, $next) {
$payload = array_merge($payload, ['my_key' => 'my_column']);
return $next($payload);
});
Closes https://github.com/statamic/eloquent-driver/issues/272