I am attempting to write some accessor methods according to my best interpretation of the documentation and they do not seem to be working. I am attempting to decrypt an attribute that I am encrypting when it comes into the database via an API call that fires in a scheduled artisan console command. I have a Model that looks like this:
<?php namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use ET_Client;
use ET_DataExtension;
use ET_DataExtension_Row;
use Crypt;
//child implementation
class MasterPreference extends Model {
////these fields can be mass assigned
protected $fillable = [
//
'SMS_OPT_IN',
'EMAIL_OPT_IN',
'CUSTOMER_NAME',
'CUSTOMER_ID'
];
protected $DE_Names = ['MasterPreferences', 'SubPreferences'];
protected $results = '';
//instantiate and replicate
function __construct()
{
}
/**
*
*
* @return $getResult
*/
public function getData()
{
}
/**
* store to the Db
*/
public function store($results)
{
}
/**
* decrypt CUSTOMER_ID
* @param $value
* @return mixed
*/
public function getCustomerIdAttribute($value)
{
return Crypt::decrypt($value);
}
public function getAccountHolderAttribute($value)
{
return $value . 'testing';
}
/**
* ecnrypt Customer ID
*
* @param $value
*/
public function setCustomerIdAttribute($value)
{
$this->attributes['CUSTOMER_ID'] = Crypt::encrypt($value);
}
}
As you can see above I've created 2 accessor methods one for an attribute named CUSTOMER_ID, and another for an attrib named ACCOUNT_HOLDER. When I store like $all = MasterPreference::all() and dd($all) in my index method in the MasterPreferencesController, these attributes are unchanged. Is there another step to calling these accessor methods? Shouldn't they just work by the magic of Laravel?
I appreciate any help! I'm fairly stumped and cannot find this in the docs.