laravel how to access column with number name of a table?
You can use the following syntax, as found in the variable variables topic in the PHP documentation:
$obj->{'22'};
...
Curly braces may also be used, to clearly delimit the property name. They are most useful when accessing values within a property that contains an array, when the property name is made of mulitple parts, or when the property name contains characters that are not otherwise valid (e.g. from json_decode() or SimpleXML).
Best way is NOT to use Integer as a fieldname. It is bad praxis.But if you need, you should access the database with raw method:
public function show(){ $tests = DB::table('test') ->select("22 as twentytwo") ->get(); foreach($tests as $test){ Log::info($test->twentytwo); }}