mercredi 10 juin 2020

Observer doesn't run saving() and retrieved() methods

I have an Observer that encrypts data

<?php

namespace App\Observers;

use App\TinkoffSetting;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Contracts\Encryption\DecryptException;

class TinkoffSettingsObserver
{
    public function saving(TinkoffSetting $settings)
    {
        try {
            $settings->account = Crypt::encryptString($settings->account);
            $settings->token = Crypt::encryptString($settings->token);
        } catch (DecryptException $e) {
            //
        }
    }

    public function retrieved(TinkoffSetting $settings)
    {
        try {
            $settings->account = Crypt::decryptString($settings->account);
            $settings->token = Crypt::decryptString($settings->token);
        } catch (DecryptException $e) {
            //
        }
    }
}

And Model that stored all data

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\TinkoffSettingsObserver;

class TinkoffSetting extends Model
{   
    public static function boot()
    {
        self::observe(TinkoffSettingsObserver::class);
        parent::boot();
    }
}

And when I run dd(1); in any observer's method, I don't see any changes on the screen. Observer doesn't encrypt and decrypt data. Can you help me to find issue, please?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BMElI6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire