Home  >  Q&A  >  body text

Problem with laravel ORM $append attribute as shown in the figure

Doesn’t it matter if you just fill in that position?

phpcn_u1582phpcn_u15822684 days ago491

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-16 16:50:50

    The return value of the modified method will be assigned to test1. Your way of writing (an assignment operation) will return true

    reply
    0
  • 阿神

    阿神2017-05-16 16:50:50

    Assumption Usermobile. Pseudocode:

    class User extends Model
    {
        public function getHiddenMobileAttribute($value)
        {
            return Str::substr($this->mobile,0,4).str_repeat('*',8);
        }
    }
    echo $user->hidden_mobile;
    // 156********

    reply
    0
  • Cancelreply