Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2023-03-21 21:14:06 -07:00
commit 8aec28fad6
48 changed files with 1206 additions and 787 deletions

View file

@ -1147,4 +1147,39 @@ class Helper
return $age;
}
/*
* This is a shorter way to see if the app is in demo mode.
*
* This makes it cleanly available in blades and in controllers, e.g.
*
* Blade:
* {{ Helper::isDemoMode() ? ' disabled' : ''}} for form blades where we need to disable a form
*
* Controller:
* if (Helper::isDemoMode()) {
* // don't allow the thing
* }
* @todo - use this everywhere else in the app where we have very long if/else config('app.lock_passwords') stuff
*/
public function isDemoMode() {
if (config('app.lock_passwords') === true) {
return true;
\Log::debug('app locked!');
}
return false;
}
/*
* I know it's gauche to return a shitty HTML string, but this is just a helper and since it will be the same every single time,
* it seemed pretty safe to do here. Don't you judge me.
*/
public function showDemoModeFieldWarning() {
if (Helper::isDemoMode()) {
return "<p class=\"text-warning\"><i class=\"fas fa-lock\"></i>" . trans('general.feature_disabled') . "</p>";
}
}
}

View file

@ -5,13 +5,14 @@ namespace App\Http\Livewire;
use GuzzleHttp\Client;
use Livewire\Component;
use App\Models\Setting;
use App\Helpers\Helper;
class SlackSettingsForm extends Component
{
public $webhook_endpoint;
public $webhook_channel;
public $webhook_botname;
public $isDisabled ='disabled' ;
public $isDisabled ='' ;
public $webhook_name;
public $webhook_link;
public $webhook_placeholder;
@ -27,8 +28,7 @@ class SlackSettingsForm extends Component
'webhook_botname' => 'string|nullable',
];
public function mount(){
public function mount() {
$this->webhook_text= [
"slack" => array(
"name" => trans('admin/settings/general.slack') ,
@ -45,6 +45,7 @@ class SlackSettingsForm extends Component
];
$this->setting = Setting::getSettings();
$this->save_button = trans('general.save');
$this->webhook_selected = $this->setting->webhook_selected;
$this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"];
$this->webhook_name = $this->webhook_text[$this->setting->webhook_selected]["name"];
@ -54,29 +55,49 @@ class SlackSettingsForm extends Component
$this->webhook_botname = $this->setting->webhook_botname;
$this->webhook_options = $this->setting->webhook_selected;
if($this->setting->webhook_selected == 'general'){
$this->isDisabled='';
}
if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){
$this->isDisabled= '';
}
}
public function updated($field){
public function updated($field) {
if($this->webhook_selected != 'general') {
$this->validateOnly($field, $this->rules);
}
}
public function updatedWebhookSelected(){
public function updatedWebhookSelected() {
$this->webhook_name = $this->webhook_text[$this->webhook_selected]['name'];
$this->webhook_icon = $this->webhook_text[$this->webhook_selected]["icon"]; ;
$this->webhook_placeholder = $this->webhook_text[$this->webhook_selected]["placeholder"];
$this->webhook_link = $this->webhook_text[$this->webhook_selected]["link"];
if($this->webhook_selected != 'slack'){
$this->isDisabled= '';
$this->save_button = trans('general.save');
}
}
private function isButtonDisabled() {
if($this->webhook_selected == 'slack') {
if (empty($this->webhook_endpoint)) {
$this->isDisabled = 'disabled';
$this->save_button = trans('admin/settings/general.webhook_presave');
}
if (empty($this->webhook_channel)) {
$this->isDisabled = 'disabled';
$this->save_button = trans('admin/settings/general.webhook_presave');
}
}
}
public function render()
{
if(empty($this->webhook_channel || $this->webhook_endpoint)){
$this->isDisabled= 'disabled';
}
if(empty($this->webhook_endpoint && $this->webhook_channel)){
$this->isDisabled= '';
}
$this->isButtonDisabled();
return view('livewire.slack-settings-form');
}
@ -98,37 +119,59 @@ class SlackSettingsForm extends Component
]);
try {
$webhook->post($this->webhook_endpoint, ['body' => $payload]);
$this->isDisabled='';
$this->save_button = trans('general.save');
return session()->flash('success' , 'Your '.$this->webhook_name.' Integration works!');
} catch (\Exception $e) {
$this->isDisabled= 'disabled';
return session()->flash('error' , trans('admin/settings/message.webhook.error', ['error_message' => $e->getMessage(), 'app' => $this->webhook_name]));
}
//}
return session()->flash('message' , trans('admin/settings/message.webhook.error_misc'));
return session()->flash('error' , trans('admin/settings/message.webhook.error_misc'));
}
public function clearSettings(){
if (Helper::isDemoMode()) {
session()->flash('error',trans('general.feature_disabled'));
} else {
$this->webhook_endpoint = '';
$this->webhook_channel = '';
$this->webhook_botname = '';
$this->setting->webhook_endpoint = '';
$this->setting->webhook_channel = '';
$this->setting->webhook_botname = '';
$this->setting->save();
session()->flash('success', trans('admin/settings/message.update.success'));
}
}
public function submit()
{
if($this->webhook_selected != 'general') {
$this->validate($this->rules);
if (Helper::isDemoMode()) {
session()->flash('error',trans('general.feature_disabled'));
} else {
if ($this->webhook_selected != 'general') {
$this->validate($this->rules);
}
$this->setting->webhook_selected = $this->webhook_selected;
$this->setting->webhook_endpoint = $this->webhook_endpoint;
$this->setting->webhook_channel = $this->webhook_channel;
$this->setting->webhook_botname = $this->webhook_botname;
$this->setting->save();
session()->flash('success',trans('admin/settings/message.update.success'));
}
$this->setting->webhook_selected = $this->webhook_selected;
$this->setting->webhook_endpoint = $this->webhook_endpoint;
$this->setting->webhook_channel = $this->webhook_channel;
$this->setting->webhook_botname = $this->webhook_botname;
$this->setting->save();
session()->flash('save',trans('admin/settings/message.update.success'));
}
}

View file

@ -150,6 +150,7 @@ class SettingsServiceProvider extends ServiceProvider
// Set the monetary locale to the configured locale to make helper::parseFloat work.
setlocale(LC_MONETARY, config('app.locale'));
setlocale(LC_NUMERIC, config('app.locale'));
}
/**

View file

@ -2,17 +2,14 @@
namespace Database\Factories;
use App\Models\Accessory;
use App\Models\Category;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
class AccessoryFactory extends Factory
{
/**
@ -20,7 +17,7 @@ class AccessoryFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Accessory::class;
protected $model = Accessory::class;
/**
* Define the model's default state.
@ -30,9 +27,16 @@ class AccessoryFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'name' => sprintf(
'%s %s',
$this->faker->randomElement(['Bluetooth', 'Wired']),
$this->faker->randomElement(['Keyboard', 'Wired'])
),
'user_id' => User::factory()->superuser(),
'category_id' => Category::factory(),
'model_number' => $this->faker->numberBetween(1000000, 50000000),
'location_id' => rand(1, 5),
'location_id' => Location::factory(),
'qty' => 1,
];
}
@ -42,11 +46,15 @@ class AccessoryFactory extends Factory
return [
'name' => 'Bluetooth Keyboard',
'image' => 'bluetooth.jpg',
'category_id' => 8,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Keyboards')->first() ?? Category::factory()->accessoryKeyboardCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'qty' => 10,
'min_amt' => 2,
'supplier_id' => rand(1, 5),
'supplier_id' => Supplier::factory(),
];
});
}
@ -57,11 +65,15 @@ class AccessoryFactory extends Factory
return [
'name' => 'USB Keyboard',
'image' => 'usb-keyboard.jpg',
'category_id' => 8,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Keyboards')->first() ?? Category::factory()->accessoryKeyboardCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'qty' => 15,
'min_amt' => 2,
'supplier_id' => rand(1, 5),
'supplier_id' => Supplier::factory(),
];
});
}
@ -72,11 +84,15 @@ class AccessoryFactory extends Factory
return [
'name' => 'Magic Mouse',
'image' => 'magic-mouse.jpg',
'category_id' => 9,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Mouse')->first() ?? Category::factory()->accessoryMouseCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'qty' => 13,
'min_amt' => 2,
'supplier_id' => rand(1, 5),
'supplier_id' => Supplier::factory(),
];
});
}
@ -87,8 +103,12 @@ class AccessoryFactory extends Factory
return [
'name' => 'Sculpt Comfort Mouse',
'image' => 'comfort-mouse.jpg',
'category_id' => 9,
'manufacturer_id' => 2,
'category_id' => function () {
return Category::where('name', 'Mouse')->first() ?? Category::factory()->accessoryMouseCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
},
'qty' => 13,
'min_amt' => 2,
];

View file

@ -4,20 +4,12 @@ namespace Database\Factories;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Company;
use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\Location;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Action Log Factories
|--------------------------------------------------------------------------
|
| This simulates checkin/checkout/etc activities
|
*/
class ActionlogFactory extends Factory
{
/**
@ -25,7 +17,7 @@ class ActionlogFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Actionlog::class;
protected $model = Actionlog::class;
/**
* Define the model's default state.
@ -34,71 +26,83 @@ class ActionlogFactory extends Factory
*/
public function definition()
{
$asset = \App\Models\Asset::factory()->create();
return [
'item_type' => get_class($asset),
'item_id' => 1,
'user_id' => 1,
'item_id' => Asset::factory(),
'item_type' => Asset::class,
'user_id' => User::factory()->superuser(),
'action_type' => 'uploaded',
];
}
public function assetCheckoutToUser()
{
return $this->state(function () {
$target = \App\Models\User::inRandomOrder()->first();
$item = \App\Models\Asset::RTD()->inRandomOrder()->first();
$user_id = rand(1, 2); // keep it simple - make it one of the two superadmins
$asset = Asset::where('id', $item->id)
->update(
$target = User::inRandomOrder()->first();
$asset = Asset::RTD()->inRandomOrder()->first();
$asset->update(
[
'assigned_to' => $target->id,
'assigned_type' => \App\Models\User::class,
'assigned_type' => User::class,
'location_id' => $target->location_id,
]
);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'user_id' => $user_id,
'action_type' => 'checkout',
'item_id' => $item->id,
'item_type' => \App\Models\Asset::class,
'item_id' => $asset->id,
'item_type' => Asset::class,
'target_id' => $target->id,
'target_type' => get_class($target),
'target_type' => User::class,
];
});
}
public function assetCheckoutToLocation()
{
return $this->state(function () {
$target = \App\Models\Location::inRandomOrder()->first();
$item = \App\Models\Asset::inRandomOrder()->RTD()->first();
$user_id = rand(1, 2); // keep it simple - make it one of the two superadmins
$asset = \App\Models\Asset::where('id', $item->id)
->update(
$target = Location::inRandomOrder()->first();
$asset = Asset::inRandomOrder()->RTD()->first();
$asset->update(
[
'assigned_to' => $target->id,
'assigned_type' => \App\Models\Location::class,
'assigned_type' => Location::class,
'location_id' => $target->id,
]
);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'user_id' => $user_id,
'action_type' => 'checkout',
'item_id' => $item->id,
'item_type' => \App\Models\Asset::class,
'item_id' => $asset->id,
'item_type' => Asset::class,
'target_id' => $target->id,
'target_type' => get_class($target),
'target_type' => Location::class,
];
});
}
public function licenseCheckoutToUser()
{
return $this->state(function () {
$target = User::inRandomOrder()->first();
$licenseSeat = LicenseSeat::whereNull('assigned_to')->inRandomOrder()->first();
$licenseSeat->update([
'assigned_to' => $target->id,
'user_id' => 1, // not ideal but works
]);
return [
'created_at' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get()),
'action_type' => 'checkout',
'item_id' => $licenseSeat->license->id,
'item_type' => License::class,
'target_id' => $target->id,
'target_type' => User::class,
];
});
}
}

