mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -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;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -30,7 +31,9 @@ class AccessoryFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'model_number' => $this->faker->numberBetween(1000000, 50000000),
|
||||
'location_id' => rand(1, 5),
|
||||
];
|
||||
|
|
|
@ -38,7 +38,9 @@ class ActionlogFactory extends Factory
|
|||
return [
|
||||
'item_type' => get_class($asset),
|
||||
'item_id' => 1,
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'action_type' => 'uploaded',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\AssetModel;
|
|||
use App\Models\Category;
|
||||
use App\Models\Location;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -41,7 +42,9 @@ class AssetFactory extends Factory
|
|||
'rtd_location_id' => Location::factory(),
|
||||
'serial' => $this->faker->uuid(),
|
||||
'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'),
|
||||
'notes' => 'Created by DB seeder',
|
||||
'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,
|
||||
'use_default_eula' => $this->faker->boolean(),
|
||||
'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;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -30,7 +31,9 @@ class ConsumableFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'item_no' => $this->faker->numberBetween(1000000, 50000000),
|
||||
'order_number' => $this->faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -30,7 +31,9 @@ class DepartmentFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'location_id' => rand(1, 5),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -31,7 +32,9 @@ class DepreciationFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'name' => $this->faker->catchPhrase(),
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'months' => 36,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -40,7 +41,9 @@ class LicenseFactory extends Factory
|
|||
|
||||
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'name' => $this->faker->name,
|
||||
'license_email' => $this->faker->safeEmail,
|
||||
'serial' => $this->faker->uuid,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/*
|
||||
|
@ -52,7 +53,9 @@ class ManufacturerFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'support_phone' => $this->faker->phoneNumber(),
|
||||
'url' => $this->faker->url(),
|
||||
'support_email' => $this->faker->safeEmail(),
|
||||
|
|
|
@ -20,6 +20,7 @@ use App\Models\Location;
|
|||
use App\Models\Manufacturer;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SettingFactory extends Factory
|
||||
|
@ -39,7 +40,9 @@ class SettingFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'user_id' => function () {
|
||||
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
||||
},
|
||||
'per_page' => 20,
|
||||
'site_name' => $this->faker->sentence,
|
||||
'auto_increment_assets' => false,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class StatuslabelFactory extends Factory
|
||||
|
@ -25,7 +26,9 @@ class StatuslabelFactory extends Factory
|
|||
'name' => $this->faker->sentence,
|
||||
'created_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,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
|
|
Loading…
Reference in a new issue