mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Remove hard-coded user_id in factories
This commit is contained in:
parent
adba450b40
commit
e8ff7cc09c
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,7 +31,9 @@ class AccessoryFactory extends Factory
|
||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'model_number' => $this->faker->numberBetween(1000000, 50000000),
|
'model_number' => $this->faker->numberBetween(1000000, 50000000),
|
||||||
'location_id' => rand(1, 5),
|
'location_id' => rand(1, 5),
|
||||||
];
|
];
|
||||||
|
|
|
@ -38,7 +38,9 @@ class ActionlogFactory extends Factory
|
||||||
return [
|
return [
|
||||||
'item_type' => get_class($asset),
|
'item_type' => get_class($asset),
|
||||||
'item_id' => 1,
|
'item_id' => 1,
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'action_type' => 'uploaded',
|
'action_type' => 'uploaded',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\AssetModel;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,7 +42,9 @@ class AssetFactory extends Factory
|
||||||
'rtd_location_id' => Location::factory(),
|
'rtd_location_id' => Location::factory(),
|
||||||
'serial' => $this->faker->uuid(),
|
'serial' => $this->faker->uuid(),
|
||||||
'status_id' => 1,
|
'status_id' => 1,
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'asset_tag' => $this->faker->unixTime('now'),
|
'asset_tag' => $this->faker->unixTime('now'),
|
||||||
'notes' => 'Created by DB seeder',
|
'notes' => 'Created by DB seeder',
|
||||||
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
|
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CategoryFactory extends Factory
|
||||||
'require_acceptance' => false,
|
'require_acceptance' => false,
|
||||||
'use_default_eula' => $this->faker->boolean(),
|
'use_default_eula' => $this->faker->boolean(),
|
||||||
'user_id' => function () {
|
'user_id' => function () {
|
||||||
return User::first() ?? User::factory()->firstAdmin();
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,7 +31,9 @@ class ConsumableFactory extends Factory
|
||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'item_no' => $this->faker->numberBetween(1000000, 50000000),
|
'item_no' => $this->faker->numberBetween(1000000, 50000000),
|
||||||
'order_number' => $this->faker->numberBetween(1000000, 50000000),
|
'order_number' => $this->faker->numberBetween(1000000, 50000000),
|
||||||
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
|
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -30,7 +31,9 @@ class DepartmentFactory extends Factory
|
||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'location_id' => rand(1, 5),
|
'location_id' => rand(1, 5),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -31,7 +32,9 @@ class DepreciationFactory extends Factory
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->catchPhrase(),
|
'name' => $this->faker->catchPhrase(),
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'months' => 36,
|
'months' => 36,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -40,7 +41,9 @@ class LicenseFactory extends Factory
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'name' => $this->faker->name,
|
'name' => $this->faker->name,
|
||||||
'license_email' => $this->faker->safeEmail,
|
'license_email' => $this->faker->safeEmail,
|
||||||
'serial' => $this->faker->uuid,
|
'serial' => $this->faker->uuid,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -52,7 +53,9 @@ class ManufacturerFactory extends Factory
|
||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'support_phone' => $this->faker->phoneNumber(),
|
'support_phone' => $this->faker->phoneNumber(),
|
||||||
'url' => $this->faker->url(),
|
'url' => $this->faker->url(),
|
||||||
'support_email' => $this->faker->safeEmail(),
|
'support_email' => $this->faker->safeEmail(),
|
||||||
|
|
|
@ -20,6 +20,7 @@ use App\Models\Location;
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
class SettingFactory extends Factory
|
class SettingFactory extends Factory
|
||||||
|
@ -39,7 +40,9 @@ class SettingFactory extends Factory
|
||||||
public function definition()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'per_page' => 20,
|
'per_page' => 20,
|
||||||
'site_name' => $this->faker->sentence,
|
'site_name' => $this->faker->sentence,
|
||||||
'auto_increment_assets' => false,
|
'auto_increment_assets' => false,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
class StatuslabelFactory extends Factory
|
class StatuslabelFactory extends Factory
|
||||||
|
@ -25,7 +26,9 @@ class StatuslabelFactory extends Factory
|
||||||
'name' => $this->faker->sentence,
|
'name' => $this->faker->sentence,
|
||||||
'created_at' => $this->faker->dateTime(),
|
'created_at' => $this->faker->dateTime(),
|
||||||
'updated_at' => $this->faker->dateTime(),
|
'updated_at' => $this->faker->dateTime(),
|
||||||
'user_id' => 1,
|
'user_id' => function () {
|
||||||
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||||
|
},
|
||||||
'deleted_at' => null,
|
'deleted_at' => null,
|
||||||
'deployable' => 0,
|
'deployable' => 0,
|
||||||
'pending' => 0,
|
'pending' => 0,
|
||||||
|
|
Loading…
Reference in a new issue