Apply pint to database directory

This commit is contained in:
snipe
2026-03-13 18:12:37 +00:00
parent 199bdb219f
commit b5a46a370f
218 changed files with 910 additions and 1013 deletions
+3 -3
View File
@@ -144,7 +144,7 @@ class AccessoryFactory extends Factory
});
}
public function checkedOutToUser(User $user = null)
public function checkedOutToUser(?User $user = null)
{
return $this->afterCreating(function (Accessory $accessory) use ($user) {
$accessory->checkouts()->create([
@@ -172,7 +172,7 @@ class AccessoryFactory extends Factory
});
}
public function checkedOutToAsset(Asset $asset = null)
public function checkedOutToAsset(?Asset $asset = null)
{
return $this->afterCreating(function (Accessory $accessory) use ($asset) {
$accessory->checkouts()->create([
@@ -185,7 +185,7 @@ class AccessoryFactory extends Factory
});
}
public function checkedOutToLocation(Location $location = null)
public function checkedOutToLocation(?Location $location = null)
{
return $this->afterCreating(function (Accessory $accessory) use ($location) {
$accessory->checkouts()->create([
+36 -36
View File
@@ -41,18 +41,18 @@ class ActionlogFactory extends Factory
$asset = Asset::inRandomOrder()->RTD()->first();
$asset->update(
[
'assigned_to' => $target->id,
'assigned_type' => User::class,
'location_id' => $target->location_id,
]
);
[
'assigned_to' => $target->id,
'assigned_type' => User::class,
'location_id' => $target->location_id,
]
);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'checkout',
'item_id' => $asset->id,
'item_type' => Asset::class,
'item_type' => Asset::class,
'target_id' => $target->id,
'target_type' => User::class,
];
@@ -66,18 +66,18 @@ class ActionlogFactory extends Factory
$asset = Asset::inRandomOrder()->RTD()->first();
$asset->update(
[
'assigned_to' => $target->id,
'assigned_type' => Location::class,
'location_id' => $target->id,
]
);
[
'assigned_to' => $target->id,
'assigned_type' => Location::class,
'location_id' => $target->id,
]
);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'checkout',
'item_id' => $asset->id,
'item_type' => Asset::class,
'item_type' => Asset::class,
'target_id' => $target->id,
'target_type' => Location::class,
];
@@ -88,10 +88,10 @@ class ActionlogFactory extends Factory
* This sets up an ActionLog representing a manually added note tied to an Asset,
* with an optional User as the creator. If no User is provided, one is generated.
*
* @param User|null $user Optional user to associate as the creator of the note.
* @return \Illuminate\Database\Eloquent\Factories\Factory<ActionLog>
* @param User|null $user Optional user to associate as the creator of the note.
* @return Factory<Actionlog>
*/
public function assetNote(?User $user=null)
public function assetNote(?User $user = null)
{
return $this
->state(function () use ($user) {
@@ -118,10 +118,10 @@ class ActionlogFactory extends Factory
]);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'checkout',
'item_id' => $licenseSeat->license->id,
'item_type' => License::class,
'item_type' => License::class,
'target_id' => $target->id,
'target_type' => User::class,
];
@@ -133,10 +133,10 @@ class ActionlogFactory extends Factory
return $this->state(function () {
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'uploaded',
'item_type' => User::class,
'filename' => $this->faker->unixTime('now'),
'item_type' => User::class,
'filename' => $this->faker->unixTime('now'),
];
});
}
@@ -148,12 +148,12 @@ class ActionlogFactory extends Factory
$asset = Asset::factory()->create();
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'accepted',
'item_id' => $asset->id,
'item_type' => Asset::class,
'target_type' => User::class,
'accept_signature' => $this->faker->unixTime('now'),
'item_type' => Asset::class,
'target_type' => User::class,
'accept_signature' => $this->faker->unixTime('now'),
];
});
}
@@ -165,12 +165,12 @@ class ActionlogFactory extends Factory
$asset = Asset::factory()->create();
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'accepted',
'item_id' => $asset->id,
'item_type' => Asset::class,
'target_type' => User::class,
'filename' => $this->faker->unixTime('now'),
'item_type' => Asset::class,
'target_type' => User::class,
'filename' => $this->faker->unixTime('now'),
];
});
}
@@ -180,10 +180,10 @@ class ActionlogFactory extends Factory
return $this->state(function () {
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'update',
'target_type' => User::class,
'item_type' => User::class,
'target_type' => User::class,
'item_type' => User::class,
];
});
}
+17 -17
View File
@@ -4,7 +4,6 @@ namespace Database\Factories;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\CustomField;
use App\Models\Location;
use App\Models\Statuslabel;
@@ -39,7 +38,7 @@ class AssetFactory extends Factory
},
'created_by' => User::factory()->superuser(),
'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_cost' => $this->faker->randomFloat(2, '299.99', '2999.99'),
'order_number' => (string) $this->faker->numberBetween(1000000, 50000000),
@@ -49,17 +48,16 @@ class AssetFactory extends Factory
'assigned_type' => null,
'next_audit_date' => null,
'last_checkout' => null,
'asset_eol_date' => null
'asset_eol_date' => null,
];
}
public function configure()
{
return $this->afterMaking(function (Asset $asset) {
// calculates the EOL date most of the time, but sometimes sets a random date so we have some explicits
// the explicit boolean gets set in the saving() method on the observer
$asset->asset_eol_date = $this->faker->boolean(5)
// the explicit boolean gets set in the saving() method on the observer
$asset->asset_eol_date = $this->faker->boolean(5)
? CarbonImmutable::parse($asset->purchase_date)->addMonths(rand(0, 20))->format('Y-m-d')
: CarbonImmutable::parse($asset->purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
});
@@ -291,7 +289,7 @@ class AssetFactory extends Factory
});
}
public function assignedToUser(User $user = null)
public function assignedToUser(?User $user = null)
{
return $this->state(function () use ($user) {
return [
@@ -302,7 +300,7 @@ class AssetFactory extends Factory
});
}
public function assignedToLocation(Location $location = null)
public function assignedToLocation(?Location $location = null)
{
return $this->state(function () use ($location) {
return [
@@ -358,20 +356,22 @@ class AssetFactory extends Factory
public function requestable()
{
$id = Statuslabel::factory()->create([
'archived' => false,
'archived' => false,
'deployable' => true,
'pending' => true,
'pending' => true,
])->id;
return $this->state(['status_id' => $id, 'requestable' => true]);
}
public function nonrequestable()
{
$id = Statuslabel::factory()->create([
'archived' => true,
'archived' => true,
'deployable' => false,
'pending' => false,
'pending' => false,
])->id;
return $this->state(['status_id' => $id, 'requestable' => false]);
}
@@ -380,13 +380,12 @@ class AssetFactory extends Factory
return $this->afterCreating(function (Asset $asset) {
$asset->update([
'purchase_date' => null,
'asset_eol_date' => null
'asset_eol_date' => null,
]);
});
}
public function hasEncryptedCustomField(CustomField $field = null)
public function hasEncryptedCustomField(?CustomField $field = null)
{
return $this->state(function () use ($field) {
return [
@@ -395,7 +394,7 @@ class AssetFactory extends Factory
});
}
public function hasMultipleCustomFields(array $fields = null): self
public function hasMultipleCustomFields(?array $fields = null): self
{
return $this->state(function () use ($fields) {
return [
@@ -408,6 +407,7 @@ class AssetFactory extends Factory
* This allows bypassing model level validation if you want to purposefully
* create an asset in an invalid state. Validation is turned back on
* after the model is created via the factory.
*
* @return AssetFactory
*/
public function canBeInvalidUponCreation()
+5 -5
View File
@@ -3,13 +3,13 @@
namespace Database\Factories;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\CustomField;
use App\Models\CustomFieldset;
use App\Models\Depreciation;
use App\Models\Manufacturer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Category;
class AssetModelFactory extends Factory
{
@@ -201,7 +201,7 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'iMac Pro',
'category_id' => function (){
'category_id' => function () {
return Category::where('name', 'Desktops')->first() ?? Category::factory()->assetDesktopCategory();
},
'manufacturer_id' => function () {
@@ -247,7 +247,7 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'OptiPlex',
'category_id' => function (){
'category_id' => function () {
return Category::where('name', 'Desktops')->first() ?? Category::factory()->assetDesktopCategory();
},
'manufacturer_id' => function () {
@@ -432,7 +432,7 @@ class AssetModelFactory extends Factory
});
}
public function hasEncryptedCustomField(CustomField $field = null)
public function hasEncryptedCustomField(?CustomField $field = null)
{
return $this->state(function () use ($field) {
return [
@@ -441,7 +441,7 @@ class AssetModelFactory extends Factory
});
}
public function hasMultipleCustomFields(array $fields = null)
public function hasMultipleCustomFields(?array $fields = null)
{
return $this->state(function () use ($fields) {
return [
+98 -100
View File
@@ -2,9 +2,9 @@
namespace Database\Factories;
use App\Models\Category;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Category;
class CategoryFactory extends Factory
{
@@ -28,7 +28,7 @@ class CategoryFactory extends Factory
'created_by' => User::factory()->superuser(),
'eula_text' => $this->faker->paragraph(),
'name' => $this->faker->catchPhrase(),
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'require_acceptance' => false,
'tag_color' => $this->faker->hexColor(),
'use_default_eula' => false,
@@ -64,115 +64,113 @@ class CategoryFactory extends Factory
]);
}
// usage: Category::factory()->assetTabletCategory();
public function assetTabletCategory()
{
return $this->state([
'name' => 'Tablets',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetTabletCategory();
public function assetTabletCategory()
{
return $this->state([
'name' => 'Tablets',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetMobileCategory();
public function assetMobileCategory()
{
return $this->state([
'name' => 'Mobile Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetMobileCategory();
public function assetMobileCategory()
{
return $this->state([
'name' => 'Mobile Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetConferenceCategory();
public function assetConferenceCategory()
{
return $this->state([
'name' => 'Conference Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetConferenceCategory();
public function assetConferenceCategory()
{
return $this->state([
'name' => 'Conference Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetVoipCategory();
public function assetVoipCategory()
{
return $this->state([
'name' => 'VOIP Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->assetVoipCategory();
public function assetVoipCategory()
{
return $this->state([
'name' => 'VOIP Phones',
'category_type' => 'asset',
]);
}
// usage: Category::factory()->accessoryKeyboardCategory();
public function accessoryKeyboardCategory()
{
return $this->state([
'name' => 'Keyboards',
'category_type' => 'accessory',
]);
}
// usage: Category::factory()->accessoryKeyboardCategory();
public function accessoryKeyboardCategory()
{
return $this->state([
'name' => 'Keyboards',
'category_type' => 'accessory',
]);
}
// usage: Category::factory()->accessoryMouseCategory();
public function accessoryMouseCategory()
{
return $this->state([
'name' => 'Mouse',
'category_type' => 'accessory',
]);
}
// usage: Category::factory()->componentHddCategory();
public function componentHddCategory()
{
return $this->state([
'name' => 'HDD/SSD',
'category_type' => 'component',
]);
}
// usage: Category::factory()->accessoryMouseCategory();
public function accessoryMouseCategory()
{
return $this->state([
'name' => 'Mouse',
'category_type' => 'accessory',
]);
}
// usage: Category::factory()->componentRamCategory();
public function componentRamCategory()
{
return $this->state([
'name' => 'RAM',
'category_type' => 'component',
]);
}
// usage: Category::factory()->componentHddCategory();
public function componentHddCategory()
{
return $this->state([
'name' => 'HDD/SSD',
'category_type' => 'component',
]);
}
// usage: Category::factory()->consumablePaperCategory();
public function consumablePaperCategory()
{
return $this->state([
'name' => 'Printer Paper',
'category_type' => 'consumable',
]);
}
// usage: Category::factory()->componentRamCategory();
public function componentRamCategory()
{
return $this->state([
'name' => 'RAM',
'category_type' => 'component',
]);
}
// usage: Category::factory()->consumableInkCategory();
public function consumableInkCategory()
{
return $this->state([
'name' => 'Printer Ink',
'category_type' => 'consumable',
]);
}
// usage: Category::factory()->consumablePaperCategory();
public function consumablePaperCategory()
{
return $this->state([
'name' => 'Printer Paper',
'category_type' => 'consumable',
]);
}
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseGraphicsCategory()
{
return $this->state([
'name' => 'Graphics Software',
'category_type' => 'license',
]);
}
// usage: Category::factory()->consumableInkCategory();
public function consumableInkCategory()
{
return $this->state([
'name' => 'Printer Ink',
'category_type' => 'consumable',
]);
}
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseGraphicsCategory()
{
return $this->state([
'name' => 'Graphics Software',
'category_type' => 'license',
]);
}
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseOfficeCategory()
{
return $this->state([
'name' => 'Office Software',
'category_type' => 'license',
]);
}
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseOfficeCategory()
{
return $this->state([
'name' => 'Office Software',
'category_type' => 'license',
]);
}
public function forAccessories()
{
@@ -23,6 +23,7 @@ class CheckoutAcceptanceFactory extends Factory
'assigned_to_id' => User::factory(),
];
}
protected static bool $skipActionLog = false;
public function withoutActionLog(): static
@@ -48,14 +49,13 @@ class CheckoutAcceptanceFactory extends Factory
if ($acceptance->checkoutable instanceof Asset && $acceptance->assignedTo instanceof User) {
$acceptance->checkoutable->update([
'assigned_to' => $acceptance->assigned_to_id,
'assigned_type'=> get_class($acceptance->assignedTo),
'assigned_to' => $acceptance->assigned_to_id,
'assigned_type' => get_class($acceptance->assignedTo),
]);
}
});
}
public function forAccessory()
{
return $this->state([
+1 -1
View File
@@ -24,7 +24,7 @@ class CompanyFactory extends Factory
return [
'name' => $this->faker->unique()->company(),
'created_by' => 1,
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'tag_color' => $this->faker->hexColor(),
];
}
+8 -7
View File
@@ -2,18 +2,16 @@
namespace Database\Factories;
use App\Models\Accessory;
use App\Models\Asset;
use App\Models\Category;
use App\Models\Company;
use App\Models\Component;
use App\Models\Manufacturer;
use App\Models\Consumable;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Supplier;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Supplier;
class ComponentFactory extends Factory
{
@@ -44,7 +42,7 @@ class ComponentFactory extends Factory
'purchase_cost' => $this->faker->randomFloat(2),
'purchase_date' => $this->faker->dateTime()->format('Y-m-d'),
'qty' => $this->faker->numberBetween(3, 10),
'serial' => $this->faker->uuid(),
'serial' => $this->faker->uuid(),
'supplier_id' => Supplier::factory(),
];
}
@@ -52,6 +50,7 @@ class ComponentFactory extends Factory
public function ramCrucial4()
{
$manufacturer = Manufacturer::where('name', 'Crucial')->first() ?? Manufacturer::factory()->create(['name' => 'Crucial']);
return $this->state(function () use ($manufacturer) {
return [
'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
@@ -69,6 +68,7 @@ class ComponentFactory extends Factory
public function ramCrucial8()
{
$manufacturer = Manufacturer::where('name', 'Crucial')->first() ?? Manufacturer::factory()->create(['name' => 'Crucial']);
return $this->state(function () use ($manufacturer) {
return [
'name' => 'Crucial 8GB DDR3L-1600 SODIMM Memory for Mac',
@@ -85,6 +85,7 @@ class ComponentFactory extends Factory
public function ssdCrucial120()
{
$manufacturer = Manufacturer::where('name', 'Crucial')->first() ?? Manufacturer::factory()->create(['name' => 'Crucial']);
return $this->state(function () use ($manufacturer) {
return [
'name' => 'Crucial BX300 120GB SATA Internal SSD',
@@ -101,6 +102,7 @@ class ComponentFactory extends Factory
public function ssdCrucial240()
{
$manufacturer = Manufacturer::where('name', 'Crucial')->first() ?? Manufacturer::factory()->create(['name' => 'Crucial']);
return $this->state(function () use ($manufacturer) {
return [
'name' => 'Crucial BX300 240GB SATA Internal SSD',
@@ -114,7 +116,7 @@ class ComponentFactory extends Factory
});
}
public function checkedOutToAsset(Asset $asset = null)
public function checkedOutToAsset(?Asset $asset = null)
{
return $this->afterCreating(function (Component $component) use ($asset) {
$component->assets()->attach($component->id, [
@@ -125,5 +127,4 @@ class ComponentFactory extends Factory
]);
});
}
}
+2 -2
View File
@@ -6,10 +6,10 @@ use App\Models\Category;
use App\Models\Company;
use App\Models\Consumable;
use App\Models\Manufacturer;
use App\Models\Supplier;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Supplier;
class ConsumableFactory extends Factory
{
@@ -118,7 +118,7 @@ class ConsumableFactory extends Factory
});
}
public function checkedOutToUser(User $user = null)
public function checkedOutToUser(?User $user = null)
{
return $this->afterCreating(function (Consumable $consumable) use ($user) {
$consumable->users()->attach($consumable->id, [
+2 -3
View File
@@ -138,7 +138,7 @@ class CustomFieldFactory extends Factory
'name' => 'Test Checkbox',
'help_text' => 'This is a sample checkbox.',
'field_values' => "One\r\nTwo\r\nThree",
'element' => 'checkbox',
'element' => 'checkbox',
];
});
}
@@ -150,9 +150,8 @@ class CustomFieldFactory extends Factory
'name' => 'Test Radio',
'help_text' => 'This is a sample radio.',
'field_values' => "One\r\nTwo\r\nThree",
'element' => 'radio',
'element' => 'radio',
];
});
}
}
+9 -9
View File
@@ -2,8 +2,8 @@
namespace Database\Factories;
use App\Models\CustomFieldset;
use App\Models\CustomField;
use App\Models\CustomFieldset;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFieldsetFactory extends Factory
@@ -45,7 +45,7 @@ class CustomFieldsetFactory extends Factory
});
}
public function hasEncryptedCustomField(CustomField $field = null)
public function hasEncryptedCustomField(?CustomField $field = null)
{
return $this->afterCreating(function (CustomFieldset $fieldset) use ($field) {
$field = $field ?? CustomField::factory()->testEncrypted()->create();
@@ -54,17 +54,17 @@ class CustomFieldsetFactory extends Factory
});
}
public function hasMultipleCustomFields(array $fields = null): self
public function hasMultipleCustomFields(?array $fields = null): self
{
return $this->afterCreating(function (CustomFieldset $fieldset) use ($fields) {
if (empty($fields)) {
$mac_address = CustomField::factory()->macAddress()->create();
$ram = CustomField::factory()->ram()->create();
$cpu = CustomField::factory()->cpu()->create();
$mac_address = CustomField::factory()->macAddress()->create();
$ram = CustomField::factory()->ram()->create();
$cpu = CustomField::factory()->cpu()->create();
$fieldset->fields()->attach($mac_address, ['order' => '1', 'required' => false]);
$fieldset->fields()->attach($ram, ['order' => '2', 'required' => false]);
$fieldset->fields()->attach($cpu, ['order' => '3', 'required' => false]);
$fieldset->fields()->attach($mac_address, ['order' => '1', 'required' => false]);
$fieldset->fields()->attach($ram, ['order' => '2', 'required' => false]);
$fieldset->fields()->attach($cpu, ['order' => '3', 'required' => false]);
} else {
foreach ($fields as $field) {
$fieldset->fields()->attach($field, ['order' => '1', 'required' => false]);
+2 -2
View File
@@ -26,8 +26,8 @@ class DepartmentFactory extends Factory
return [
'created_by' => User::factory()->superuser(),
'location_id' => Location::factory(),
'name' => $this->faker->unique()->word() . ' Department',
'notes' => 'Created by DB seeder',
'name' => $this->faker->unique()->word().' Department',
'notes' => 'Created by DB seeder',
'tag_color' => $this->faker->hexColor(),
];
}
+1 -1
View File
@@ -25,7 +25,7 @@ class GroupFactory extends Factory
return [
'created_by' => User::factory()->superuser(),
'name' => $this->faker->name(),
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'permissions' => json_encode([]),
];
}
+6 -10
View File
@@ -3,8 +3,8 @@
namespace Database\Factories;
use App\Models\Import;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Tests\Support\Importing;
/**
@@ -13,19 +13,19 @@ use Tests\Support\Importing;
class ImportFactory extends Factory
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected $model = Import::class;
/**
* @inheritdoc
* {@inheritdoc}
*/
public function definition()
{
return [
'name' => $this->faker->company,
'name' => $this->faker->company,
'file_path' => Str::random().'.csv',
'filesize' => $this->faker->randomDigitNotNull(),
'filesize' => $this->faker->randomDigitNotNull(),
'field_map' => null,
];
}
@@ -106,7 +106,7 @@ class ImportFactory extends Factory
});
}
/**
/**
* Create a license import type.
*
* @return static
@@ -144,8 +144,6 @@ class ImportFactory extends Factory
});
}
/**
* Create an asset model import type.
*
@@ -231,6 +229,4 @@ class ImportFactory extends Factory
return $attributes;
});
}
}
+2 -2
View File
@@ -1,4 +1,5 @@
<?php
namespace Database\Factories;
use App\Models\Category;
@@ -30,7 +31,7 @@ class LicenseFactory extends Factory
'expiration_date' => null,
'license_email' => $this->faker->safeEmail(),
'name' => $this->faker->name(),
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'order_number' => $this->faker->numberBetween(1000000, 50000000),
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
'reassignable' => $this->faker->boolean(),
@@ -95,7 +96,6 @@ class LicenseFactory extends Factory
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
];
return $data;
});
+2 -2
View File
@@ -18,7 +18,7 @@ class LicenseSeatFactory extends Factory
];
}
public function assignedToAsset(Asset $asset = null)
public function assignedToAsset(?Asset $asset = null)
{
return $this->state(function () use ($asset) {
return [
@@ -27,7 +27,7 @@ class LicenseSeatFactory extends Factory
});
}
public function assignedToUser(User $user = null)
public function assignedToUser(?User $user = null)
{
return $this->state(function () use ($user) {
return [
+3 -3
View File
@@ -23,19 +23,19 @@ class LocationFactory extends Factory
'currency' => $this->faker->currencyCode(),
'image' => rand(1, 9).'.jpg',
'name' => $this->faker->city(),
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'state' => $this->faker->stateAbbr(),
'tag_color' => $this->faker->hexColor(),
'zip' => $this->faker->postcode(),
];
}
// one of these can eventuall go away - left temporarily for conflict resolution
public function deleted(): self
{
return $this->state(['deleted_at' => $this->faker->dateTime()]);
}
public function deletedLocation()
{
return $this->state(function () {
+1 -1
View File
@@ -35,7 +35,7 @@ class MaintenanceFactory extends Factory
'url' => $this->faker->url(),
'cost' => $this->faker->randomFloat(),
'created_by' => User::factory()->superuser(),
'image' => $this->faker->numberBetween(1,11).'.png',
'image' => $this->faker->numberBetween(1, 11).'.png',
];
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ class ManufacturerFactory extends Factory
return [
'created_by' => User::factory()->superuser(),
'name' => $this->faker->unique()->company(),
'notes' => 'Created by DB seeder',
'notes' => 'Created by DB seeder',
'support_email' => $this->faker->safeEmail(),
'support_phone' => $this->faker->phoneNumber(),
'tag_color' => $this->faker->hexColor(),
+2 -1
View File
@@ -2,10 +2,11 @@
namespace Database\Factories;
use App\Models\PredefinedKit;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PredefinedKit>
* @extends Factory<PredefinedKit>
*/
class PredefinedKitFactory extends Factory
{
+1 -1
View File
@@ -27,7 +27,7 @@ class ReportTemplateFactory extends Factory
public function shared()
{
return $this->state(function () {
return['is_shared' => 1];
return ['is_shared' => 1];
});
}
+4 -4
View File
@@ -28,7 +28,7 @@ class StatuslabelFactory extends Factory
'created_by' => User::factory()->superuser(),
'deleted_at' => null,
'deployable' => 0,
'name' => $this->faker->sentence(),
'name' => $this->faker->sentence(),
'notes' => '',
'pending' => 0,
'updated_at' => $this->faker->dateTime(),
@@ -87,7 +87,7 @@ class StatuslabelFactory extends Factory
{
return $this->state(function () {
return [
'name' => 'Out for Repair',
'name' => 'Out for Repair',
'default_label' => 0,
];
});
@@ -97,7 +97,7 @@ class StatuslabelFactory extends Factory
{
return $this->state(function () {
return [
'name' => 'Broken - Not Fixable',
'name' => 'Broken - Not Fixable',
'default_label' => 0,
];
});
@@ -107,7 +107,7 @@ class StatuslabelFactory extends Factory
{
return $this->state(function () {
return [
'name' => 'Lost/Stolen',
'name' => 'Lost/Stolen',
'default_label' => 0,
];
});
+2 -2
View File
@@ -30,13 +30,13 @@ class SupplierFactory extends Factory
'country' => $this->faker->countryCode(),
'created_by' => User::factory()->superuser(),
'email' => $this->faker->safeEmail(),
'fax' => $this->faker->phoneNumber(),
'fax' => $this->faker->phoneNumber(),
'name' => $this->faker->company(),
'notes' => $this->faker->text(191), // Supplier notes can be a max of 255 characters.
'phone' => $this->faker->phoneNumber(),
'state' => $this->faker->stateAbbr(),
'tag_color' => $this->faker->hexColor(),
'url' => $this->faker->url(),
'url' => $this->faker->url(),
'zip' => $this->faker->postCode(),
];
}
-4
View File
@@ -5,7 +5,6 @@ namespace Database\Factories;
use App\Models\Company;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use \Auth;
/**
* @extends Factory<User>
@@ -53,7 +52,6 @@ class UserFactory extends Factory
});
}
public function firstAdmin()
{
return $this->state(function () {
@@ -362,7 +360,6 @@ class UserFactory extends Factory
return $this->appendPermission(['customfields.view' => '1']);
}
public function deleteCustomFields()
{
return $this->appendPermission(['customfields.delete' => '1']);
@@ -408,7 +405,6 @@ class UserFactory extends Factory
return $this->appendPermission(['assets.audit' => '1']);
}
private function appendPermission(array $permission)
{
return $this->state(function ($currentState) use ($permission) {
@@ -1,4 +1,5 @@
<?php
/**
* Part of the Sentry package.
*
@@ -11,9 +12,11 @@
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @version 2.0.0
*
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
*
* @link http://cartalyst.com
*/
@@ -1,4 +1,5 @@
<?php
/**
* Part of the Sentry package.
*
@@ -11,9 +12,11 @@
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @version 2.0.0
*
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
*
* @link http://cartalyst.com
*/
@@ -1,4 +1,5 @@
<?php
/**
* Part of the Sentry package.
*
@@ -11,9 +12,11 @@
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @version 2.0.0
*
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
*
* @link http://cartalyst.com
*/
@@ -1,4 +1,5 @@
<?php
/**
* Part of the Sentry package.
*
@@ -11,9 +12,11 @@
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @version 2.0.0
*
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
*
* @link http://cartalyst.com
*/
@@ -6,17 +6,16 @@ class CreateTempLicensesTable extends Migration
{
/**
* Run the migrations.
*
*
* This migration is overwritten by a later migration - 2013_11_25_recreate_licenses_table.php
*
* @return void
*/
public function up()
{
//
}
/**
@@ -9,9 +9,7 @@ class AddLicenseNameToLicenses extends Migration
*
* @return void
*/
public function up()
{
}
public function up() {}
/**
* Reverse the migrations.
@@ -18,7 +18,7 @@ class CreateDepreciationsTable extends Migration
$table->timestamps();
$table->integer('user_id')->nullable();
$table->engine = 'InnoDB';
//$table->foreign('user_id')->references('id')->on('users');
// $table->foreign('user_id')->references('id')->on('users');
});
}
@@ -28,6 +28,6 @@ class CreateHistoryTable extends Migration
*/
public function down()
{
//Schema::drop('history');
// Schema::drop('history');
}
}
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddPhysicalToAssets extends Migration
{
@@ -14,7 +13,7 @@ class AddPhysicalToAssets extends Migration
{
//
Schema::table('assets', function ($table) {
//$table->boolean('physical')->default(1);
// $table->boolean('physical')->default(1);
$table->dropColumn('checkedout_to');
});
}
@@ -13,8 +13,8 @@ class SetNullvaluesForUser extends Migration
{
//
// $prefix = DB::getTablePrefix();
// DB::statement('ALTER TABLE '.$prefix.'users MODIFY phone varchar(20) null');
// DB::statement('ALTER TABLE '.$prefix.'users MODIFY jobtitle varchar(50) null');
// DB::statement('ALTER TABLE '.$prefix.'users MODIFY phone varchar(20) null');
// DB::statement('ALTER TABLE '.$prefix.'users MODIFY jobtitle varchar(50) null');
}
/**
@@ -13,7 +13,7 @@ class EditsToSettingsTable extends Migration
{
Schema::table('settings', function ($table) {
// $table->dropColumn('option_label');
//$table->dropColumn('option_name');
// $table->dropColumn('option_name');
// $table->dropColumn('option_value');
$table->integer('per_page')->default(20);
$table->string('site_name', '100')->default('Snipe IT Asset Management');
@@ -11,7 +11,7 @@ class ReCreateLicensesTable extends Migration
*/
public function up()
{
if (!Schema::hasTable('licenses')) {
if (! Schema::hasTable('licenses')) {
Schema::create('licenses', function ($table) {
$table->increments('id');
$table->string('name');
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterDefaultLicenseDepreciationId extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterDefaultValuesLicenses extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAssetNameToSettings extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MakeAssetLogCheckedoutToNullable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MakeAssetLogPurchasedateToNullable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddSuppliers extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddSupplierIdToAsset extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddZipToSupplier extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddUrlToSupplier extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddEmployeeIdToUsers extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddRequestableToAssets extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAssetToSoftware extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MakeAssetIdInLogsNullable extends Migration
{
@@ -18,47 +18,47 @@ class Alpha042Release extends Migration
});
// DB::statement('UPDATE '.$prefix.'assets SET status_id="0" where status_id is null');
// DB::statement('UPDATE '.$prefix.'assets SET purchase_cost=0 where purchase_cost is null');
// DB::statement('UPDATE '.$prefix.'models SET eol=0 where eol is null');
// DB::statement('UPDATE '.$prefix.'users SET location_id=0 where location_id is null');
// DB::statement('UPDATE '.$prefix.'assets SET asset_tag=" " WHERE asset_tag is null');
// DB::statement('UPDATE '.$prefix.'locations SET state=" " where state is null');
// DB::statement('UPDATE '.$prefix.'models SET manufacturer_id="0" where manufacturer_id is null');
// DB::statement('UPDATE '.$prefix.'models SET category_id="0" where category_id is null');
// DB::statement('UPDATE '.$prefix.'assets SET purchase_cost=0 where purchase_cost is null');
// DB::statement('UPDATE '.$prefix.'models SET eol=0 where eol is null');
// DB::statement('UPDATE '.$prefix.'users SET location_id=0 where location_id is null');
// DB::statement('UPDATE '.$prefix.'assets SET asset_tag=" " WHERE asset_tag is null');
// DB::statement('UPDATE '.$prefix.'locations SET state=" " where state is null');
// DB::statement('UPDATE '.$prefix.'models SET manufacturer_id="0" where manufacturer_id is null');
// DB::statement('UPDATE '.$prefix.'models SET category_id="0" where category_id is null');
// DB::statement('ALTER TABLE '.$prefix.'assets '
// . 'MODIFY COLUMN name VARCHAR(255) NULL , '
// . 'MODIFY COLUMN asset_tag VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN order_number VARCHAR(255) NULL , '
// . 'MODIFY COLUMN assigned_to INT(11) NULL , '
// . 'MODIFY COLUMN notes TEXT NULL , '
// . 'MODIFY COLUMN archived TINYINT(1) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN depreciate TINYINT(1) NOT NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'licenses '
// . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NULL , '
// . 'MODIFY COLUMN depreciate TINYINT(1) NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'license_seats '
// . 'MODIFY COLUMN assigned_to INT(11) NULL ');
//
// DB::statement('ALTER TABLE '.$prefix.'locations '
// . 'MODIFY COLUMN state VARCHAR(255) NOT NULL ,'
// . 'MODIFY COLUMN address2 VARCHAR(255) NULL ,'
// . 'MODIFY COLUMN zip VARCHAR(10) NULL ');
//
// DB::statement('ALTER TABLE '.$prefix.'models '
// . 'MODIFY COLUMN modelno VARCHAR(255) NULL , '
// . 'MODIFY COLUMN manufacturer_id INT(11) NOT NULL , '
// . 'MODIFY COLUMN category_id INT(11) NOT NULL , '
// . 'MODIFY COLUMN depreciation_id INT(11) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN eol INT(11) NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'users '
// . 'MODIFY COLUMN first_name VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN last_name VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN location_id INT(11) NOT NULL');
// DB::statement('ALTER TABLE '.$prefix.'assets '
// . 'MODIFY COLUMN name VARCHAR(255) NULL , '
// . 'MODIFY COLUMN asset_tag VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN order_number VARCHAR(255) NULL , '
// . 'MODIFY COLUMN assigned_to INT(11) NULL , '
// . 'MODIFY COLUMN notes TEXT NULL , '
// . 'MODIFY COLUMN archived TINYINT(1) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN depreciate TINYINT(1) NOT NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'licenses '
// . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NULL , '
// . 'MODIFY COLUMN depreciate TINYINT(1) NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'license_seats '
// . 'MODIFY COLUMN assigned_to INT(11) NULL ');
//
// DB::statement('ALTER TABLE '.$prefix.'locations '
// . 'MODIFY COLUMN state VARCHAR(255) NOT NULL ,'
// . 'MODIFY COLUMN address2 VARCHAR(255) NULL ,'
// . 'MODIFY COLUMN zip VARCHAR(10) NULL ');
//
// DB::statement('ALTER TABLE '.$prefix.'models '
// . 'MODIFY COLUMN modelno VARCHAR(255) NULL , '
// . 'MODIFY COLUMN manufacturer_id INT(11) NOT NULL , '
// . 'MODIFY COLUMN category_id INT(11) NOT NULL , '
// . 'MODIFY COLUMN depreciation_id INT(11) NOT NULL DEFAULT "0" , '
// . 'MODIFY COLUMN eol INT(11) NULL DEFAULT "0"');
//
// DB::statement('ALTER TABLE '.$prefix.'users '
// . 'MODIFY COLUMN first_name VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN last_name VARCHAR(255) NOT NULL , '
// . 'MODIFY COLUMN location_id INT(11) NOT NULL');
}
/**
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MakeLocationIdNullable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddRtdLocationToAssets extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterSupplierStateTo32 extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddDisplayCheckoutDate extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddEolDisplayToSettings extends Migration
{
@@ -2,7 +2,6 @@
use App\Models\Group;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateGroupFieldForReporting extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddFieldsToLicenses extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ChangeLicenceType extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddFieldsMaintainedTermToLicenses extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class IncreaseUserFieldLengths extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddSoftDeletedToLog extends Migration
{
@@ -12,8 +11,8 @@ class AddSoftDeletedToLog extends Migration
*/
public function up()
{
//$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
//$platform->registerDoctrineTypeMapping('enum', 'string');
// $platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
// $platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('asset_logs', function ($table) {
$table->string('asset_type', 100)->nullable()->change();
@@ -24,7 +23,7 @@ class AddSoftDeletedToLog extends Migration
// Schema::table('asset_logs', function ($table) {
// $table->renameColumn('added_on', 'created_at');
// $table->timestamp('updated_at');
// $table->softDeletes();
// $table->softDeletes();
// });
}
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class FixBadAssignedToIds extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MigrateDataToNewStatuses extends Migration
{
@@ -34,7 +33,7 @@ class MigrateDataToNewStatuses extends Migration
$rtds = DB::table('assets')->where('status_id', 0)->where('physical', '1')->get();
foreach ($rtds as $rtd) {
//DB::update('update users set votes = 100 where name = ?', array('John'));
// DB::update('update users set votes = 100 where name = ?', array('John'));
DB::update('update '.DB::getTablePrefix().'assets set status_id = ? where status_id = 0 AND physical=1', $rtd_id);
}
}
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MigrateMakeLicenseAssignedNull extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MigrateCreateRequestsTable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddMacAddressToAsset extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ChangeLicenseNotesType extends Migration
{
@@ -23,7 +22,5 @@ class ChangeLicenseNotesType extends Migration
*
* @return void
*/
public function down()
{
}
public function down() {}
}
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddLocalonlyToSettings extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddLogoAndColorsToSettings extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAlertsToSettings extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddEulaFields extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAccessoriesTable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAccessoriesUserTable extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddDeletedAtModels extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddCategoryType extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateAcceptedAtToAcceptanceId extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddQrTypeToSettings extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddNoteToUser extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class FixDefaultForUserNotes extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateConsumables extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class MoveEmailToUsername extends Migration
{
@@ -24,6 +23,6 @@ class MoveEmailToUsername extends Migration
public function down()
{
//
//DB::statement('ALTER TABLE `users` MODIFY `notes` varchar(255);');
// DB::statement('ALTER TABLE `users` MODIFY `notes` varchar(255);');
}
}
@@ -1,58 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAssetMaintenancesTable extends Migration
class CreateAssetMaintenancesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('asset_maintenances', function (Blueprint $table) {
$table->increments('id');
$table->integer('asset_id')
->unsigned();
$table->integer('supplier_id')
->unsigned();
$table->string('asset_maintenance_type');
$table->string('title', 100);
$table->boolean('is_warranty');
$table->date('start_date');
$table->date('completion_date')
->nullable();
$table->integer('asset_maintenance_time')
->nullable();
$table->longText('notes')
->nullable();
$table->decimal('cost', 10, 2)
->nullable();
$table->dateTime('deleted_at')
->nullable();
$table->timestamps();
});
}
protected function getEnumFields()
{
return [
trans('admin/maintenances/general.maintenance'),
trans('admin/maintenances/general.repair'),
trans('admin/maintenances/general.upgrade'),
];
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('asset_maintenances');
}
Schema::create('asset_maintenances', function (Blueprint $table) {
$table->increments('id');
$table->integer('asset_id')
->unsigned();
$table->integer('supplier_id')
->unsigned();
$table->string('asset_maintenance_type');
$table->string('title', 100);
$table->boolean('is_warranty');
$table->date('start_date');
$table->date('completion_date')
->nullable();
$table->integer('asset_maintenance_time')
->nullable();
$table->longText('notes')
->nullable();
$table->decimal('cost', 10, 2)
->nullable();
$table->dateTime('deleted_at')
->nullable();
$table->timestamps();
});
}
protected function getEnumFields()
{
return [
trans('admin/maintenances/general.maintenance'),
trans('admin/maintenances/general.repair'),
trans('admin/maintenances/general.upgrade'),
];
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('asset_maintenances');
}
}
@@ -1,6 +1,6 @@
<?php
//use Illuminate\Database\Schema\Blueprint;
// use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCustomFieldsTable extends Migration
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddCheckinEmailToCategoryTable extends Migration
{
@@ -1,203 +1,208 @@
<?php
use App\Models\Actionlog;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\Actionlog;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddThreadIdToAssetLogsTable extends Migration
class AddThreadIdToAssetLogsTable extends Migration
{
/**
* currentAssetId
*
* @var int
*/
protected $currentAssetId = null;
/**
* currentAssetLogId
*
* @var int
*/
protected $currentAssetLogId = null;
/**
* assetLogs
*
* @var array
*/
protected $assetLogs = null;
/**
* startOfCurrentThread
*
* @var bool
*/
protected $startOfCurrentThread = true;
/**
* threadStartingActionTypes
*
* @var array
*/
protected $threadStartingActionTypes = ['checkout', 'requested'];
/**
* threadFinalActionTypes
*
* @var array
*/
protected $threadFinalActionTypes = ['checkin from'];
/**
* actionlog
*
* @var \Actionlog
*/
private $actionlog;
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
/**
* currentAssetId
*
* @var int
*/
protected $currentAssetId = null;
/**
* currentAssetLogId
*
* @var int
*/
protected $currentAssetLogId = null;
// if (!Schema::hasColumn('asset_logs', 'thread_id')) {
/**
* assetLogs
*
* @var array
*/
protected $assetLogs = null;
// Schema::table( 'asset_logs', function ( Blueprint $table ) {
/**
* startOfCurrentThread
*
* @var bool
*/
protected $startOfCurrentThread = true;
// $table->integer( 'thread_id' )
// ->nullable()
// ->default( null );
// $table->index( 'thread_id' );
// } );
// }
/**
* threadStartingActionTypes
*
* @var array
*/
protected $threadStartingActionTypes = ['checkout', 'requested'];
// $this->actionlog = new App\Models\Actionlog();
// $this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
/**
* threadFinalActionTypes
*
* @var array
*/
protected $threadFinalActionTypes = ['checkin from'];
// foreach ($this->assetLogs as $assetLog) {
/**
* actionlog
*
* @var \Actionlog
*/
private $actionlog;
// if ($this->hasAssetChanged( $assetLog )) {
// $this->resetCurrentAssetInformation( $assetLog );
// }
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// if ($this->hasBegunNewChain( $assetLog )) {
// $this->startOfCurrentThread = false;
// continue;
// }
// if (!Schema::hasColumn('asset_logs', 'thread_id')) {
// $this->updateAssetLogWithThreadInformation( $assetLog );
// Schema::table( 'asset_logs', function ( Blueprint $table ) {
// if ($this->hasReachedEndOfChain( $assetLog )
// ) {
// $this->clearCurrentAssetInformation();
// }
// $table->integer( 'thread_id' )
// ->nullable()
// ->default( null );
// $table->index( 'thread_id' );
// } );
// }
// $this->actionlog = new App\Models\Actionlog();
// $this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
// foreach ($this->assetLogs as $assetLog) {
// if ($this->hasAssetChanged( $assetLog )) {
// $this->resetCurrentAssetInformation( $assetLog );
// }
// if ($this->hasBegunNewChain( $assetLog )) {
// $this->startOfCurrentThread = false;
// continue;
// }
// $this->updateAssetLogWithThreadInformation( $assetLog );
// if ($this->hasReachedEndOfChain( $assetLog )
// ) {
// $this->clearCurrentAssetInformation();
// }
// }
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Schema::table('asset_logs', function (Blueprint $table) {
// $table->dropIndex('thread_id');
// $table->dropColumn('thread_id');
// });
}
/**
* hasAssetChanged
*
* @param $assetLog
*
* @return bool
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function hasAssetChanged($assetLog)
{
return $assetLog->asset_id !== $this->currentAssetId;
}
/**
* resetCurrentAssetInformation
*
* @param $assetLog
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function resetCurrentAssetInformation($assetLog)
{
$this->currentAssetId = $assetLog->asset_id;
$this->currentAssetLogId = $assetLog->id;
$this->startOfCurrentThread = true;
}
/**
* hasReachedEndOfChain
*
* @param $assetLog
*
* @return bool
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function hasReachedEndOfChain($assetLog)
{
return in_array($assetLog->action_type, $this->threadFinalActionTypes)
&& $this->startOfCurrentThread == false;
}
/**
* clearCurrentAssetInformation
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function clearCurrentAssetInformation()
{
$this->startOfCurrentThread = true;
$this->currentAssetLogId = null;
$this->currentAssetId = null;
}
/**
* updateAssetLogWithThreadInformation
*
* @param $assetLog
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function updateAssetLogWithThreadInformation($assetLog)
{
$loadedAssetLog = Actionlog::find($assetLog->id);
$loadedAssetLog->thread_id = $this->currentAssetLogId;
$loadedAssetLog->update();
unset($loadedAssetLog);
}
/**
* hasBegunNewChain
*
* @param $assetLog
*
* @return bool
* @author Vincent Sposato <vincent.sposato@gmail.com>
* @version v1.0
*/
protected function hasBegunNewChain($assetLog)
{
return in_array($assetLog->action_type, $this->threadStartingActionTypes)
&& $this->startOfCurrentThread == true;
}
// }
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Schema::table('asset_logs', function (Blueprint $table) {
// $table->dropIndex('thread_id');
// $table->dropColumn('thread_id');
// });
}
/**
* hasAssetChanged
*
*
* @return bool
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function hasAssetChanged($assetLog)
{
return $assetLog->asset_id !== $this->currentAssetId;
}
/**
* resetCurrentAssetInformation
*
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function resetCurrentAssetInformation($assetLog)
{
$this->currentAssetId = $assetLog->asset_id;
$this->currentAssetLogId = $assetLog->id;
$this->startOfCurrentThread = true;
}
/**
* hasReachedEndOfChain
*
*
* @return bool
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function hasReachedEndOfChain($assetLog)
{
return in_array($assetLog->action_type, $this->threadFinalActionTypes)
&& $this->startOfCurrentThread == false;
}
/**
* clearCurrentAssetInformation
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function clearCurrentAssetInformation()
{
$this->startOfCurrentThread = true;
$this->currentAssetLogId = null;
$this->currentAssetId = null;
}
/**
* updateAssetLogWithThreadInformation
*
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function updateAssetLogWithThreadInformation($assetLog)
{
$loadedAssetLog = Actionlog::find($assetLog->id);
$loadedAssetLog->thread_id = $this->currentAssetLogId;
$loadedAssetLog->update();
unset($loadedAssetLog);
}
/**
* hasBegunNewChain
*
*
* @return bool
*
* @author Vincent Sposato <vincent.sposato@gmail.com>
*
* @version v1.0
*/
protected function hasBegunNewChain($assetLog)
{
return in_array($assetLog->action_type, $this->threadStartingActionTypes)
&& $this->startOfCurrentThread == true;
}
}
@@ -1,7 +1,7 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateCustomFieldCustomFieldset extends Migration
{
@@ -1,5 +1,8 @@
<?php
use App\Models\AssetModel;
use App\Models\CustomField;
use App\Models\CustomFieldset;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
@@ -12,23 +15,23 @@ class MigrateMacAddress extends Migration
*/
public function up()
{
//DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
// DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$f2 = new \App\Models\CustomFieldset(['name' => 'Asset with MAC Address']);
$f2->timestamps = false; //when this model was first created, it had no timestamps. But later on it gets them.
$f2 = new CustomFieldset(['name' => 'Asset with MAC Address']);
$f2->timestamps = false; // when this model was first created, it had no timestamps. But later on it gets them.
if (! $f2->save()) {
throw new Exception("couldn't save customfieldset");
}
$macid = DB::table('custom_fields')->insertGetId([
'name' => 'MAC Address',
'format' => \App\Models\CustomField::PREDEFINED_FORMATS['MAC'],
'element'=>'text', ]);
'format' => CustomField::PREDEFINED_FORMATS['MAC'],
'element' => 'text', ]);
if (! $macid) {
throw new Exception("Can't save MAC Custom field: $macid");
}
$f2->fields()->attach($macid, ['required' => false, 'order' => 1]);
\App\Models\AssetModel::where(['show_mac_address' => true])->update(['fieldset_id'=>$f2->id]);
AssetModel::where(['show_mac_address' => true])->update(['fieldset_id' => $f2->id]);
Schema::table('assets', function (Blueprint $table) {
$table->renameColumn('mac_address', '_snipeit_mac_address');
@@ -48,7 +51,7 @@ class MigrateMacAddress extends Migration
*/
public function down()
{
$f = \App\Models\CustomFieldset::where(['name' => 'Asset with MAC Address'])->first();
$f = CustomFieldset::where(['name' => 'Asset with MAC Address'])->first();
if ($f) {
$f->fields()->delete();
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddAccessoryConsumablePriceInfo extends Migration
{
@@ -22,7 +22,7 @@ class FixDefaultsAccessories extends Migration
//
// DB::statement('ALTER TABLE `'.DB::getTablePrefix().'accessories` MODIFY `order_number` varchar(255) DEFAULT NULL;');
//
//
// DB::statement('ALTER TABLE `'.DB::getTablePrefix().'consumables` MODIFY `order_number` varchar(255) DEFAULT NULL;');
}
@@ -14,7 +14,7 @@ class AddCompanyIdToConsumablesTable extends Migration
{
Schema::table('consumables', function (Blueprint $table) {
$table->integer('company_id')->unsigned()->nullable();
//$table->foreign('company_id')->references('id')->on('companies');
// $table->foreign('company_id')->references('id')->on('companies');
});
}
@@ -26,7 +26,7 @@ class AddCompanyIdToConsumablesTable extends Migration
public function down()
{
Schema::table('consumables', function (Blueprint $table) {
//$table->dropForeign('consumables_company_id_foreign');
// $table->dropForeign('consumables_company_id_foreign');
$table->dropColumn('company_id');
});
}
@@ -24,7 +24,7 @@ class AddImageToAssets extends Migration
* field already exists. Thanks, I hate it. - snipe
*/
Schema::table('assets', function (Blueprint $table) {
if (!Schema::hasColumn('assets', 'image')) {
if (! Schema::hasColumn('assets', 'image')) {
$table->text('image')->after('notes')->nullable()->default(null);
}
});
@@ -38,8 +38,8 @@ class AddImageToAssets extends Migration
public function down()
{
/**
* I'm leaving this one out, since it could destroy data that was already long-existing.
*/
/**
* I'm leaving this one out, since it could destroy data that was already long-existing.
*/
}
}
@@ -14,7 +14,7 @@ class AddCompanyIdToAccessoriesTable extends Migration
{
Schema::table('accessories', function (Blueprint $table) {
$table->integer('company_id')->unsigned()->nullable();
//$table->foreign('company_id')->references('id')->on('companies');
// $table->foreign('company_id')->references('id')->on('companies');
});
}
@@ -26,7 +26,7 @@ class AddCompanyIdToAccessoriesTable extends Migration
public function down()
{
Schema::table('accessories', function (Blueprint $table) {
//$table->dropForeign('accessories_company_id_foreign');
// $table->dropForeign('accessories_company_id_foreign');
$table->dropColumn('company_id');
});
}
@@ -14,7 +14,7 @@ class AddCompanyIdToUsersTable extends Migration
{
Schema::table('users', function (Blueprint $table) {
$table->integer('company_id')->unsigned()->nullable();
//$table->foreign('company_id')->references('id')->on('companies');
// $table->foreign('company_id')->references('id')->on('companies');
});
}
@@ -26,7 +26,7 @@ class AddCompanyIdToUsersTable extends Migration
public function down()
{
Schema::table('users', function (Blueprint $table) {
//$table->dropForeign('users_company_id_foreign');
// $table->dropForeign('users_company_id_foreign');
$table->dropColumn('company_id');
});
}
@@ -14,7 +14,7 @@ class AddCompanyIdToLicensesTable extends Migration
{
Schema::table('licenses', function (Blueprint $table) {
$table->integer('company_id')->unsigned()->nullable();
//$table->foreign('company_id')->references('id')->on('companies');
// $table->foreign('company_id')->references('id')->on('companies');
});
}
@@ -26,7 +26,7 @@ class AddCompanyIdToLicensesTable extends Migration
public function down()
{
Schema::table('licenses', function (Blueprint $table) {
//$table->dropForeign('licenses_company_id_foreign');
// $table->dropForeign('licenses_company_id_foreign');
$table->dropColumn('company_id');
});
}
@@ -14,7 +14,7 @@ class AddCompanyIdToAssetsTable extends Migration
{
Schema::table('assets', function (Blueprint $table) {
$table->integer('company_id')->unsigned()->nullable();
//$table->foreign('company_id')->references('id')->on('companies');
// $table->foreign('company_id')->references('id')->on('companies');
});
}
@@ -22,7 +22,7 @@ class AddLdapFieldsToSettings extends Migration
$table->string('ldap_username_field')->nullable()->default('samaccountname');
$table->string('ldap_lname_field')->nullable()->default('sn');
$table->string('ldap_fname_field')->nullable()->default('givenname');
$table->string('ldap_auth_filter_query')->nullable()->default('uid=');
$table->string('ldap_auth_filter_query')->nullable()->default('uid=');
$table->integer('ldap_version')->nullable()->default(3);
$table->string('ldap_active_flag')->nullable()->default(null);
$table->string('ldap_emp_num')->nullable()->default(null);
@@ -1,7 +1,7 @@
<?php
use App\Models\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ImportLdapSettings extends Migration
{
@@ -12,7 +12,7 @@ class ImportLdapSettings extends Migration
*/
public function up()
{
$settings = \App\Models\Setting::first();
$settings = Setting::first();
// Only update the settings record if there IS an LDAP Config
// AND the Settings table doesn't already have LDAP settings in it
@@ -13,30 +13,30 @@ class RemoveFkCompanyId extends Migration
public function up()
{
//
// Schema::table('users', function(Blueprint $table)
// {
// $table->dropForeign('users_company_id_foreign');
// });
//
// Schema::table('accessories', function(Blueprint $table)
// {
// $table->dropForeign('accessories_company_id_foreign');
// });
//
// Schema::table('assets', function(Blueprint $table)
// {
// $table->dropForeign('assets_company_id_foreign');
// });
//
// Schema::table('consumables', function(Blueprint $table)
// {
// $table->dropForeign('consumables_company_id_foreign');
// });
//
// Schema::table('licenses', function(Blueprint $table)
// {
// $table->dropForeign('licenses_company_id_foreign');
// });
// Schema::table('users', function(Blueprint $table)
// {
// $table->dropForeign('users_company_id_foreign');
// });
//
// Schema::table('accessories', function(Blueprint $table)
// {
// $table->dropForeign('accessories_company_id_foreign');
// });
//
// Schema::table('assets', function(Blueprint $table)
// {
// $table->dropForeign('assets_company_id_foreign');
// });
//
// Schema::table('consumables', function(Blueprint $table)
// {
// $table->dropForeign('consumables_company_id_foreign');
// });
//
// Schema::table('licenses', function(Blueprint $table)
// {
// $table->dropForeign('licenses_company_id_foreign');
// });
}
/**
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddNotesToModels extends Migration
{
@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateComponentsTable extends Migration
{

Some files were not shown because too many files have changed in this diff Show More