-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauto_fix_factory.php
More file actions
32 lines (26 loc) · 989 Bytes
/
auto_fix_factory.php
File metadata and controls
32 lines (26 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
$factory_file = $argv[1] ?? null;
if (!$factory_file || !file_exists($factory_file)) {
echo "Usage: php auto_fix_factory.php <factory_file>\n";
exit(1);
}
// Extract model class from factory
$content = file_get_contents($factory_file);
if (preg_match('/protected \$model = ([^:]+)::class;/', $content, $matches)) {
$model_class = trim($matches[1], '\\');
// Get table name
if (class_exists($model_class)) {
$model = new $model_class;
$table = $model->getTable();
echo "Model: $model_class\n";
echo "Table: $table\n";
// Get actual columns
$columns = DB::getSchemaBuilder()->getColumnListing($table);
echo "Columns: " . implode(', ', $columns) . "\n";
}
}