2017-10-07 02:27:02 -07:00
|
|
|
<?php
|
2021-06-10 13:19:27 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
2023-03-14 12:50:02 -07:00
|
|
|
use App\Models\Category;
|
2023-03-14 12:01:23 -07:00
|
|
|
use App\Models\Manufacturer;
|
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 02:27:02 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Asset Model Factories
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Factories related exclusively to creating models ..
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
class AccessoryFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = \App\Models\Accessory::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
2023-03-14 11:34:58 -07:00
|
|
|
'user_id' => function () {
|
|
|
|
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
'model_number' => $this->faker->numberBetween(1000000, 50000000),
|
|
|
|
'location_id' => rand(1, 5),
|
|
|
|
];
|
|
|
|
}
|
2017-10-07 02:27:02 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function appleBtKeyboard()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'name' => 'Bluetooth Keyboard',
|
|
|
|
'image' => 'bluetooth.jpg',
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Keyboardss')->first() ?? Category::factory()->accessoryKeyboardCategory();
|
|
|
|
},
|
2023-03-14 12:01:23 -07:00
|
|
|
'manufacturer_id' => function () {
|
|
|
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
'qty' => 10,
|
|
|
|
'min_amt' => 2,
|
|
|
|
'supplier_id' => rand(1, 5),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2017-10-07 02:27:02 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function appleUsbKeyboard()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'name' => 'USB Keyboard',
|
|
|
|
'image' => 'usb-keyboard.jpg',
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Keyboardss')->first() ?? Category::factory()->accessoryKeyboardCategory();
|
|
|
|
},
|
2023-03-14 12:01:23 -07:00
|
|
|
'manufacturer_id' => function () {
|
|
|
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
'qty' => 15,
|
|
|
|
'min_amt' => 2,
|
|
|
|
'supplier_id' => rand(1, 5),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2017-10-07 02:27:02 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function appleMouse()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'name' => 'Magic Mouse',
|
|
|
|
'image' => 'magic-mouse.jpg',
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Mouse')->first() ?? Category::factory()->accessoryMouseCategory();
|
|
|
|
},
|
2023-03-14 12:01:23 -07:00
|
|
|
'manufacturer_id' => function () {
|
|
|
|
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
|
|
|
|
},
|
2021-06-10 13:17:44 -07:00
|
|
|
'qty' => 13,
|
|
|
|
'min_amt' => 2,
|
|
|
|
'supplier_id' => rand(1, 5),
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2017-10-07 02:27:02 -07:00
|
|
|
|
2021-06-10 13:17:44 -07:00
|
|
|
public function microsoftMouse()
|
|
|
|
{
|
|
|
|
return $this->state(function () {
|
|
|
|
return [
|
|
|
|
'name' => 'Sculpt Comfort Mouse',
|
|
|
|
'image' => 'comfort-mouse.jpg',
|
2023-03-14 12:50:02 -07:00
|
|
|
'category_id' => function () {
|
|
|
|
return Category::where('name', 'Mouse')->first() ?? Category::factory()->accessoryMouseCategory();
|
|
|
|
},
|
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
|
|
|
'qty' => 13,
|
|
|
|
'min_amt' => 2,
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|