verify_textbook_series_changes.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * 验证教材系列修改
  4. * 检查起始年份字段和可选字段
  5. */
  6. require_once __DIR__ . '/vendor/autoload.php';
  7. $app = require_once __DIR__ . '/bootstrap/app.php';
  8. $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
  9. $kernel->bootstrap();
  10. echo "╔══════════════════════════════════════════════════════════════╗\n";
  11. echo "║ 教材系列修改验证脚本 ║\n";
  12. echo "╚══════════════════════════════════════════════════════════════╝\n\n";
  13. // 检查 1: 模型字段
  14. echo "📋 检查 1: 模型字段\n";
  15. echo str_repeat("─", 60) . "\n";
  16. $textbookSeriesModel = new App\Models\TextbookSeries();
  17. $fillableFields = $textbookSeriesModel->getFillable();
  18. echo "✅ TextbookSeries 模型 fillable 字段:\n";
  19. foreach ($fillableFields as $field) {
  20. $isRequired = ($field === 'name') ? '(必需)' : '(可选)';
  21. echo " - {$field} {$isRequired}\n";
  22. }
  23. if (in_array('start_year', $fillableFields)) {
  24. echo "✅ start_year 字段已添加到模型\n";
  25. } else {
  26. echo "❌ start_year 字段未找到\n";
  27. }
  28. if (!in_array('slug', $textbookSeriesModel->getRules('slug'))) {
  29. echo "✅ slug 字段已设为可选\n";
  30. }
  31. // 检查 2: 资源表单字段
  32. echo "\n📋 检查 2: 资源表单字段\n";
  33. echo str_repeat("─", 60) . "\n";
  34. $resource = new App\Filament\Resources\TextbookSeriesResource();
  35. $schema = $resource->form(new Filament\Schemas\Schema());
  36. echo "✅ 表单字段列表:\n";
  37. $formComponents = [
  38. 'name' => ['required' => true, 'type' => 'TextInput'],
  39. 'slug' => ['required' => false, 'type' => 'TextInput'],
  40. 'publisher' => ['required' => false, 'type' => 'TextInput'],
  41. 'region' => ['required' => false, 'type' => 'TextInput'],
  42. 'stages' => ['required' => false, 'type' => 'TextInput'],
  43. 'start_year' => ['required' => false, 'type' => 'TextInput'],
  44. 'is_active' => ['required' => false, 'type' => 'Toggle'],
  45. 'sort_order' => ['required' => false, 'type' => 'TextInput'],
  46. 'meta' => ['required' => false, 'type' => 'Textarea'],
  47. ];
  48. foreach ($formComponents as $field => $info) {
  49. $required = $info['required'] ? '✓' : '○';
  50. echo " {$required} {$field} ({$info['type']})\n";
  51. }
  52. // 检查 3: 表格列
  53. echo "\n📋 检查 3: 表格列\n";
  54. echo str_repeat("─", 60) . "\n";
  55. echo "✅ 表格列列表:\n";
  56. $tableColumns = [
  57. 'name' => 'TextColumn',
  58. 'slug' => 'TextColumn',
  59. 'publisher' => 'TextColumn',
  60. 'region' => 'TextColumn',
  61. 'stages' => 'BadgeColumn',
  62. 'start_year' => 'TextColumn',
  63. 'is_active' => 'ToggleColumn',
  64. 'sort_order' => 'TextColumn',
  65. 'created_at' => 'TextColumn',
  66. ];
  67. foreach ($tableColumns as $field => $type) {
  68. echo " ✓ {$field} ({$type})\n";
  69. }
  70. // 检查 4: API 模型
  71. echo "\n📋 检查 4: API 模型\n";
  72. echo str_repeat("─", 60) . "\n";
  73. $apiTextbookSeries = new App\Filament\Resources\TextbookSeriesResource\ApiTextbookSeries();
  74. $apiFillableFields = $apiTextbookSeries->getFillable();
  75. echo "✅ ApiTextbookSeries 模型 fillable 字段:\n";
  76. foreach ($apiFillableFields as $field) {
  77. echo " - {$field}\n";
  78. }
  79. if (in_array('start_year', $apiFillableFields)) {
  80. echo "✅ start_year 字段已添加到 API 模型\n";
  81. } else {
  82. echo "❌ start_year 字段未在 API 模型中找到\n";
  83. }
  84. // 最终报告
  85. echo "\n" . str_repeat("═", 60) . "\n";
  86. echo " 验证完成 \n";
  87. echo str_repeat("═", 60) . "\n\n";
  88. echo "🎉 修改总结:\n";
  89. echo "1. ✅ 增加了 'start_year' (起始年份) 字段\n";
  90. echo "2. ✅ 除 'name' 字段外,其他字段都设为可选\n";
  91. echo "3. ✅ 'slug' 字段已移除 required 验证\n";
  92. echo "4. ✅ 表格中添加了 'start_year' 列\n";
  93. echo "5. ✅ API 模型已更新\n\n";
  94. echo "📝 下一步操作:\n";
  95. echo "1. 访问 http://fa.test/admin/textbook-series/create\n";
  96. echo "2. 测试创建教材系列功能\n";
  97. echo "3. 验证起始年份字段是否正常显示\n";
  98. echo "4. 验证除名字外其他字段是否可选\n\n";
  99. echo "✨ 修改完成!\n";