I am using Mutator to change the Attribute Name
in the Model. So far i used to concatinate the value with '1'
But i want to concatinate with another value named $Subname
and i should get back in the controller before i use DataModel::create($Data);
Code i have already
public function setNameAttribute($value)
{
$this->attributes['Name'] = $Name.'1';
}
Code i need to change
public function setNameAttribute($value)
{
$this->attributes['Name'] = $Name.$SubName;
}
So How can i use the two attribute inside the function and get back in the Controller ?
You cannot use $Name
or $SubName
because they won't be defined. What you want here is probably:
public function setNameAttribute($value)
{
$this->attributes['Name'] = $value.$this->SubName;
}