Category : accessor

i have an Laravel object model with accessor: class NutritionalPlanRow extends Model { use HasFactory; private $nomeAlimento; public function __construct($aliment = null, array $attributes = array()) { parent::__construct($attributes); if($aliment){ $this->aliment()->associate($aliment); $this->nomeAlimento = $aliment->nome; } } public function aliment() { return $this->belongsTo(‘AppModelsAliment’); } protected $guarded = []; public function getNomeAlimentoAttribute() { return $this->nomeAlimento; } } and ..

Read more

I want to decrypt the email attribute of my model: protected $fillable = [ ’email’, ‘password’, ‘remember_token’, ‘status’, ‘name’, ‘lastname’, ‘password_changed_at’, ‘role’, ‘attempts’ ]; By using this mutator with JSON Append protected $appends = [’email’]; public function getEmailAttribute($value) { return $this->attributes[’email’] === Crypt::decrypt($value); } The problem I’m facing it’s that when I execute a dump ..

Read more

I want to decrypt the email attribute of my model: protected $fillable = [ ’email’, ‘password’, ‘remember_token’, ‘status’, ‘name’, ‘lastname’, ‘password_changed_at’, ‘role’, ‘attempts’ ]; By using this mutator with JSON Append protected $appends = [’email’]; public function getEmailAttribute($value) { return $this->attributes[’email’] === Crypt::decrypt($value); } The problem I’m facing it’s that when I execute a dump ..

Read more

I want to write before and after data to logs table when updating an instance. I’m getting beforeUpdate(original) data by getOriginal() method, but I don’t know how to get data related to original data. Ex: Table campaigns has field campaign_status_id. I have an Accessor is getCampaignStatusNameAttribute(), this method will get relationship between campaigns table and ..

Read more