snipe-it/database/factories/LicenseFactory.php

142 lines
4.4 KiB
PHP
Raw Normal View History

2017-10-07 04:25:35 -07:00
<?php
2021-06-10 13:17:44 -07:00
namespace Database\Factories;
use App\Models\Category;
use App\Models\Manufacturer;
use App\Models\Supplier;
2023-03-14 11:34:58 -07:00
use App\Models\User;
2021-06-10 13:19:27 -07:00
use Illuminate\Database\Eloquent\Factories\Factory;
2017-10-07 04:25:35 -07:00
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
// 1
// 2
// 3
// 4
2021-06-10 13:17:44 -07:00
class LicenseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = \App\Models\License::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
2021-06-10 13:17:44 -07:00
return [
2023-03-14 11:34:58 -07:00
'user_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
'name' => $this->faker->name,
2021-06-10 13:17:44 -07:00
'license_email' => $this->faker->safeEmail,
'serial' => $this->faker->uuid,
'notes' => 'Created by DB seeder',
'seats' => $this->faker->numberBetween(1, 10),
2023-02-28 14:50:48 -08:00
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
2021-06-10 13:17:44 -07:00
'order_number' => $this->faker->numberBetween(1000000, 50000000),
'expiration_date' => $this->faker->dateTimeBetween('now', '+3 years', date_default_timezone_get())->format('Y-m-d H:i:s'),
'reassignable' => $this->faker->boolean(),
'termination_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d H:i:s'),
'supplier_id' => Supplier::factory(),
2021-06-10 13:17:44 -07:00
];
}
public function photoshop()
{
return $this->state(function () {
$data = [
'name' => 'Photoshop',
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
2021-06-10 13:17:44 -07:00
'purchase_cost' => '299.99',
'seats' => 10,
'purchase_order' => '13503Q',
'maintained' => true,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
2021-06-10 13:17:44 -07:00
];
return $data;
});
}
public function acrobat()
{
return $this->state(function () {
$data = [
'name' => 'Acrobat',
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
2021-06-10 13:17:44 -07:00
'purchase_cost' => '29.99',
'seats' => 10,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
2021-06-10 13:17:44 -07:00
];
return $data;
});
}
public function indesign()
{
return $this->state(function () {
$data = [
'name' => 'InDesign',
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
2021-06-10 13:17:44 -07:00
'purchase_cost' => '199.99',
'seats' => 10,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
2021-06-10 13:17:44 -07:00
];
Merge branch 'master' into rcs/merge_master_into_develop_for_rc_8 Signed-off-by: snipe <snipe@snipe.net> # Conflicts: # README.md # app/Console/Commands/MoveUploadsToNewDisk.php # app/Http/Controllers/ActionlogController.php # app/Http/Controllers/Api/LicensesController.php # app/Http/Controllers/Api/StatuslabelsController.php # app/Http/Controllers/Assets/AssetCheckinController.php # app/Http/Controllers/Licenses/LicensesController.php # app/Http/Controllers/Users/BulkUsersController.php # app/Http/Requests/AssetCheckoutRequest.php # app/Importer/LicenseImporter.php # app/Models/Actionlog.php # app/Models/License.php # app/Models/User.php # app/Observers/AssetObserver.php # composer.lock # config/version.php # database/factories/LicenseFactory.php # database/migrations/2015_09_21_235926_create_custom_field_custom_fieldset.php # database/migrations/2018_10_18_191228_add_kits_licenses_table.php # database/migrations/2018_10_19_153910_add_kits_table.php # database/migrations/2018_10_19_154013_add_kits_models_table.php # database/migrations/2019_02_07_185953_add_kits_consumables_table.php # database/migrations/2019_02_07_190030_add_kits_accessories_table.php # package-lock.json # package.json # public/css/dist/all.css # public/css/dist/bootstrap-table.css # public/js/dist/bootstrap-table.js # public/mix-manifest.json # resources/lang/ar/general.php # resources/lang/ar/passwords.php # resources/lang/cs/general.php # resources/lang/cs/passwords.php # resources/lang/de/admin/custom_fields/general.php # resources/lang/de/admin/settings/general.php # resources/lang/de/admin/settings/message.php # resources/lang/fr/admin/custom_fields/general.php # resources/lang/fr/admin/hardware/general.php # resources/lang/fr/admin/locations/table.php # resources/lang/fr/admin/settings/message.php # resources/lang/hu/admin/custom_fields/general.php # resources/lang/hu/admin/settings/general.php # resources/lang/hu/general.php # resources/lang/it/admin/settings/general.php # resources/lang/nl/admin/custom_fields/general.php # resources/lang/nl/admin/settings/general.php # resources/lang/nl/general.php # resources/lang/pl/admin/custom_fields/general.php # resources/lang/sv-SE/passwords.php # resources/lang/tr/general.php # resources/views/hardware/view.blade.php # resources/views/partials/bootstrap-table.blade.php # resources/views/reports/activity.blade.php # resources/views/users/print.blade.php
2022-04-28 09:49:06 -07:00
2021-06-10 13:17:44 -07:00
return $data;
});
}
public function office()
{
return $this->state(function () {
$data = [
'name' => 'Office',
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
},
2021-06-10 13:17:44 -07:00
'purchase_cost' => '49.99',
'seats' => 20,
'category_id' => function () {
return Category::where('name', 'Office Software')->first() ?? Category::factory()->licenseOfficeCategory();
},
2021-06-10 13:17:44 -07:00
];
return $data;
});
}
}