View file

@ -4,22 +4,12 @@ namespace Database\Factories;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Location;
use App\Models\Statuslabel;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to modelling assets.
|
*/
// These are just for unit tests, not to generate data
class AssetFactory extends Factory
{
/**
@ -38,10 +28,13 @@ class AssetFactory extends Factory
{
return [
'name' => null,
'model_id' => AssetModel::factory(),
'rtd_location_id' => Location::factory(),
'serial' => $this->faker->uuid(),
'status_id' => 1,
'user_id' => 1,
'status_id' => function () {
return Statuslabel::where('name', 'Ready to Deploy')->first() ?? Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
},
'user_id' => User::factory()->superuser(),
'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'),
@ -60,7 +53,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
];
});
}
@ -69,8 +64,12 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'status_id' => 2,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
'status_id' => function () {
return Statuslabel::where('name', 'Pending')->first() ?? Statuslabel::factory()->pending()->make(['name' => 'Pending']);
},
];
});
}
@ -79,8 +78,12 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'status_id' => 3,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13"')->first() ?? AssetModel::factory()->mbp13Model();
},
'status_id' => function () {
return Statuslabel::where('name', 'Archived')->first() ?? Statuslabel::factory()->archived()->make(['name' => 'Archived']);
},
];
});
}
@ -89,7 +92,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 2,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Air')->first() ?? AssetModel::factory()->mbpAirModel();
},
];
});
}
@ -98,7 +103,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 3,
'model_id' => function () {
return AssetModel::where('name', 'Surface')->first() ?? AssetModel::factory()->surfaceModel();
},
];
});
}
@ -107,7 +114,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 4,
'model_id' => function () {
return AssetModel::where('name', 'XPS 13')->first() ?? AssetModel::factory()->xps13Model();
},
];
});
}
@ -116,7 +125,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 5,
'model_id' => function () {
return AssetModel::where('name', 'Spectre')->first() ?? AssetModel::factory()->spectreModel();
},
];
});
}
@ -125,7 +136,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 6,
'model_id' => function () {
return AssetModel::where('name', 'ZenBook UX310')->first() ?? AssetModel::factory()->zenbookModel();
},
];
});
}
@ -134,7 +147,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 7,
'model_id' => function () {
return AssetModel::where('name', 'Yoga 910')->first() ?? AssetModel::factory()->yogaModel();
},
];
});
}
@ -143,7 +158,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 8,
'model_id' => function () {
return AssetModel::where('name', 'iMac Pro')->first() ?? AssetModel::factory()->macproModel();
},
];
});
}
@ -152,7 +169,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 9,
'model_id' => function () {
return AssetModel::where('name', 'Lenovo Intel Core i5')->first() ?? AssetModel::factory()->lenovoI5Model();
},
];
});
}
@ -161,7 +180,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 10,
'model_id' => function () {
return AssetModel::where('name', 'OptiPlex')->first() ?? AssetModel::factory()->optiplexModel();
},
];
});
}
@ -170,7 +191,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 11,
'model_id' => function () {
return AssetModel::where('name', 'SoundStation 2')->first() ?? AssetModel::factory()->polycomModel();
},
];
});
}
@ -179,7 +202,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 12,
'model_id' => function () {
return AssetModel::where('name', 'Polycom CX3000 IP Conference Phone')->first() ?? AssetModel::factory()->polycomcxModel();
},
];
});
}
@ -188,7 +213,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 13,
'model_id' => function () {
return AssetModel::where('name', 'iPad Pro')->first() ?? AssetModel::factory()->ipadModel();
},
];
});
}
@ -197,7 +224,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 14,
'model_id' => function () {
return AssetModel::where('name', 'Tab3')->first() ?? AssetModel::factory()->tab3Model();
},
];
});
}
@ -206,7 +235,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 15,
'model_id' => function () {
return AssetModel::where('name', 'iPhone 11')->first() ?? AssetModel::factory()->iphone11Model();
},
];
});
}
@ -215,7 +246,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 16,
'model_id' => function () {
return AssetModel::where('name', 'iPhone 12')->first() ?? AssetModel::factory()->iphone12Model();
},
];
});
}
@ -224,7 +257,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 17,
'model_id' => function () {
return AssetModel::where('name', 'Ultrafine 4k')->first() ?? AssetModel::factory()->ultrafine();
},
];
});
}
@ -233,7 +268,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 18,
'model_id' => function () {
return AssetModel::where('name', 'Ultrasharp U2415')->first() ?? AssetModel::factory()->ultrasharp();
},
];
});
}
@ -242,9 +279,8 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'assigned_to' => \App\Models\User::factory()->create()->id,
'assigned_type' => \App\Models\User::class,
'assigned_to' => User::factory(),
'assigned_type' => User::class,
];
});
}
@ -253,9 +289,8 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'assigned_to' => \App\Models\Location::factory()->create()->id,
'assigned_type' => \App\Models\Location::class,
'assigned_to' => Location::factory(),
'assigned_type' => Location::class,
];
});
}
@ -265,8 +300,8 @@ class AssetFactory extends Factory
return $this->state(function () {
return [
'model_id' => 1,
'assigned_to' => \App\Models\Asset::factory()->create()->id,
'assigned_type' => \App\Models\Asset::class,
'assigned_to' => Asset::factory(),
'assigned_type' => Asset::class,
];
});
}
@ -275,7 +310,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
];
});
}
@ -284,7 +321,9 @@ class AssetFactory extends Factory
{
return $this->state(function () {
return [
'model_id' => 1,
'model_id' => function () {
return AssetModel::where('name', 'Macbook Pro 13')->first() ?? AssetModel::factory()->mbp13Model();
},
'deleted_at' => $this->faker->dateTime(),
];
});

View file

@ -3,19 +3,10 @@
namespace Database\Factories;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\AssetMaintenance;
use App\Models\Supplier;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to modelling assets.
|
*/
class AssetMaintenanceFactory extends Factory
{
/**
@ -23,7 +14,7 @@ class AssetMaintenanceFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\AssetMaintenance::class;
protected $model = AssetMaintenance::class;
/**
* Define the model's default state.
@ -33,14 +24,10 @@ class AssetMaintenanceFactory extends Factory
public function definition()
{
return [
'asset_id' => function () {
return \App\Models\Asset::factory()->create()->id;
},
'supplier_id' => function () {
return \App\Models\Supplier::factory()->create()->id;
},
'asset_id' => Asset::factory(),
'supplier_id' => Supplier::factory(),
'asset_maintenance_type' => $this->faker->randomElement(['maintenance', 'repair', 'upgrade']),
'title' => $this->faker->sentence,
'title' => $this->faker->sentence(),
'start_date' => $this->faker->date(),
'is_warranty' => $this->faker->boolean(),
'notes' => $this->faker->paragraph(),

View file

@ -2,68 +2,14 @@
namespace Database\Factories;
use App\Models\AssetModel;
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;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
/*
|--------------------------------------------------------------------------
| Laptops
|--------------------------------------------------------------------------
*/
// 1
// 2
// 3
// 4
// 5
// 6
// 7
/*
|--------------------------------------------------------------------------
| Desktops
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Conference Phones
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Tablets
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Mobile Phones
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Displays
|--------------------------------------------------------------------------
*/
class AssetModelFactory extends Factory
{
/**
@ -71,7 +17,7 @@ class AssetModelFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\AssetModel::class;
protected $model = AssetModel::class;
/**
* Define the model's default state.
@ -81,8 +27,9 @@ class AssetModelFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'user_id' => User::factory()->superuser(),
'name' => $this->faker->catchPhrase(),
'category_id' => Category::factory(),
'model_number' => $this->faker->creditCardNumber(),
'notes' => 'Created by demo seeder',
@ -94,11 +41,17 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Macbook Pro 13"',
'category_id' => 1,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'mbp.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -108,12 +61,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Macbook Air',
'category_id' => 1,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'macbookair.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -123,12 +84,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Surface',
'category_id' => 1,
'manufacturer_id' => 2,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'surface.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -138,12 +107,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'XPS 13',
'category_id' => 1,
'manufacturer_id' => 3,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'xps.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -153,12 +130,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'ZenBook UX310',
'category_id' => 1,
'manufacturer_id' => 4,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Asus')->first() ?? Manufacturer::factory()->asus();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'zenbook.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -168,12 +153,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Spectre',
'category_id' => 1,
'manufacturer_id' => 5,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'spectre.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -183,12 +176,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Yoga 910',
'category_id' => 1,
'manufacturer_id' => 6,
'category_id' => function () {
return Category::where('name', 'Laptops')->first() ?? Category::factory()->assetLaptopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
},
'eol' => '36',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'yoga.png',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -198,12 +199,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'iMac Pro',
'category_id' => 2,
'manufacturer_id' => 1,
'category_id' => function (){
return Category::where('name', 'Desktops')->first() ?? Category::factory()->assetDesktopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'eol' => '24',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'imacpro.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -213,12 +222,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Lenovo Intel Core i5',
'category_id' => 2,
'manufacturer_id' => 6,
'category_id' => function () {
return Category::where('name', 'Desktops')->first() ?? Category::factory()->assetDesktopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
},
'eol' => '24',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'lenovoi5.png',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -228,13 +245,21 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'OptiPlex',
'category_id' => 2,
'manufacturer_id' => 3,
'category_id' => function (){
return Category::where('name', 'Desktops')->first() ?? Category::factory()->assetDesktopCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
},
'model_number' => '5040 (MRR81)',
'eol' => '24',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'optiplex.jpg',
'fieldset_id' => 2,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Laptops and Desktops')->first() ?? CustomFieldset::factory()->computer();
},
];
});
}
@ -244,10 +269,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'SoundStation 2',
'category_id' => 6,
'manufacturer_id' => 8,
'category_id' => function () {
return Category::where('name', 'VOIP Phones')->first() ?? Category::factory()->assetVoipCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
},
'eol' => '12',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'soundstation.jpg',
];
});
@ -258,10 +289,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Polycom CX3000 IP Conference Phone',
'category_id' => 6,
'manufacturer_id' => 8,
'category_id' => function () {
return Category::where('name', 'VOIP Phones')->first() ?? Category::factory()->assetVoipCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Polycom')->first() ?? Manufacturer::factory()->polycom();
},
'eol' => '12',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'cx3000.png',
];
});
@ -272,10 +309,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'iPad Pro',
'category_id' => 3,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Tablets')->first() ?? Category::factory()->assetTabletCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'eol' => '12',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'ipad.jpg',
];
});
@ -286,10 +329,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Tab3',
'category_id' => 3,
'manufacturer_id' => 6,
'category_id' => function () {
return Category::where('name', 'Tablets')->first() ?? Category::factory()->assetTabletCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Lenovo')->first() ?? Manufacturer::factory()->lenovo();
},
'eol' => '12',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'tab3.png',
];
});
@ -300,12 +349,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'iPhone 11',
'category_id' => 4,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Mobile Phones')->first() ?? Category::factory()->assetMobileCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'eol' => '12',
'depreciation_id' => 3,
'depreciation_id' => function () {
return Depreciation::where('name', 'Mobile Phone Depreciation')->first() ?? Depreciation::factory()->mobilePhones();
},
'image' => 'iphone11.jpeg',
'fieldset_id' => 1,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Mobile Devices')->first() ?? CustomFieldset::factory()->mobile();
},
];
});
}
@ -315,12 +372,20 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'iPhone 12',
'category_id' => 4,
'manufacturer_id' => 1,
'category_id' => function () {
return Category::where('name', 'Mobile Phones')->first() ?? Category::factory()->assetMobileCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Apple')->first() ?? Manufacturer::factory()->apple();
},
'eol' => '12',
'depreciation_id' => 1,
'depreciation_id' => function () {
return Depreciation::where('name', 'Computer Depreciation')->first() ?? Depreciation::factory()->computer();
},
'image' => 'iphone12.jpeg',
'fieldset_id' => 1,
'fieldset_id' => function () {
return CustomFieldset::where('name', 'Mobile Devices')->first() ?? CustomFieldset::factory()->mobile();
},
];
});
}
@ -330,10 +395,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Ultrafine 4k',
'category_id' => 5,
'manufacturer_id' => 7,
'category_id' => function () {
return Category::where('name', 'Displays')->first() ?? Category::factory()->assetDisplayCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'LG')->first() ?? Manufacturer::factory()->lg();
},
'eol' => '12',
'depreciation_id' => 2,
'depreciation_id' => function () {
return Depreciation::where('name', 'Display Depreciation')->first() ?? Depreciation::factory()->display();
},
'image' => 'ultrafine.jpg',
];
});
@ -344,10 +415,16 @@ class AssetModelFactory extends Factory
return $this->state(function () {
return [
'name' => 'Ultrasharp U2415',
'category_id' => 5,
'manufacturer_id' => 3,
'category_id' => function () {
return Category::where('name', 'Displays')->first() ?? Category::factory()->assetDisplayCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Dell')->first() ?? Manufacturer::factory()->dell();
},
'eol' => '12',
'depreciation_id' => 2,
'depreciation_id' => function () {
return Depreciation::where('name', 'Display Depreciation')->first() ?? Depreciation::factory()->display();
},
'image' => 'ultrasharp.jpg',
];
});

View file

@ -2,18 +2,10 @@
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\Category;
/*
|--------------------------------------------------------------------------
| Category Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating categories and the various states..
|
*/
class CategoryFactory extends Factory
{
/**
@ -21,7 +13,7 @@ class CategoryFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Category::class;
protected $model = Category::class;
/**
* Define the model's default state.
@ -32,18 +24,19 @@ class CategoryFactory extends Factory
{
return [
'name' => $this->faker->catchPhrase(),
'category_type' => 'asset',
'checkin_email' => $this->faker->boolean(),
'eula_text' => $this->faker->paragraph(),
'require_acceptance' => false,
'use_default_eula' => $this->faker->boolean(),
'user_id' => 1,
'user_id' => User::factory()->superuser(),
];
}
// usage: Category::factory()->assetLaptopCategory();
public function assetLaptopCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Laptops',
'category_type' => 'asset',
'require_acceptance' => true,
@ -53,7 +46,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetDesktopCategory();
public function assetDesktopCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Desktops',
'category_type' => 'asset',
'require_acceptance' => true,
@ -63,7 +56,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetDisplayCategory();
public function assetDisplayCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Displays',
'category_type' => 'asset',
]);
@ -72,7 +65,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetTabletCategory();
public function assetTabletCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Tablets',
'category_type' => 'asset',
]);
@ -81,7 +74,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetMobileCategory();
public function assetMobileCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Mobile Phones',
'category_type' => 'asset',
]);
@ -90,7 +83,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetConferenceCategory();
public function assetConferenceCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Conference Phones',
'category_type' => 'asset',
]);
@ -100,7 +93,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->assetVoipCategory();
public function assetVoipCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'VOIP Phones',
'category_type' => 'asset',
]);
@ -109,8 +102,8 @@ class CategoryFactory extends Factory
// usage: Category::factory()->accessoryKeyboardCategory();
public function accessoryKeyboardCategory()
{
return Category::factory()->create([
'name' => 'Keyboardss',
return $this->state([
'name' => 'Keyboards',
'category_type' => 'accessory',
]);
}
@ -119,7 +112,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->accessoryMouseCategory();
public function accessoryMouseCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Mouse',
'category_type' => 'accessory',
]);
@ -128,7 +121,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->componentHddCategory();
public function componentHddCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'HDD/SSD',
'category_type' => 'component',
]);
@ -137,7 +130,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->componentRamCategory();
public function componentRamCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'RAM',
'category_type' => 'component',
]);
@ -146,7 +139,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->consumablePaperCategory();
public function consumablePaperCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Printer Paper',
'category_type' => 'consumable',
]);
@ -155,7 +148,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->consumableInkCategory();
public function consumableInkCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Printer Ink',
'category_type' => 'consumable',
]);
@ -164,7 +157,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseGraphicsCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Graphics Software',
'category_type' => 'license',
]);
@ -173,7 +166,7 @@ class CategoryFactory extends Factory
// usage: Category::factory()->licenseGraphicsCategory();
public function licenseOfficeCategory()
{
return Category::factory()->create([
return $this->state([
'name' => 'Office Software',
'category_type' => 'license',
]);

View file

@ -1,25 +1,8 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
namespace Database\Factories;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Company;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\Supplier;
use Illuminate\Database\Eloquent\Factories\Factory;
class CompanyFactory extends Factory
@ -29,7 +12,7 @@ class CompanyFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Company::class;
protected $model = Company::class;
/**
* Define the model's default state.
@ -39,7 +22,7 @@ class CompanyFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->company,
'name' => $this->faker->company(),
];
}
}

View file

@ -2,17 +2,12 @@
namespace Database\Factories;
use App\Models\Category;
use App\Models\Company;
use App\Models\Component;
use App\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Components Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating components ..
|
*/
class ComponentFactory extends Factory
{
/**
@ -20,7 +15,7 @@ class ComponentFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Component::class;
protected $model = Component::class;
/**
* Define the model's default state.
@ -31,19 +26,15 @@ class ComponentFactory extends Factory
{
return [
'name' => $this->faker->text(20),
'category_id' => function () {
return \App\Models\Category::factory()->create()->id;
},
'location_id' => 1,
'serial' => $this->faker->uuid,
'category_id' => Category::factory(),
'location_id' => Location::factory(),
'serial' => $this->faker->uuid(),
'qty' => $this->faker->numberBetween(3, 10),
'order_number' => $this->faker->numberBetween(1000000, 50000000),
'purchase_date' => $this->faker->dateTime()->format('Y-m-d'),
'purchase_cost' => $this->faker->randomFloat(2),
'min_amt' => $this->faker->numberBetween($min = 1, $max = 2),
'company_id' => function () {
return \App\Models\Company::factory()->create()->id;
},
'company_id' => Company::factory(),
];
}
@ -52,11 +43,12 @@ class ComponentFactory extends Factory
return $this->state(function () {
return [
'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
'category_id' => 13,
'category_id' => function () {
return Category::where('name', 'RAM')->first() ?? Category::factory()->componentRamCategory();
},
'qty' => 10,
'min_amt' => 2,
'location_id' => 3,
'company_id' => 2,
'location_id' => Location::factory(),
];
});
}
@ -66,7 +58,9 @@ class ComponentFactory extends Factory
return $this->state(function () {
return [
'name' => 'Crucial 8GB DDR3L-1600 SODIMM Memory for Mac',
'category_id' => 13,
'category_id' => function () {
return Category::where('name', 'RAM')->first() ?? Category::factory()->componentRamCategory();
},
'qty' => 10,
'min_amt' => 2,
];
@ -78,7 +72,9 @@ class ComponentFactory extends Factory
return $this->state(function () {
return [
'name' => 'Crucial BX300 120GB SATA Internal SSD',
'category_id' => 12,
'category_id' => function () {
return Category::where('name', 'HDD/SSD')->first() ?? Category::factory()->componentHddCategory();
},
'qty' => 10,
'min_amt' => 2,
];
@ -90,7 +86,9 @@ class ComponentFactory extends Factory
return $this->state(function () {
return [
'name' => 'Crucial BX300 240GB SATA Internal SSD',
'category_id' => 12,
'category_id' => function () {
return Category::where('name', 'HDD/SSD')->first() ?? Category::factory()->componentHddCategory();
},
'qty' => 10,
'min_amt' => 2,
];

View file

@ -2,17 +2,13 @@
namespace Database\Factories;
use App\Models\Category;
use App\Models\Company;
use App\Models\Consumable;
use App\Models\Manufacturer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Consumables Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating consumables ..
|
*/
class ConsumableFactory extends Factory
{
/**
@ -20,7 +16,7 @@ class ConsumableFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Consumable::class;
protected $model = Consumable::class;
/**
* Define the model's default state.
@ -30,13 +26,16 @@ class ConsumableFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'name' => $this->faker->word(),
'category_id' => Category::factory(),
'user_id' => User::factory()->superuser(),
'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())->format('Y-m-d'),
'purchase_cost' => $this->faker->randomFloat(2, 1, 50),
'qty' => $this->faker->numberBetween(5, 10),
'min_amt' => $this->faker->numberBetween($min = 1, $max = 2),
'company_id' => Company::factory(),
];
}
@ -45,11 +44,14 @@ class ConsumableFactory extends Factory
return $this->state(function () {
return [
'name' => 'Cardstock (White)',
'category_id' => 10,
'manufacturer_id' => 10,
'category_id' => function () {
return Category::where('name', 'Printer Paper')->first() ?? Category::factory()->consumablePaperCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Avery')->first() ?? Manufacturer::factory()->avery();
},
'qty' => 10,
'min_amt' => 2,
'company_id' => 3,
];
});
}
@ -59,8 +61,12 @@ class ConsumableFactory extends Factory
return $this->state(function () {
return [
'name' => 'Laserjet Paper (Ream)',
'category_id' => 10,
'manufacturer_id' => 10,
'category_id' => function () {
return Category::where('name', 'Printer Paper')->first() ?? Category::factory()->consumablePaperCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Avery')->first() ?? Manufacturer::factory()->avery();
},
'qty' => 20,
'min_amt' => 2,
];
@ -72,8 +78,12 @@ class ConsumableFactory extends Factory
return $this->state(function () {
return [
'name' => 'Laserjet Toner (black)',
'category_id' => 11,
'manufacturer_id' => 5,
'category_id' => function () {
return Category::where('name', 'Printer Ink')->first() ?? Category::factory()->consumableInkCategory();
},
'manufacturer_id' => function () {
return Manufacturer::where('name', 'HP')->first() ?? Manufacturer::factory()->hp();
},
'qty' => 20,
'min_amt' => 2,
];

View file

@ -2,6 +2,7 @@
namespace Database\Factories;
use App\Models\CustomField;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFieldFactory extends Factory
@ -11,7 +12,7 @@ class CustomFieldFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\CustomField::class;
protected $model = CustomField::class;
/**
* Define the model's default state.
@ -21,7 +22,7 @@ class CustomFieldFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->catchPhrase,
'name' => $this->faker->catchPhrase(),
'format' => '',
'element' => 'text',
];

View file

@ -2,6 +2,7 @@
namespace Database\Factories;
use App\Models\CustomFieldset;
use Illuminate\Database\Eloquent\Factories\Factory;
class CustomFieldsetFactory extends Factory
@ -11,7 +12,7 @@ class CustomFieldsetFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\CustomFieldset::class;
protected $model = CustomFieldset::class;
/**
* Define the model's default state.
@ -21,7 +22,7 @@ class CustomFieldsetFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->catchPhrase,
'name' => $this->faker->catchPhrase(),
];
}

View file

@ -2,17 +2,11 @@
namespace Database\Factories;
use App\Models\Department;
use App\Models\Location;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
class DepartmentFactory extends Factory
{
/**
@ -20,7 +14,7 @@ class DepartmentFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Department::class;
protected $model = Department::class;
/**
* Define the model's default state.
@ -30,8 +24,9 @@ class DepartmentFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'location_id' => rand(1, 5),
'name' => $this->faker->word() . ' Department',
'user_id' => User::factory()->superuser(),
'location_id' => Location::factory(),
];
}

View file

@ -2,17 +2,10 @@
namespace Database\Factories;
use App\Models\Depreciation;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
class DepreciationFactory extends Factory
{
/**
@ -20,7 +13,7 @@ class DepreciationFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Depreciation::class;
protected $model = Depreciation::class;
/**
* Define the model's default state.
@ -31,7 +24,7 @@ class DepreciationFactory extends Factory
{
return [
'name' => $this->faker->catchPhrase(),
'user_id' => 1,
'user_id' => User::factory()->superuser(),
'months' => 36,
];
}

View file

@ -1,25 +1,8 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
namespace Database\Factories;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Company;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\Supplier;
use App\Models\Group;
use Illuminate\Database\Eloquent\Factories\Factory;
class GroupFactory extends Factory
@ -29,7 +12,7 @@ class GroupFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Group::class;
protected $model = Group::class;
/**
* Define the model's default state.
@ -39,7 +22,7 @@ class GroupFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->name,
'name' => $this->faker->name(),
];
}
}

View file

@ -2,25 +2,12 @@
namespace Database\Factories;
use App\Models\Category;
use App\Models\License;
use App\Models\Manufacturer;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
// 1
// 2
// 3
// 4
class LicenseFactory extends Factory
{
/**
@ -28,7 +15,7 @@ class LicenseFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\License::class;
protected $model = License::class;
/**
* Define the model's default state.
@ -37,13 +24,11 @@ class LicenseFactory extends Factory
*/
public function definition()
{
return [
'user_id' => 1,
'name' => $this->faker->name,
'license_email' => $this->faker->safeEmail,
'serial' => $this->faker->uuid,
'user_id' => User::factory()->superuser(),
'name' => $this->faker->name(),
'license_email' => $this->faker->safeEmail(),
'serial' => $this->faker->uuid(),
'notes' => 'Created by DB seeder',
'seats' => $this->faker->numberBetween(1, 10),
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
@ -51,8 +36,8 @@ class LicenseFactory extends Factory
'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' => $this->faker->numberBetween(1, 5),
'category_id' => Category::where('category_type', '=', 'license')->inRandomOrder()->first()->id
'supplier_id' => Supplier::factory(),
'category_id' => Category::factory(),
];
}
@ -61,12 +46,16 @@ class LicenseFactory extends Factory
return $this->state(function () {
$data = [
'name' => 'Photoshop',
'manufacturer_id' => 9,
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
'purchase_cost' => '299.99',
'seats' => 10,
'purchase_order' => '13503Q',
'maintained' => true,
'category_id' => 14,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
];
return $data;
@ -78,10 +67,14 @@ class LicenseFactory extends Factory
return $this->state(function () {
$data = [
'name' => 'Acrobat',
'manufacturer_id' => 9,
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
'purchase_cost' => '29.99',
'seats' => 10,
'category_id' => 14,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
];
return $data;
@ -93,10 +86,14 @@ class LicenseFactory extends Factory
return $this->state(function () {
$data = [
'name' => 'InDesign',
'manufacturer_id' => 9,
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Adobe')->first() ?? Manufacturer::factory()->adobe();
},
'purchase_cost' => '199.99',
'seats' => 10,
'category_id' => 14,
'category_id' => function () {
return Category::where('name', 'Graphics Software')->first() ?? Category::factory()->licenseGraphicsCategory();
},
];
@ -109,10 +106,14 @@ class LicenseFactory extends Factory
return $this->state(function () {
$data = [
'name' => 'Office',
'manufacturer_id' => 2,
'manufacturer_id' => function () {
return Manufacturer::where('name', 'Microsoft')->first() ?? Manufacturer::factory()->microsoft();
},
'purchase_cost' => '49.99',
'seats' => 20,
'category_id' => 15,
'category_id' => function () {
return Category::where('name', 'Office Software')->first() ?? Category::factory()->licenseOfficeCategory();
},
];
return $data;

View file

@ -23,8 +23,6 @@ class LocationFactory extends Factory
'currency' => $this->faker->currencyCode(),
'zip' => $this->faker->postcode(),
'image' => rand(1, 9).'.jpg',
];
}
}

View file

@ -2,39 +2,10 @@
namespace Database\Factories;
use App\Models\Manufacturer;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/*
|--------------------------------------------------------------------------
| Asset Model Factories
|--------------------------------------------------------------------------
|
| Factories related exclusively to creating models ..
|
*/
// 1
// 2
// 3
// 4
// 5
// 6
// 7
// 8
// 9
// 10
// 11
class ManufacturerFactory extends Factory
{
/**
@ -42,7 +13,7 @@ class ManufacturerFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Manufacturer::class;
protected $model = Manufacturer::class;
/**
* Define the model's default state.
@ -52,7 +23,8 @@ class ManufacturerFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'name' => $this->faker->company(),
'user_id' => User::factory()->superuser(),
'support_phone' => $this->faker->phoneNumber(),
'url' => $this->faker->url(),
'support_email' => $this->faker->safeEmail(),

View file

@ -1,25 +1,8 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
namespace Database\Factories;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Company;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\Supplier;
use App\Models\Setting;
use Illuminate\Database\Eloquent\Factories\Factory;
class SettingFactory extends Factory
@ -29,7 +12,7 @@ class SettingFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Setting::class;
protected $model = Setting::class;
/**
* Define the model's default state.
@ -39,14 +22,13 @@ class SettingFactory extends Factory
public function definition()
{
return [
'user_id' => 1,
'per_page' => 20,
'site_name' => $this->faker->sentence,
'site_name' => $this->faker->sentence(),
'auto_increment_assets' => false,
'alert_email' => $this->faker->safeEmail(),
'alerts_enabled' => true,
'brand' => 1,
'default_currency' => $this->faker->currencyCode,
'default_currency' => $this->faker->currencyCode(),
'locale' => 'en',
'pwd_secure_min' => 10, // Match web setup
'email_domain' => 'test.com',

View file

@ -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
@ -22,10 +23,10 @@ class StatuslabelFactory extends Factory
public function definition()
{
return [
'name' => $this->faker->sentence,
'name' => $this->faker->sentence(),
'created_at' => $this->faker->dateTime(),
'updated_at' => $this->faker->dateTime(),
'user_id' => 1,
'user_id' => User::factory()->superuser(),
'deleted_at' => null,
'deployable' => 0,
'pending' => 0,
@ -38,7 +39,7 @@ class StatuslabelFactory extends Factory
{
return $this->state(function () {
return [
'notes' => $this->faker->sentence,
'notes' => $this->faker->sentence(),
'deployable' => 1,
'default_label' => 1,
];
@ -49,7 +50,7 @@ class StatuslabelFactory extends Factory
{
return $this->state(function () {
return [
'notes' => $this->faker->sentence,
'notes' => $this->faker->sentence(),
'pending' => 1,
'default_label' => 1,
];

View file

@ -1,24 +1,7 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
namespace Database\Factories;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Company;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\Supplier;
use Illuminate\Database\Eloquent\Factories\Factory;
@ -29,7 +12,7 @@ class SupplierFactory extends Factory
*
* @var string
*/
protected $model = \App\Models\Supplier::class;
protected $model = Supplier::class;
/**
* Define the model's default state.

View file

@ -2,6 +2,8 @@
namespace Database\Factories;
use App\Models\Company;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use \Auth;
@ -18,10 +20,9 @@ class UserFactory extends Factory
'activated' => 1,
'address' => $this->faker->address(),
'city' => $this->faker->city(),
'company_id' => rand(1, 4),
'company_id' => Company::factory(),
'country' => $this->faker->country(),
'department_id' => rand(1, 6),
'email' => $this->faker->safeEmail,
'email' => $this->faker->safeEmail(),
'employee_num' => $this->faker->numberBetween(3500, 35050),
'first_name' => $this->faker->firstName(),
'jobtitle' => $this->faker->jobTitle(),
@ -30,10 +31,10 @@ class UserFactory extends Factory
'notes' => 'Created by DB seeder',
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'permissions' => '{"user":"0"}',
'phone' => $this->faker->phoneNumber,
'state' => $this->faker->stateAbbr,
'username' => $this->faker->username,
'zip' => $this->faker->postcode,
'phone' => $this->faker->phoneNumber(),
'state' => $this->faker->stateAbbr(),
'username' => $this->faker->username(),
'zip' => $this->faker->postcode(),
];
}
@ -78,7 +79,9 @@ class UserFactory extends Factory
return $this->state(function () {
return [
'permissions' => '{"admin":"1"}',
'manager_id' => rand(1, 2),
'manager_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
];
});
}

View file

@ -3,6 +3,9 @@
namespace Database\Seeders;
use App\Models\Accessory;
use App\Models\Location;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@ -14,10 +17,45 @@ class AccessorySeeder extends Seeder
{
Accessory::truncate();
DB::table('accessories_users')->truncate();
Accessory::factory()->count(1)->appleUsbKeyboard()->create();
Accessory::factory()->count(1)->appleBtKeyboard()->create();
Accessory::factory()->count(1)->appleMouse()->create();
Accessory::factory()->count(1)->microsoftMouse()->create();
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
$locationIds = Location::all()->pluck('id');
if (! Supplier::count()) {
$this->call(SupplierSeeder::class);
}
$supplierIds = Supplier::all()->pluck('id');
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Accessory::factory()->appleUsbKeyboard()->create([
'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
Accessory::factory()->appleBtKeyboard()->create([
'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
Accessory::factory()->appleMouse()->create([
'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
Accessory::factory()->microsoftMouse()->create([
'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
$src = public_path('/img/demo/accessories/');
$dst = 'accessories'.'/';

View file

@ -3,6 +3,9 @@
namespace Database\Seeders;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Location;
use App\Models\User;
use Illuminate\Database\Seeder;
class ActionlogSeeder extends Seeder
@ -10,9 +13,30 @@ class ActionlogSeeder extends Seeder
public function run()
{
Actionlog::truncate();
Actionlog::factory()->count(300)->assetCheckoutToUser()->create();
Actionlog::factory()->count(100)->assetCheckoutToLocation()->create();
if (! Asset::count()) {
$this->call(AssetSeeder::class);
}
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Actionlog::factory()
->count(300)
->assetCheckoutToUser()
->create(['user_id' => $admin->id]);
Actionlog::factory()
->count(100)
->assetCheckoutToLocation()
->create(['user_id' => $admin->id]);
Actionlog::factory()
->count(20)
->licenseCheckoutToUser()
->create(['user_id' => $admin->id]);
}
}

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\AssetModel;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
@ -13,35 +14,37 @@ class AssetModelSeeder extends Seeder
{
AssetModel::truncate();
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
// Laptops
AssetModel::factory()->count(1)->mbp13Model()->create(); // 1
AssetModel::factory()->count(1)->mbpAirModel()->create(); // 2
AssetModel::factory()->count(1)->surfaceModel()->create(); // 3
AssetModel::factory()->count(1)->xps13Model()->create(); // 4
AssetModel::factory()->count(1)->spectreModel()->create(); // 5
AssetModel::factory()->count(1)->zenbookModel()->create(); // 6
AssetModel::factory()->count(1)->yogaModel()->create(); // 7
AssetModel::factory()->count(1)->mbp13Model()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->mbpAirModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->surfaceModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->xps13Model()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->spectreModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->zenbookModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->yogaModel()->create(['user_id' => $admin->id]);
// Desktops
AssetModel::factory()->count(1)->macproModel()->create(); // 8
AssetModel::factory()->count(1)->lenovoI5Model()->create(); // 9
AssetModel::factory()->count(1)->optiplexModel()->create(); // 10
AssetModel::factory()->count(1)->macproModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->lenovoI5Model()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->optiplexModel()->create(['user_id' => $admin->id]);
// Conference Phones
AssetModel::factory()->count(1)->polycomModel()->create(); // 11
AssetModel::factory()->count(1)->polycomcxModel()->create(); // 12
AssetModel::factory()->count(1)->polycomModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->polycomcxModel()->create(['user_id' => $admin->id]);
// Tablets
AssetModel::factory()->count(1)->ipadModel()->create(); // 13
AssetModel::factory()->count(1)->tab3Model()->create(); // 14
AssetModel::factory()->count(1)->ipadModel()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->tab3Model()->create(['user_id' => $admin->id]);
// Phones
AssetModel::factory()->count(1)->iphone11Model()->create(); // 15
AssetModel::factory()->count(1)->iphone12Model()->create(); // 16
AssetModel::factory()->count(1)->iphone11Model()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->iphone12Model()->create(['user_id' => $admin->id]);
// Displays
AssetModel::factory()->count(1)->ultrafine()->create(); // 17
AssetModel::factory()->count(1)->ultrasharp()->create(); // 18
AssetModel::factory()->count(1)->ultrafine()->create(['user_id' => $admin->id]);
AssetModel::factory()->count(1)->ultrasharp()->create(['user_id' => $admin->id]);
$src = public_path('/img/demo/models/');
$dst = 'models'.'/';

View file

@ -3,6 +3,10 @@
namespace Database\Seeders;
use App\Models\Asset;
use App\Models\Location;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Sequence;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@ -10,40 +14,47 @@ use Illuminate\Support\Facades\Storage;
class AssetSeeder extends Seeder
{
private $admin;
private $locationIds;
private $supplierIds;
public function run()
{
Asset::truncate();
Asset::factory()->count(1000)->laptopMbp()->create();
Asset::factory()->count(50)->laptopMbpPending()->create();
Asset::factory()->count(50)->laptopMbpArchived()->create();
Asset::factory()->count(50)->laptopAir()->create();
Asset::factory()->count(5)->laptopSurface()->create();
Asset::factory()->count(5)->laptopXps()->create();
Asset::factory()->count(5)->laptopSpectre()->create();
Asset::factory()->count(5)->laptopZenbook()->create();
Asset::factory()->count(3)->laptopYoga()->create();
Asset::factory()->count(30)->desktopMacpro()->create();
Asset::factory()->count(30)->desktopLenovoI5()->create();
Asset::factory()->count(30)->desktopOptiplex()->create();
$this->ensureLocationsSeeded();
$this->ensureSuppliersSeeded();
Asset::factory()->count(5)->confPolycom()->create();
Asset::factory()->count(2)->confPolycomcx()->create();
$this->admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
$this->locationIds = Location::all()->pluck('id');
$this->supplierIds = Supplier::all()->pluck('id');
Asset::factory()->count(12)->tabletIpad()->create();
Asset::factory()->count(4)->tabletTab3()->create();
Asset::factory()->count(27)->phoneIphone11()->create();
Asset::factory()->count(40)->phoneIphone12()->create();
Asset::factory()->count(10)->ultrafine()->create();
Asset::factory()->count(10)->ultrasharp()->create();
Asset::factory()->count(1000)->laptopMbp()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(50)->laptopMbpPending()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(50)->laptopMbpArchived()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(50)->laptopAir()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(5)->laptopSurface()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(5)->laptopXps()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(5)->laptopSpectre()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(5)->laptopZenbook()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(3)->laptopYoga()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(30)->desktopMacpro()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(30)->desktopLenovoI5()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(30)->desktopOptiplex()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(5)->confPolycom()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(2)->confPolycomcx()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(12)->tabletIpad()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(4)->tabletTab3()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(27)->phoneIphone11()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(40)->phoneIphone12()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(10)->ultrafine()->state(new Sequence($this->getState()))->create();
Asset::factory()->count(10)->ultrasharp()->state(new Sequence($this->getState()))->create();
$del_files = Storage::files('assets');
foreach ($del_files as $del_file) { // iterate files
Log::debug('Deleting: '.$del_files);
Log::debug('Deleting: ' . $del_files);
try {
Storage::disk('public')->delete('assets'.'/'.$del_files);
Storage::disk('public')->delete('assets' . '/' . $del_files);
} catch (\Exception $e) {
Log::debug($e);
}
@ -51,4 +62,27 @@ class AssetSeeder extends Seeder
DB::table('checkout_requests')->truncate();
}
private function ensureLocationsSeeded()
{
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
}
private function ensureSuppliersSeeded()
{
if (! Supplier::count()) {
$this->call(SupplierSeeder::class);
}
}
private function getState()
{
return fn($sequence) => [
'rtd_location_id' => $this->locationIds->random(),
'supplier_id' => $this->supplierIds->random(),
'user_id' => $this->admin->id,
];
}
}

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Category;
use App\Models\User;
use Illuminate\Database\Seeder;
class CategorySeeder extends Seeder
@ -11,20 +12,22 @@ class CategorySeeder extends Seeder
{
Category::truncate();
Category::factory()->count(1)->assetLaptopCategory()->create(); // 1
Category::factory()->count(1)->assetDesktopCategory()->create(); // 2
Category::factory()->count(1)->assetTabletCategory()->create(); // 3
Category::factory()->count(1)->assetMobileCategory()->create(); // 4
Category::factory()->count(1)->assetDisplayCategory()->create(); // 5
Category::factory()->count(1)->assetVoipCategory()->create(); // 6
Category::factory()->count(1)->assetConferenceCategory()->create(); // 7
Category::factory()->count(1)->accessoryKeyboardCategory()->create(); // 8
Category::factory()->count(1)->accessoryMouseCategory()->create(); // 9
Category::factory()->count(1)->consumablePaperCategory()->create(); // 10
Category::factory()->count(1)->consumableInkCategory()->create(); // 11
Category::factory()->count(1)->componentHddCategory()->create(); // 12
Category::factory()->count(1)->componentRamCategory()->create(); // 13
Category::factory()->count(1)->licenseGraphicsCategory()->create(); // 14
Category::factory()->count(1)->licenseOfficeCategory()->create(); // 15
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Category::factory()->count(1)->assetLaptopCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetDesktopCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetTabletCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetMobileCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetDisplayCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetVoipCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->assetConferenceCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->accessoryKeyboardCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->accessoryMouseCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->consumablePaperCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->consumableInkCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->componentHddCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->componentRamCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->licenseGraphicsCategory()->create(['user_id' => $admin->id]);
Category::factory()->count(1)->licenseOfficeCategory()->create(['user_id' => $admin->id]);
}
}

View file

@ -2,7 +2,9 @@
namespace Database\Seeders;
use App\Models\Company;
use App\Models\Component;
use App\Models\Location;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
@ -12,9 +14,34 @@ class ComponentSeeder extends Seeder
{
Component::truncate();
DB::table('components_assets')->truncate();
Component::factory()->count(1)->ramCrucial4()->create(); // 1
Component::factory()->count(1)->ramCrucial8()->create(); // 1
Component::factory()->count(1)->ssdCrucial120()->create(); // 1
Component::factory()->count(1)->ssdCrucial240()->create(); // 1
if (! Company::count()) {
$this->call(CompanySeeder::class);
}
$companyIds = Company::all()->pluck('id');
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
$locationIds = Location::all()->pluck('id');
Component::factory()->ramCrucial4()->create([
'company_id' => $companyIds->random(),
'location_id' => $locationIds->random(),
]);
Component::factory()->ramCrucial8()->create([
'company_id' => $companyIds->random(),
'location_id' => $locationIds->random(),
]);
Component::factory()->ssdCrucial120()->create([
'company_id' => $companyIds->random(),
'location_id' => $locationIds->random(),
]);
Component::factory()->ssdCrucial240()->create([
'company_id' => $companyIds->random(),
'location_id' => $locationIds->random(),
]);
}
}

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Consumable;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
@ -12,8 +13,11 @@ class ConsumableSeeder extends Seeder
{
Consumable::truncate();
DB::table('consumables_users')->truncate();
Consumable::factory()->count(1)->cardstock()->create(); // 1
Consumable::factory()->count(1)->paper()->create(); // 2
Consumable::factory()->count(1)->ink()->create(); // 3
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Consumable::factory()->count(1)->cardstock()->create(['user_id' => $admin->id]);
Consumable::factory()->count(1)->paper()->create(['user_id' => $admin->id]);
Consumable::factory()->count(1)->ink()->create(['user_id' => $admin->id]);
}
}

View file

@ -3,15 +3,6 @@
namespace Database\Seeders;
use App\Models\Setting;
use Database\Seeders\AccessorySeeder;
use Database\Seeders\ActionlogSeeder;
use Database\Seeders\AssetModelSeeder;
use Database\Seeders\AssetSeeder;
use Database\Seeders\CategorySeeder;
use Database\Seeders\CompanySeeder;
use Database\Seeders\ComponentSeeder;
use Database\Seeders\ConsumableSeeder;
use Database\Seeders\CustomFieldSeeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Artisan;
@ -38,9 +29,9 @@ class DatabaseSeeder extends Seeder
$this->call(CompanySeeder::class);
$this->call(CategorySeeder::class);
$this->call(LocationSeeder::class);
$this->call(DepartmentSeeder::class);
$this->call(UserSeeder::class);
$this->call(DepreciationSeeder::class);
$this->call(DepartmentSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(SupplierSeeder::class);
$this->call(AssetModelSeeder::class);

View file

@ -3,6 +3,8 @@
namespace Database\Seeders;
use App\Models\Department;
use App\Models\Location;
use App\Models\User;
use Illuminate\Database\Seeder;
class DepartmentSeeder extends Seeder
@ -10,11 +12,43 @@ class DepartmentSeeder extends Seeder
public function run()
{
Department::truncate();
Department::factory()->count(1)->hr()->create(); // 1
Department::factory()->count(1)->engineering()->create(); // 2
Department::factory()->count(1)->marketing()->create(); // 3
Department::factory()->count(1)->client()->create(); // 4
Department::factory()->count(1)->product()->create(); // 5
Department::factory()->count(1)->silly()->create(); // 6
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
$locationIds = Location::all()->pluck('id');
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Department::factory()->count(1)->hr()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
Department::factory()->count(1)->engineering()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
Department::factory()->count(1)->marketing()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
Department::factory()->count(1)->client()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
Department::factory()->count(1)->product()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
Department::factory()->count(1)->silly()->create([
'location_id' => $locationIds->random(),
'user_id' => $admin->id,
]);
}
}

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Depreciation;
use App\Models\User;
use Illuminate\Database\Seeder;
class DepreciationSeeder extends Seeder
@ -10,8 +11,11 @@ class DepreciationSeeder extends Seeder
public function run()
{
Depreciation::truncate();
Depreciation::factory()->count(1)->computer()->create(); // 1
Depreciation::factory()->count(1)->display()->create(); // 2
Depreciation::factory()->count(1)->mobilePhones()->create(); // 3
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Depreciation::factory()->count(1)->computer()->create(['user_id' => $admin->id]);
Depreciation::factory()->count(1)->display()->create(['user_id' => $admin->id]);
Depreciation::factory()->count(1)->mobilePhones()->create(['user_id' => $admin->id]);
}
}

View file

@ -2,8 +2,11 @@
namespace Database\Seeders;
use App\Models\Category;
use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Database\Seeder;
class LicenseSeeder extends Seeder
@ -12,9 +15,43 @@ class LicenseSeeder extends Seeder
{
License::truncate();
LicenseSeat::truncate();
License::factory()->count(1)->photoshop()->create();
License::factory()->count(1)->acrobat()->create();
License::factory()->count(1)->indesign()->create();
License::factory()->count(1)->office()->create();
if (! Category::count()) {
$this->call(CategorySeeder::class);
}
$categoryIds = Category::all()->pluck('id');
if (! Supplier::count()) {
$this->call(SupplierSeeder::class);
}
$supplierIds = Supplier::all()->pluck('id');
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
License::factory()->count(1)->photoshop()->create([
'category_id' => $categoryIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
License::factory()->count(1)->acrobat()->create([
'category_id' => $categoryIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
License::factory()->count(1)->indesign()->create([
'category_id' => $categoryIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
License::factory()->count(1)->office()->create([
'category_id' => $categoryIds->random(),
'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id,
]);
}
}

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Manufacturer;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
@ -12,17 +13,20 @@ class ManufacturerSeeder extends Seeder
public function run()
{
Manufacturer::truncate();
Manufacturer::factory()->count(1)->apple()->create(); // 1
Manufacturer::factory()->count(1)->microsoft()->create(); // 2
Manufacturer::factory()->count(1)->dell()->create(); // 3
Manufacturer::factory()->count(1)->asus()->create(); // 4
Manufacturer::factory()->count(1)->hp()->create(); // 5
Manufacturer::factory()->count(1)->lenovo()->create(); // 6
Manufacturer::factory()->count(1)->lg()->create(); // 7
Manufacturer::factory()->count(1)->polycom()->create(); // 8
Manufacturer::factory()->count(1)->adobe()->create(); // 9
Manufacturer::factory()->count(1)->avery()->create(); // 10
Manufacturer::factory()->count(1)->crucial()->create(); // 10
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Manufacturer::factory()->count(1)->apple()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->microsoft()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->dell()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->asus()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->hp()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->lenovo()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->lg()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->polycom()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->adobe()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->avery()->create(['user_id' => $admin->id]);
Manufacturer::factory()->count(1)->crucial()->create(['user_id' => $admin->id]);
$src = public_path('/img/demo/manufacturers/');
$dst = 'manufacturers'.'/';

View file

@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Models\Statuslabel;
use App\Models\User;
use Illuminate\Database\Seeder;
class StatuslabelSeeder extends Seeder
@ -10,12 +11,27 @@ class StatuslabelSeeder extends Seeder
public function run()
{
Statuslabel::truncate();
Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
Statuslabel::factory()->pending()->create(['name' => 'Pending']);
Statuslabel::factory()->archived()->create(['name' => 'Archived']);
Statuslabel::factory()->outForDiagnostics()->create();
Statuslabel::factory()->outForRepair()->create();
Statuslabel::factory()->broken()->create();
Statuslabel::factory()->lost()->create();
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
Statuslabel::factory()->rtd()->create([
'name' => 'Ready to Deploy',
'user_id' => $admin->id,
]);
Statuslabel::factory()->pending()->create([
'name' => 'Pending',
'user_id' => $admin->id,
]);
Statuslabel::factory()->archived()->create([
'name' => 'Archived',
'user_id' => $admin->id,
]);
Statuslabel::factory()->outForDiagnostics()->create(['user_id' => $admin->id]);
Statuslabel::factory()->outForRepair()->create(['user_id' => $admin->id]);
Statuslabel::factory()->broken()->create(['user_id' => $admin->id]);
Statuslabel::factory()->lost()->create(['user_id' => $admin->id]);
}
}

View file

@ -2,7 +2,10 @@
namespace Database\Seeders;
use App\Models\Company;
use App\Models\Department;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Sequence;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;
@ -17,11 +20,53 @@ class UserSeeder extends Seeder
public function run()
{
User::truncate();
User::factory()->count(1)->firstAdmin()->create();
User::factory()->count(1)->snipeAdmin()->create();
User::factory()->count(3)->superuser()->create();
User::factory()->count(3)->admin()->create();
User::factory()->count(50)->viewAssets()->create();
if (! Company::count()) {
$this->call(CompanySeeder::class);
}
$companyIds = Company::all()->pluck('id');
if (! Department::count()) {
$this->call(DepartmentSeeder::class);
}
$departmentIds = Department::all()->pluck('id');
User::factory()->count(1)->firstAdmin()
->state(new Sequence(fn($sequence) => [
'company_id' => $companyIds->random(),
'department_id' => $departmentIds->random(),
]))
->create();
User::factory()->count(1)->snipeAdmin()
->state(new Sequence(fn($sequence) => [
'company_id' => $companyIds->random(),
'department_id' => $departmentIds->random(),
]))
->create();
User::factory()->count(3)->superuser()
->state(new Sequence(fn($sequence) => [
'company_id' => $companyIds->random(),
'department_id' => $departmentIds->random(),
]))
->create();
User::factory()->count(3)->admin()
->state(new Sequence(fn($sequence) => [
'company_id' => $companyIds->random(),
'department_id' => $departmentIds->random(),
]))
->create();
User::factory()->count(50)->viewAssets()
->state(new Sequence(fn($sequence) => [
'company_id' => $companyIds->random(),
'department_id' => $departmentIds->random(),
]))
->create();
$src = public_path('/img/demo/avatars/');
$dst = 'avatars'.'/';

View file

@ -202,6 +202,7 @@ return [
'slack' => 'Slack',
'general_webhook' => 'General Webhook',
'webhook' => ':app',
'webhook_presave' => 'Test to Save',
'webhook_title' => 'Update Webhook Settings',
'webhook_help' => 'Integration settings',
'webhook_botname' => ':app Botname',

View file

@ -417,6 +417,6 @@ return [
'merged' => 'merged',
'merged_log_this_user_into' => 'Merged this user (ID :to_id - :to_username) into user ID :from_id (:from_username) ',
'merged_log_this_user_from' => 'Merged user ID :from_id (:from_username) into this user (ID :to_id - :to_username)',
'clear_and_save' => 'Clear & Save',
];

View file

@ -12,34 +12,33 @@
{{-- Page content --}}
@section('content')
<div>
<div><!-- livewire div - do not remove -->
<form class="form-horizontal" role="form" wire:submit.prevent="submit">
{{csrf_field()}}
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="panel box box-default">
<div class="box-header with-border">
<h2 class="box-title">
<i class="{{$webhook_icon}}"></i> {{ trans('admin/settings/general.webhook', ['app' => $webhook_name] ) }}
</h2>
</div>
<div class="box-body">
<div class="col-md-12">
@if($webhook_selected != 'general')
<p>
{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_name)) !!}
</p>
@endif
<br>
</div>
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="panel box box-default">
<div class="box-header with-border">
<h2 class="box-title">
<i class="{{$webhook_icon}}"></i> {{ trans('admin/settings/general.webhook', ['app' => $webhook_name] ) }}
</h2>
</div>
<div class="box-body">
@if($webhook_selected != 'general')
<div class="col-md-12">
@if (session()->has('save'))
<div class="alert alert-success fade in">
{{session('save')}}
</div>
@endif
<p>
{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_name)) !!}
</p>
<br>
</div>
@endif
<div class="col-md-12" style="border-top: 0px;">
@if(session()->has('success'))
<div class="alert alert-success fade in">
@ -51,123 +50,135 @@
{{session('error')}}
</div>
@endif
@if(session()->has('message'))
<div class="alert alert-danger fade in">
{{session('message')}}
<div class="form-group">
<div class="col-md-2">
<label for="webhook_selected">
{{ trans('general.integration_option') }}
</label>
</div>
<div class="col-md-9 required" wire:ignore>
{{ Form::select('webhook_selected', array('slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook')), old('webhook_selected', $webhook_selected), array('class'=>'select2 form-control', 'aria-label' => 'webhook_selected', 'id' => 'select2', 'style'=>'width:90%')) }}
</div>
</div>
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!--Webhook endpoint-->
<div class="form-group{{ $errors->has('webhook_endpoint') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_endpoint', trans('admin/settings/general.webhook_endpoint',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9 required">
<input type="text" wire:model="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<div class="form-group col-md-12 required">
<div class="col-md-3">
<label for="webhook_selected">
{{ trans('general.integration_option') }}
</label>
</div>
<div class="col-md-9">
<select wire:model="webhook_selected" aria-label="webhook_selected" class="form-control">
<option value="slack">{{ trans('admin/settings/general.slack') }}</option>
<option value="general">{{ trans('admin/settings/general.general_webhook') }}</option>
</select>
</div>
</div>
<!--Webhook endpoint-->
<div class="form-group col-md-12 required{{ $errors->has('webhook_endpoint') ? ' error' : '' }}">
<div class="col-md-3">
{{ Form::label('webhook_endpoint', trans('admin/settings/general.webhook_endpoint',['app' => ucwords($webhook_selected) ])) }}
</div>
<div class="col-md-9">
@if (config('app.lock_passwords')===true)
<p class="text-warning">
<i class="fas fa-lock" aria-hidden="true"></i>
{{ trans('general.feature_disabled') }}
</p>
<input type="text" wire:model="webhook_endpoint" class="form-control" placeholder="{{ $webhook_placeholder }}" value="{{ old('webhook_endpoint', $webhook_endpoint) }}">
@else
<input type="text" wire:model="webhook_endpoint" class="form-control" placeholder="{{ $webhook_placeholder }}" value="{{ old('webhook_endpoint', $webhook_endpoint) }}">
@endif
{!! $errors->first('webhook_endpoint', '<span class="alert-msg">:message</span>') !!}
</div>
</div>
<!-- Webhook channel -->
<div class="col-md-12 form-group required{{ $errors->has('webhook_channel') ? ' error' : '' }}">
<div class="col-md-3">
{{ Form::label('webhook_channel', trans('admin/settings/general.webhook_channel',['app' => ucwords($webhook_selected) ])) }}
<div class="form-group{{ $errors->has('webhook_channel') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_channel', trans('admin/settings/general.webhook_channel',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9">
<div class="col-md-9 required">
<input type="text" wire:model="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
@if (config('app.lock_passwords')===true)
<input type="text" wire:model="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}">
<p class="text-warning">
<i class="fas fa-lock" aria-hidden="true"></i> {{ trans('general.feature_disabled') }}</p>
@else
<input type="text" wire:model="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}">
@endif
{!! $errors->first('webhook_channel', '<span class="alert-msg">:message</span>') !!}
{!! $errors->first('webhook_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
<!-- Webhook botname -->
<div class="col-md-12 form-group required{{ $errors->has('webhook_botname') ? ' error' : '' }}">
<div class="col-md-3">
{{ Form::label('webhook_botname', trans('admin/settings/general.webhook_botname',['app' => ucwords($webhook_selected) ])) }}
</div>
<div class="col-md-9">
@if (config('app.lock_passwords')===true)
<input type="text" wire:model="webhook_botname" class='form-control'
placeholder="Snipe-Bot" {{old('webhook_botname', $webhook_botname)}}>
<p class="text-warning"><i class="fas fa-lock"></i>
{{ trans('general.feature_disabled') }}
</p>
@else
<input type="text" wire:model="webhook_botname" class="form-control" placeholder="Snipe-Bot" {{old('webhook_botname', $webhook_botname)}}>
@endif
{!! $errors->first('webhook_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10-->
@if (Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!-- Webhook botname -->
<div class="form-group{{ $errors->has('webhook_botname') ? ' error' : '' }}">
<div class="col-md-2">
{{ Form::label('webhook_botname', trans('admin/settings/general.webhook_botname',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9">
<input type="text" wire:model="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10-->
</div>
<!--Webhook Integration Test-->
@if($webhook_selected == 'slack')
@if($webhook_endpoint != null && $webhook_channel != null)
<div class="form-group col-md-12">
<div class="col-md-offset-3 col-md-9">
<a href="#" wire:click.prevent="testWebhook"
class="btn btn-default btn-sm pull-left">
<i class="{{$webhook_icon}}" aria-hidden="true"></i>
{!! trans('admin/settings/general.webhook_test',['app' => ucwords($webhook_selected) ]) !!}
</a>
<div wire:loading>
<span style="padding-left: 5px; font-size: 20px">
<i class="fas fa-spinner fa-spin" aria-hidden="true"></i>
</span>
</div>
@if (!Helper::isDemoMode())
@include('partials.forms.demo-mode')
@endif
<!--Webhook Integration Test-->
@if($webhook_selected == 'slack')
@if($webhook_endpoint != null && $webhook_channel != null)
<div class="form-group">
<div class="col-md-offset-2 col-md-9">
<a href="#" wire:click.prevent="testWebhook"
class="btn btn-default btn-sm pull-left">
<i class="{{$webhook_icon}}" aria-hidden="true"></i>
{!! trans('admin/settings/general.webhook_test',['app' => ucwords($webhook_selected) ]) !!}
</a>
<div wire:loading>
<span style="padding-left: 5px; font-size: 20px">
<i class="fas fa-spinner fa-spin" aria-hidden="true"></i>
</span>
</div>
</div>
@endif
@endif
<div class="box-footer" style="margin-top: 45px;">
<div class="text-right col-md-12">
<a class="btn btn-link text-left"
href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" {{$isDisabled}} class="btn btn-primary"><i
class="fas fa-check icon-white"
aria-hidden="true"></i> {{ trans('general.save') }}</button>
</div>
</div><!--box-footer-->
</div> <!-- /box -->
</div> <!-- /.col-md-8-->
</div>
</div>
</form>
</div>
@endif
@endif
</div><!-- /.col-md-12 -->
</div><!-- /.box-body -->
<div class="box-footer">
<div class="text-right col-md-12">
<button type="reset" wire:click.prevent="clearSettings" class="col-md-2 text-left btn btn-danger pull-left"{{ Helper::isDemoMode() ? ' disabled' : ''}}>{{ trans('general.clear_and_save') }}</button>
<a class="btn btn-link pull-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" {{$isDisabled}} class="btn btn-primary"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
<i class="fas fa-check icon-white" aria-hidden="true"></i> {{ $save_button }}</button>
</div> <!-- /.col-md-12 -->
</div><!--box-footer-->
</div> <!-- /.box -->
</div> <!-- /.col-md-8-->
</div> <!-- /.row -->
</form>
</div> <!-- /livewire div -->
@section('moar_scripts')
<script>
$(document).ready(function () {
$('#select2').select2();
$('#select2').on('change', function (e) {
var data = $('#select2').select2("val");
@this.set('webhook_selected', data);
});
// Re-render select2
window.livewire.hook('message.processed', function (el, component) {
$('.select2').select2();
});
});
</script>
@endsection

View file

@ -0,0 +1,5 @@
<div class="row">
<div class="col-md-10 col-md-offset-2">
{!! Helper::showDemoModeFieldWarning() !!}
</div>
</div>

View file

@ -0,0 +1,35 @@
<?php
namespace Tests\Feature\Api\Assets;
use App\Models\Asset;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Testing\Fluent\AssertableJson;
use Laravel\Passport\Passport;
use Tests\TestCase;
class AssetIndexTest extends TestCase
{
public function testAssetIndexReturnsExpectedAssets()
{
Setting::factory()->create();
Asset::factory()->count(3)->create();
Passport::actingAs(User::factory()->superuser()->create());
$this->getJson(
route('api.assets.index', [
'sort' => 'name',
'order' => 'asc',
'offset' => '0',
'limit' => '20',
]))
->assertOk()
->assertJsonStructure([
'total',
'rows',
])
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
}
}

View file

@ -15,9 +15,9 @@ class UsersForSelectListTest extends TestCase
{
Setting::factory()->create();
User::factory()->count(3)->create();
$users = User::factory()->superuser()->count(3)->create();
Passport::actingAs(User::factory()->firstAdmin()->create());
Passport::actingAs($users->first());
$this->getJson(route('api.users.selectlist'))
->assertOk()
->assertJsonStructure([
@ -27,7 +27,7 @@ class UsersForSelectListTest extends TestCase
'page',
'page_count',
])
->assertJson(fn(AssertableJson $json) => $json->has('results', 4)->etc());
->assertJson(fn(AssertableJson $json) => $json->has('results', 3)->etc());
}
public function testUsersScopedToCompanyWhenMultipleFullCompanySupportEnabled()

View file

@ -36,7 +36,7 @@ class AssetTest extends TestCase
'model_id' => AssetModel::factory()
->create(
[
'category_id' => Category::factory()->assetLaptopCategory()->id
'category_id' => Category::factory()->assetLaptopCategory()->create()->id
]
)->id,
'warranty_months' => 24,

View file

@ -26,7 +26,7 @@ class CategoryTest extends TestCase
public function testACategoryCanHaveAssets()
{
$category = Category::factory()->assetDesktopCategory();
$category = Category::factory()->assetDesktopCategory()->create();
// Generate 5 models via factory
$models = AssetModel::factory()

View file

@ -18,7 +18,7 @@ class DepreciationTest extends TestCase
->count(5)
->create(
[
'category_id' => Category::factory()->assetLaptopCategory(),
'category_id' => Category::factory()->assetLaptopCategory()->create(),
'depreciation_id' => $depreciation->id
]);
@ -35,7 +35,7 @@ class DepreciationTest extends TestCase
->photoshop()
->create(
[
'category_id' => Category::factory()->licenseGraphicsCategory(),
'category_id' => Category::factory()->licenseGraphicsCategory()->create(),
'depreciation_id' => $depreciation->id
]);

View file

@ -22,7 +22,7 @@ class NotificationTest extends TestCase
'model_id' => AssetModel::factory()
->create(
[
'category_id' => Category::factory()->assetLaptopCategory()->id
'category_id' => Category::factory()->assetLaptopCategory()->create()->id
]
)->id,
'warranty_months' => 24,