laravel how to access column with number name of a table?

后端 未结 12 1268
闹比i
闹比i 2020-12-18 19:11

I make a table with number 22 as the column name. How to access this column?

content:

I\'ve tryed thest

$obj = Tablename::f         


        
12条回答
  •  独厮守ぢ
    2020-12-18 19:59

    You can use model attribute $maps to give your troublesome column a different name. Try

    $maps = ['22' => 'twentytwo'];
    
    $hidden = ['22'];
    
    $appends = ['twentytwo'];
    

    Then with your model instance

    echo $model->twentytwo;
    

提交回复
热议问题