test_permissions.php 763 B

123456789101112131415161718
  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. $u = App\Models\User::find(11);
  7. $unitId = $u->units()->value('units.id');
  8. $unitUser = App\Models\UnitUser::where('user_id', 11)->where('unit_id', $unitId)->first();
  9. $userType = App\Models\UserType::find($unitUser->user_type_id);
  10. echo "Andreia Unit: {$unitId}\n";
  11. echo "Andreia UserType ID: {$userType->id}\n";
  12. echo "Andreia UserType Label: {$userType->label}\n";
  13. echo "Andreia UserType System Key: {$userType->system_key}\n";
  14. $permissions = App\Models\UserTypePermission::where('user_type_id', $userType->id)->get();
  15. echo "Permissions count: " . $permissions->count() . "\n";