I found this answer which says to do like this:
$columns = Schema::getColumnListing('users');
But it doesnt say what to use, but I suppose it should be:
use Illuminate\Database\Schema\Builder as Schema;
But when I try it it doesnt work:
$columns = Schema::getColumnListing("users");
I get error:
Non-static method Illuminate\Database\Schema\Builder::getColumnListing() should not be called statically, assuming $this from incompatible context
答案 0 :(得分:4)
You can do:
$columns = DB::getSchemaBuilder()->getColumnListing('users');
And use DB;
to import the needed dependencies.
答案 1 :(得分:2)
为了解决最初的问题,它之所以不起作用,是因为你应该只使用它:
use Schema;
而不是:
use Illuminate\Database\Schema\Builder as Schema;