Level 75
To exclude one or more attributes from being replicated to the new model, you may pass an array to the
replicatemethod.
So in your case:
$replicate = $record->replicate([
'categories_count'
]);
Is there a way of replicating straight from collection record?
$result = Product::withCount('categories')->get();
$record = $result->first();
$replicate = $record->replicate();
// Unset non-fillable?
$replicate->save();
Above code throws error:
Column not found: 1054 Unknown column 'categories_count' in 'field list'
To exclude one or more attributes from being replicated to the new model, you may pass an array to the
replicatemethod.
So in your case:
$replicate = $record->replicate([
'categories_count'
]);
Please or to participate in this conversation.