More adjustments for categories

This commit is contained in:
snipe
2026-02-23 14:30:40 +00:00
parent 8cae765835
commit 9280b92b2e
10 changed files with 19 additions and 9 deletions

View File

@@ -219,10 +219,9 @@ class CategoryFactory extends Factory
public function xssTestCategory()
{
return $this->state([
'name' => "<script>alert('xssTest license')</script>",
'category_type' => 'accessory',
'name' => "<script>alert('xssTest category name')</script>",
'notes' => "<script>alert('xssTest category notes')</script>",
'tag_color' => "<script>alert('xssTest department tag')</script>",
'tag_color' => "<script>alert('xssTest category tag')</script>",
'created_by' => function () {
return User::where('username', "<script>alert('xssTest username')</script>@example.org")->first() ?? User::factory()->xssTestUser()->create();
},

View File

@@ -118,9 +118,9 @@ class StatuslabelFactory extends Factory
return $this->state(function () {
return [
'name' => "<script>alert('xssTest label')</script>",
// 'created_by' => function () {
// return User::where('username', "<script>alert('xssTest username')</script>@example.org")->first() ?? User::factory()->xssTestUser()->create();
// },
'created_by' => function () {
return User::where('username', "<script>alert('xssTest username')</script>@example.org")->first() ?? User::factory()->xssTestUser()->create();
},
];
});
}

View File

@@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Accessory;
use App\Models\Category;
use App\Models\Location;
use App\Models\Supplier;
use App\Models\User;
@@ -28,6 +29,8 @@ class AccessorySeeder extends Seeder
$this->call(SupplierSeeder::class);
}
Category::factory()->count(1)->xssTestCategory()->create(['category_type' => 'accessory']);
$supplierIds = Supplier::all()->pluck('id');
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();

View File

@@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Asset;
use App\Models\Category;
use App\Models\Location;
use App\Models\Supplier;
use App\Models\User;
@@ -49,6 +50,7 @@ class AssetSeeder extends Seeder
Asset::factory()->count(40)->phoneIphone12()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(20)->ultrafine()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(20)->ultrasharp()->state(new Sequence($this->getState()))->create();
Category::factory()->count(1)->xssTestCategory()->create(['category_type' => 'assets']);
$del_files = Storage::files('assets');
foreach ($del_files as $del_file) { // iterate files

View File

@@ -29,7 +29,6 @@ class CategorySeeder extends Seeder
Category::factory()->count(1)->componentRamCategory()->create(['created_by' => $admin->id]);
Category::factory()->count(1)->licenseGraphicsCategory()->create(['created_by' => $admin->id]);
Category::factory()->count(1)->licenseOfficeCategory()->create(['created_by' => $admin->id]);
Category::factory()->count(1)->xssTestCategory()->create();
}
}

View File

@@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Company;
use App\Models\Component;
use App\Models\Location;
@@ -43,5 +44,7 @@ class ComponentSeeder extends Seeder
'company_id' => $companyIds->random(),
'location_id' => $locationIds->random(),
]);
Category::factory()->count(1)->xssTestCategory()->create(['category_type' => 'components']);
}
}

View File

@@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Consumable;
use App\Models\User;
use Illuminate\Database\Seeder;
@@ -19,5 +20,6 @@ class ConsumableSeeder extends Seeder
Consumable::factory()->count(1)->cardstock()->create(['created_by' => $admin->id]);
Consumable::factory()->count(1)->paper()->create(['created_by' => $admin->id]);
Consumable::factory()->count(1)->ink()->create(['created_by' => $admin->id]);
Category::factory()->count(1)->xssTestCategory()->create(['category_type' => 'consumables']);
}
}

View File

@@ -27,10 +27,10 @@ class DatabaseSeeder extends Seeder
}
$this->call(CompanySeeder::class);
$this->call(CategorySeeder::class);
$this->call(LocationSeeder::class);
$this->call(DepartmentSeeder::class);
$this->call(UserSeeder::class);
$this->call(CategorySeeder::class);
$this->call(DepreciationSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(SupplierSeeder::class);

View File

@@ -68,6 +68,8 @@ class LicenseSeeder extends Seeder
'created_by' => $admin->id,
]);
Category::factory()->count(1)->xssTestCategory()->create(['category_type' => 'licenses']);
License::factory()->count(1)->xssTestLicense()->create();
}
}

View File

@@ -33,6 +33,6 @@ class StatuslabelSeeder extends Seeder
Statuslabel::factory()->outForRepair()->create(['created_by' => $admin->id]);
Statuslabel::factory()->broken()->create(['created_by' => $admin->id]);
Statuslabel::factory()->lost()->create(['created_by' => $admin->id]);
Statuslabel::factory()->xssTestStatuslabel()->create(['created_by' => $admin->id]);
Statuslabel::factory()->xssTestStatuslabel()->create();
}
}