2017-10-07 04:25:35 -07:00
|
|
|
<?php
|
2021-06-10 13:17:44 -07:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
2022-01-10 10:54:57 -08:00
|
|
|
use App\Models\Category;
|
2023-03-20 11:39:27 -07:00
|
|
|
use App\Models\License;
|
2023-03-14 12:01:23 -07:00
|
|
|
use App\Models\Manufacturer;
|
2023-03-16 12:41:34 -07:00
|
|
|
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
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
class LicenseFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2023-03-20 11:39:27 -07:00
|
|
|
protected $model = License::class;
|
2021-06-10 13:17:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
2024-09-17 14:16:41 -07:00
|
|
|
'created_by' => User::factory()->superuser(),
|
2023-03-16 17:07:46 -07:00
|
|
|
'name' => $this->faker->name(),
|
|
|
|
'license_email' => $this->faker->safeEmail(),
|
|
|
|
'serial' => $this->faker->uuid(),
|
2021-06-10 13:17:44 -07:00
|
|
|
'notes' => 'Created by DB seeder',
|
2022-01-10 10:54:57 -08:00
|
|
|
'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'),
|
2023-03-16 12:41:34 -07:00
|
|
|
'supplier_id' => Supplier::factory(),
|
2023-03-16 17:08:18 -07:00
|
|
|
'category_id' => Category::factory(),
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function photoshop()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
$data = [
|
|
|
|
'name' => 'Photoshop',
|
2023-03-14 12:01:23 -07:00
|
|
|
'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,
|
2023-03-14 12:50:02 -07:00
|
|
|
'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',
|
2023-03-14 12:01:23 -07:00
|
|
|
'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,
|
2023-03-14 12:50:02 -07:00
|
|
|
'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',
|
2023-03-14 12:01:23 -07:00
|
|
|
'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,
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
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',
|
2023-03-14 12:01:23 -07:00
|
|
|
'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,
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Office Software')->first() ?? Category::factory()->licenseOfficeCategory();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|