-
| Does anyone have an idea how to overwrite the  I tried to change the column value on the model boot  Thanks! | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            rez1dent3
          
      
      
        Dec 26, 2022 
      
    
    Replies: 1 comment 2 replies
-
| Hello. I would override the TransactionDtoTransformerInterface interface. use Bavix\Wallet\Internal\Dto\TransactionDtoInterface;
use Bavix\Wallet\Internal\Transform\TransactionDtoTransformer;
use Bavix\Wallet\Internal\Transform\TransactionDtoTransformerInterface;
final class TransactionDtoTransformerCustom implements TransactionDtoTransformerInterface
{
    public function __construct(
        private TransactionDtoTransformer $transactionDtoTransformer
    ) {
    }
    public function extract(TransactionDtoInterface $dto): array
    {
        return array_merge($this->transactionDtoTransformer->extract($dto), [
            'created_at' => new DateTimeImmutable($dto->getMeta()['created_at'] ?? 'now'),
        ]);
    }
}And then in config/wallet.php:   //...
    'transformers' => [
        'transaction' => TransactionDtoTransformerCustom::class,
        //...
    ],
 //...As a result, the composition can keep you backward compatible with the package in the future. And now to use: $user->deposit(1000, ['created_at' => '2020-11-13 15:00:00']);It will work. | 
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
      Answer selected by
        gera919
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Hello. I would override the TransactionDtoTransformerInterface interface.