Laravel 4 Eloquent Column Alias

后端 未结 1 1423
再見小時候
再見小時候 2020-12-10 17:53

What i am trying to achieve is in my database i have a table named channel i am using laravel\'s eloquent class to access these the properties from the table The problem tha

相关标签:
1条回答
  • 2020-12-10 18:49

    You could probably do it easily with Accessors / Mutators.

    class Channel extends Eloquent {
    
        public function getNameAttribute()
        {
            return $this->attributes['channel'];
        }
    
        public function setNameAttribute($value)
        {
            $this->attributes['channel'] = $value;
        }
    
    }
    

    Reference

    • Laravel Accessors & Mutators
    0 讨论(0)
提交回复
热议问题