我有一个应用程序,用户在其中创建用于数据存储的表。表名带有前缀:
$user->id . "_table_name"
我可以像这样检索属于该用户的所有表:
$tables = DB::select("SHOW TABLES LIKE '{$user->id} . _%'");
我可以像这样获取每个表的列:
$columns = Schema::getColumnListing($table);
但我想急切地加载每个表的列,例如:
$tables = DB::with('columns')->select("SHOW TABLES LIKE '{$user->id} . _%'");
如何才能做到这一点?谢谢。