test_db.php 989 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. require __DIR__.'/vendor/autoload.php';
  3. $app = require_once __DIR__.'/bootstrap/app.php';
  4. $kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
  5. $kernel->bootstrap();
  6. try {
  7. $count = App\Models\UserType::count();
  8. echo "DB is UP! \n";
  9. // Find Andreia
  10. $andreia = App\Models\User::find(11);
  11. if ($andreia) {
  12. $unitId = $andreia->units()->value('units.id');
  13. echo "Andreia Unit ID: " . $unitId . "\n";
  14. $roles = App\Models\UserType::where('unit_id', $unitId)->get();
  15. echo "\nPerfis da unidade da Andreia:\n";
  16. foreach($roles as $role) {
  17. $permCount = App\Models\UserTypePermission::where('user_type_id', $role->id)->count();
  18. echo "- {$role->label} (slug: {$role->slug}, is_system: {$role->is_system}) | Permissões: {$permCount}\n";
  19. }
  20. } else {
  21. echo "Andreia nao encontrada.\n";
  22. }
  23. } catch (\Exception $e) {
  24. echo "DB_IS_DOWN: " . $e->getMessage() . "\n";
  25. }