搜尋

首頁  >  問答  >  主體

laravel ORM $append屬性的問題 如圖所示

#那個位置隨便填寫無所謂?

phpcn_u1582phpcn_u15822818 天前572

全部回覆(2)我來回復

  • 高洛峰

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

    改方法的回傳值會賦予 test1 ,你這樣的寫法(一個賦值操作)會回傳 true

    回覆
    0
  • 阿神

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

    假設 Usermobile。偽代碼:

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

    回覆
    0
  • 取消回覆