mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 08:04:09 -08:00
Merge branch 'develop'
This commit is contained in:
commit
7a0e695ea0
|
@ -37,7 +37,7 @@ class DemoData extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:demo-seed {--username=*}';
|
||||
protected $signature = 'snipeit:demo-seed {--nukeusers}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
@ -74,23 +74,6 @@ class DemoData extends Command
|
|||
|
||||
if ($this->confirm("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n This will overwrite your existing database. Do you wish to continue?")) {
|
||||
|
||||
|
||||
$this->dropRealCustomFieldsColumns();
|
||||
$this->dropAndCreateCategories();
|
||||
$this->dropAndCreateManufacturers();
|
||||
$this->dropAndCreateLocations();
|
||||
$this->dropAndCreateActionlogs();
|
||||
$this->dropAndCreateAssetModels();
|
||||
$this->dropAndCreateStatusLabels();
|
||||
$this->dropAndCreateAssets();
|
||||
$this->dropAndCreateDepreciations();
|
||||
$this->dropAndCreateSuppliers();
|
||||
$this->dropAndCreateAccessories();
|
||||
$this->dropAndCreateLicenses();
|
||||
$this->dropAndCreateComponents();
|
||||
$this->dropAndCreateConsumables();
|
||||
|
||||
|
||||
Import::truncate();
|
||||
AssetMaintenance::truncate();
|
||||
Group::truncate();
|
||||
|
@ -98,13 +81,31 @@ class DemoData extends Command
|
|||
CustomField::truncate();
|
||||
Group::truncate();
|
||||
CustomFieldset::truncate();
|
||||
Department::truncate();
|
||||
User::where('username', '!=', 'snipe')
|
||||
->where('username', '!=', 'admin')
|
||||
->forceDelete();
|
||||
|
||||
DB::table('custom_field_custom_fieldset')->truncate();
|
||||
DB::table('checkout_requests')->truncate();
|
||||
|
||||
$this->dropRealCustomFieldsColumns();
|
||||
$this->dropAndCreateCategories();
|
||||
$this->dropAndCreateManufacturers();
|
||||
$this->dropAndCreateAssetModels();
|
||||
$this->dropAndCreateStatusLabels();
|
||||
$this->dropAndCreateDepreciations();
|
||||
$this->dropAndCreateSuppliers();
|
||||
$this->dropAndCreateAccessories();
|
||||
$this->dropAndCreateLicenses();
|
||||
$this->dropAndCreateComponents();
|
||||
$this->dropAndCreateConsumables();
|
||||
$this->dropAndCreateLocations();
|
||||
if ($this->option('nukeusers')) {
|
||||
$this->dropAndCreateUsers();
|
||||
}
|
||||
|
||||
$this->dropAndCreateAssets();
|
||||
$this->dropAndCreateActionlogs();
|
||||
$this->dropAndCreateDepartments();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -289,6 +290,81 @@ class DemoData extends Command
|
|||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000311'
|
||||
],
|
||||
[
|
||||
'id' => 12,
|
||||
'user_id' => 1,
|
||||
'name' => null,
|
||||
'model_id' => 14,
|
||||
'assigned_to' => null,
|
||||
'assigned_type' => null,
|
||||
'purchase_cost' => '899.56',
|
||||
'purchase_date' => date('Y-m-d'),
|
||||
'supplier_id' => rand(1,4),
|
||||
'status_id' => 1,
|
||||
'rtd_location_id' => rand(1,4),
|
||||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000312'
|
||||
],
|
||||
[
|
||||
'id' => 13,
|
||||
'user_id' => 1,
|
||||
'name' => null,
|
||||
'model_id' => 14,
|
||||
'assigned_to' => null,
|
||||
'assigned_type' => null,
|
||||
'purchase_cost' => '899.56',
|
||||
'purchase_date' => date('Y-m-d'),
|
||||
'supplier_id' => rand(1,4),
|
||||
'status_id' => 1,
|
||||
'rtd_location_id' => rand(1,4),
|
||||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000313'
|
||||
],
|
||||
[
|
||||
'id' => 14,
|
||||
'user_id' => 1,
|
||||
'name' => null,
|
||||
'model_id' => 14,
|
||||
'assigned_to' => null,
|
||||
'assigned_type' => null,
|
||||
'purchase_cost' => '899.56',
|
||||
'purchase_date' => date('Y-m-d'),
|
||||
'supplier_id' => rand(1,4),
|
||||
'status_id' => 4,
|
||||
'rtd_location_id' => rand(1,4),
|
||||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000314'
|
||||
],
|
||||
[
|
||||
'id' => 15,
|
||||
'user_id' => 1,
|
||||
'name' => 'Reception Laptop',
|
||||
'model_id' => 4,
|
||||
'assigned_to' => 3,
|
||||
'assigned_type' => Location::class,
|
||||
'purchase_cost' => '3025.56',
|
||||
'purchase_date' => date('Y-m-d'),
|
||||
'supplier_id' => rand(1,4),
|
||||
'status_id' => 1,
|
||||
'rtd_location_id' => rand(1,4),
|
||||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000315'
|
||||
],
|
||||
[
|
||||
'id' => 16,
|
||||
'user_id' => 1,
|
||||
'name' => 'Testing Laptop',
|
||||
'model_id' => 4,
|
||||
'assigned_to' => 2,
|
||||
'assigned_type' => User::class,
|
||||
'purchase_cost' => '3025.56',
|
||||
'purchase_date' => date('Y-m-d'),
|
||||
'supplier_id' => rand(1,4),
|
||||
'status_id' => 1,
|
||||
'rtd_location_id' => rand(1,4),
|
||||
'serial' => self::generateRandomString(),
|
||||
'asset_tag' => '1000316'
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
@ -362,7 +438,7 @@ class DemoData extends Command
|
|||
|
||||
|
||||
public function dropAndCreateSuppliers() {
|
||||
|
||||
$this->info('Dropping suppliers data');
|
||||
Supplier::truncate();
|
||||
|
||||
$supppliers = [
|
||||
|
@ -390,12 +466,13 @@ class DemoData extends Command
|
|||
|
||||
// Create Depreciations
|
||||
DB::table('suppliers')->insert($supppliers);
|
||||
$this->info('Generating suppliers data');
|
||||
return $supppliers;
|
||||
}
|
||||
|
||||
|
||||
public function dropAndCreateDepreciations() {
|
||||
|
||||
$this->info('Dropping depreciations data');
|
||||
Depreciation::truncate();
|
||||
|
||||
$depreciations = [
|
||||
|
@ -414,13 +491,15 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Depreciations
|
||||
$this->info('Generating suppliers data');
|
||||
DB::table('depreciations')->insert($depreciations);
|
||||
|
||||
return $depreciations;
|
||||
}
|
||||
|
||||
|
||||
public function dropAndCreateAssetModels() {
|
||||
|
||||
$this->info('Dropping asset model data');
|
||||
AssetModel::truncate();
|
||||
|
||||
$models = [
|
||||
|
@ -582,14 +661,17 @@ class DemoData extends Command
|
|||
'model_number' => rand(111111,99999)
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
||||
// Create Models
|
||||
$this->info('generating asset model data');
|
||||
DB::table('models')->insert($models);
|
||||
return $models;
|
||||
}
|
||||
public function dropAndCreateCategories() {
|
||||
|
||||
$this->info('Dropping category data');
|
||||
Category::truncate();
|
||||
$categories = [
|
||||
|
||||
|
@ -686,12 +768,14 @@ class DemoData extends Command
|
|||
|
||||
|
||||
// Create Categories
|
||||
$this->info('Generating category data');
|
||||
DB::table('categories')->insert($categories);
|
||||
return $categories;
|
||||
}
|
||||
|
||||
public function dropAndCreateLocations() {
|
||||
|
||||
$this->info('Dropping location data');
|
||||
Location::truncate();
|
||||
|
||||
$locations = [
|
||||
|
@ -720,6 +804,7 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating location data');
|
||||
DB::table('locations')->insert($locations);
|
||||
return $locations;
|
||||
|
||||
|
@ -727,6 +812,7 @@ class DemoData extends Command
|
|||
|
||||
public function dropAndCreateLicenses() {
|
||||
|
||||
$this->info('Dropping licenses and seat data');
|
||||
License::truncate();
|
||||
LicenseSeat::truncate();
|
||||
|
||||
|
@ -789,6 +875,7 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Licenses
|
||||
$this->info('Dropping license and seat data');
|
||||
DB::table('licenses')->insert($licenses);
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
|
@ -811,6 +898,7 @@ class DemoData extends Command
|
|||
|
||||
public function dropAndCreateAccessories() {
|
||||
|
||||
$this->info('Dropping accessory data');
|
||||
Accessory::truncate();
|
||||
DB::table('accessories_users')->truncate();
|
||||
|
||||
|
@ -869,6 +957,7 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating accessory data');
|
||||
DB::table('accessories')->insert($accessories);
|
||||
return $accessories;
|
||||
|
||||
|
@ -878,6 +967,7 @@ class DemoData extends Command
|
|||
|
||||
public function dropAndCreateComponents() {
|
||||
|
||||
$this->info('Dropping component data');
|
||||
Component::truncate();
|
||||
DB::table('components_assets')->truncate();
|
||||
|
||||
|
@ -898,6 +988,7 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating component data');
|
||||
DB::table('components')->insert($components);
|
||||
return $components;
|
||||
|
||||
|
@ -906,6 +997,7 @@ class DemoData extends Command
|
|||
|
||||
public function dropAndCreateConsumables() {
|
||||
|
||||
$this->info('Dropping consumable data');
|
||||
Consumable::truncate();
|
||||
DB::table('consumables_users')->truncate();
|
||||
|
||||
|
@ -927,16 +1019,139 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating consumable data');
|
||||
DB::table('consumables')->insert($consumables);
|
||||
return $consumables;
|
||||
|
||||
}
|
||||
|
||||
public function dropAndCreateUsers() {
|
||||
|
||||
$this->info('Dropping users data (except user: admin)');
|
||||
User::where('username', '!=', 'snipe')
|
||||
->where('username', '!=', 'admin')
|
||||
->forceDelete();
|
||||
|
||||
$users = [
|
||||
|
||||
// Users
|
||||
[
|
||||
'first_name' => 'Test',
|
||||
'last_name' => 'User',
|
||||
'username' => 'testuser',
|
||||
'email' => 'testuser@snipe.net',
|
||||
'jobtitle' => 'Just a test user',
|
||||
'notes' => 'Created by demo seeder',
|
||||
'location_id' => 1,
|
||||
'department_id' => 1,
|
||||
'password' => bcrypt('password'),
|
||||
'activated' => 1,
|
||||
],
|
||||
[
|
||||
'first_name' => 'Donald',
|
||||
'last_name' => 'Duck',
|
||||
'username' => 'donaldduck',
|
||||
'email' => 'donaldduck@example.com',
|
||||
'jobtitle' => 'Director of Engineering',
|
||||
'notes' => 'Created by demo seeder',
|
||||
'location_id' => 2,
|
||||
'department_id' => 3,
|
||||
'password' => bcrypt('password'),
|
||||
'activated' => 1,
|
||||
],
|
||||
[
|
||||
'first_name' => 'Adrian',
|
||||
'last_name' => 'Whapcaplet',
|
||||
'username' => 'adrianwhapcaplet',
|
||||
'email' => 'adrianwhapcaplet@example.com',
|
||||
'jobtitle' => 'HR Manager',
|
||||
'notes' => 'Created by demo seeder',
|
||||
'location_id' => 2,
|
||||
'department_id' => 1,
|
||||
'password' => bcrypt('password'),
|
||||
'activated' => 1,
|
||||
],
|
||||
[
|
||||
'first_name' => 'Arthur',
|
||||
'last_name' => 'Nudge',
|
||||
'username' => 'arthurnudge',
|
||||
'email' => 'arthurnudge@example.com',
|
||||
'jobtitle' => 'Social Media Manager',
|
||||
'notes' => 'Created by demo seeder',
|
||||
'location_id' => 2,
|
||||
'department_id' => 2,
|
||||
'password' => bcrypt('password'),
|
||||
'activated' => 1,
|
||||
],
|
||||
[
|
||||
'first_name' => 'Spiny',
|
||||
'last_name' => 'Norman',
|
||||
'username' => 'spinynorman',
|
||||
'email' => 'spinynorman@example.com',
|
||||
'jobtitle' => 'CEO',
|
||||
'notes' => 'Created by demo seeder',
|
||||
'location_id' => 2,
|
||||
'department_id' => 2,
|
||||
'password' => bcrypt('password'),
|
||||
'activated' => 1,
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating user data');
|
||||
DB::table('users')->insert($users);
|
||||
return $users;
|
||||
|
||||
}
|
||||
|
||||
public function dropAndCreateDepartments() {
|
||||
|
||||
$this->info('Dropping department data');
|
||||
Department::truncate();
|
||||
|
||||
$departments = [
|
||||
|
||||
// Departments
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'Human Resources',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'Dept of Silly Walks',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'Engineering',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'Marketing',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'Client Services',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
// Create Locations
|
||||
$this->info('Generating suppliers data');
|
||||
DB::table('departments')->insert($departments);
|
||||
return $departments;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function dropAndCreateActionlogs() {
|
||||
|
||||
$this->info('Dropping actionlog data');
|
||||
Actionlog::truncate();
|
||||
|
||||
|
||||
$action_logs = [
|
||||
|
||||
// Action logs
|
||||
|
@ -1010,16 +1225,38 @@ class DemoData extends Command
|
|||
'created_at' => date('Y-m-d'),
|
||||
'note' => 'Created by demo seeder',
|
||||
],
|
||||
[
|
||||
'user_id' => 1,
|
||||
'action_type' => 'checkout',
|
||||
'target_id' => 3,
|
||||
'target_type' => Location::class,
|
||||
'item_type' => Asset::class,
|
||||
'item_id' => 15,
|
||||
'created_at' => date('Y-m-d'),
|
||||
'note' => 'Created by demo seeder',
|
||||
],
|
||||
[
|
||||
'user_id' => 1,
|
||||
'action_type' => 'checkout',
|
||||
'target_id' => 1,
|
||||
'target_type' => User::class,
|
||||
'item_type' => Asset::class,
|
||||
'item_id' => 16,
|
||||
'created_at' => date('Y-m-d'),
|
||||
'note' => 'Created by demo seeder',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
// Create Logs
|
||||
$this->info('Generating actionlog data');
|
||||
DB::table('action_logs')->insert($action_logs);
|
||||
return $action_logs;
|
||||
}
|
||||
|
||||
public function dropAndCreateStatusLabels() {
|
||||
|
||||
$this->info('Dropping statuslabel data');
|
||||
Statuslabel::truncate();
|
||||
|
||||
$statuslabels = [
|
||||
|
@ -1076,23 +1313,30 @@ class DemoData extends Command
|
|||
];
|
||||
|
||||
// Create status labels
|
||||
$this->info('Dropping statuslabel data');
|
||||
DB::table('status_labels')->insert($statuslabels);
|
||||
return $statuslabels;
|
||||
}
|
||||
|
||||
public function dropRealCustomFieldsColumns() {
|
||||
// delete custom field columns on the asset table
|
||||
$this->info('Dropping custom fields from asset table');
|
||||
$fields = Customfield::all();
|
||||
$fieldcount = 0;
|
||||
foreach ($fields as $field) {
|
||||
if ($field->db_column!='') {
|
||||
$fieldcount++;
|
||||
$this->info('Dropping DB column: '.$field->db_column);
|
||||
Schema::table('assets', function (Blueprint $table) {
|
||||
$table->dropColumn($field->db_column);
|
||||
});
|
||||
}
|
||||
}
|
||||
$this->info('Dropped '.$fieldcount.' fields from asset table');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
|
|
|
@ -369,143 +369,5 @@ class AccessoriesController extends Controller
|
|||
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkin.error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the JSON response for accessories listing view.
|
||||
*
|
||||
* Example:
|
||||
* {
|
||||
* "actions": "(links to available actions)",
|
||||
* "category": "(link to category)",
|
||||
* "company": "My Company",
|
||||
* "location": "My Location",
|
||||
* "min_amt": 2,
|
||||
* "name": "(link to accessory),
|
||||
* "numRemaining": 6,
|
||||
* "order_number": null,
|
||||
* "purchase_cost": "0.00",
|
||||
* "purchase_date": null,
|
||||
* "qty": 7
|
||||
* },
|
||||
*
|
||||
* The names of the fields in the returns JSON correspond directly to the the
|
||||
* names of the fields in the bootstrap-tables in the view.
|
||||
*
|
||||
* For debugging, see at /api/accessories/list
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param Request $request
|
||||
* @return string JSON containing accessories and their associated atrributes.
|
||||
* @internal param int $accessoryId
|
||||
*/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$this->authorize('index', Accessory::class);
|
||||
$accessories = Company::scopeCompanyables(
|
||||
Accessory::select('accessories.*')
|
||||
->whereNull('accessories.deleted_at')
|
||||
->with('category', 'company', 'manufacturer', 'users', 'location')
|
||||
);
|
||||
if (Input::has('search')) {
|
||||
$accessories = $accessories->TextSearch(e(Input::get('search')));
|
||||
}
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$allowed_columns = ['name','min_amt','order_number','purchase_date','purchase_cost','company','category','model_number', 'manufacturer', 'location'];
|
||||
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'category':
|
||||
$accessories = $accessories->OrderCategory($order);
|
||||
break;
|
||||
case 'company':
|
||||
$accessories = $accessories->OrderCompany($order);
|
||||
break;
|
||||
case 'location':
|
||||
$accessories = $accessories->OrderLocation($order);
|
||||
break;
|
||||
case 'manufacturer':
|
||||
$accessories = $accessories->OrderManufacturer($order);
|
||||
break;
|
||||
default:
|
||||
$accessories = $accessories->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$accessCount = $accessories->count();
|
||||
$accessories = $accessories->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
$rows[] = $accessory->present()->forDataTable();
|
||||
}
|
||||
|
||||
$data = array('total'=>$accessCount, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the JSON response for accessory detail view.
|
||||
*
|
||||
* Example:
|
||||
* <code>
|
||||
* {
|
||||
* "rows": [
|
||||
* {
|
||||
* "actions": "(link to available actions)",
|
||||
* "name": "(link to user)"
|
||||
* }
|
||||
* ],
|
||||
* "total": 1
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* The names of the fields in the returns JSON correspond directly to the the
|
||||
* names of the fields in the bootstrap-tables in the view.
|
||||
*
|
||||
* For debugging, see at /api/accessories/$accessoryID/view
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $accessoryId
|
||||
* @return string JSON containing accessories and their associated atrributes.
|
||||
**/
|
||||
public function getDataView(Request $request, $accessoryID)
|
||||
{
|
||||
$accessory = Accessory::find($accessoryID);
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($accessory)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
|
||||
$accessory_users = $accessory->users;
|
||||
$count = $accessory_users->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessory_users as $user) {
|
||||
$actions = '';
|
||||
if (Gate::allows('checkin', $accessory)) {
|
||||
$actions .= Helper::generateDatatableButton('checkin', route('checkin/accessory', $user->pivot->id));
|
||||
}
|
||||
|
||||
if (Gate::allows('view', $user)) {
|
||||
$name = (string) link_to_route('users.show', e($user->present()->fullName()), [$user->id]);
|
||||
} else {
|
||||
$name = e($user->present()->fullName());
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
'name' => $name,
|
||||
'actions' => $actions
|
||||
);
|
||||
}
|
||||
|
||||
$data = array('total'=>$count, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,6 @@ class ComponentsController extends Controller
|
|||
$limit = $request->input('limit', 50);
|
||||
$total = $assets->count();
|
||||
$assets = $assets->skip($offset)->take($limit)->get();
|
||||
return (new ComponentsAssetsTransformer)->transformAssets($assets, $total);
|
||||
return (new ComponentsTransformer)->transformCheckedoutComponents($assets, $total);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,49 +366,6 @@ class AssetModelsController extends Controller
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Get the asset information to present to the model view detail page
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v2.0]
|
||||
* @param Request $request
|
||||
* @param $modelID
|
||||
* @return String JSON
|
||||
* @internal param int $modelId
|
||||
*/
|
||||
public function getDataView(Request $request, $modelID)
|
||||
{
|
||||
$assets = Asset::where('model_id', '=', $modelID)->with('company', 'assetstatus');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$assets = $assets->TextSearch(e($request->input('search')));
|
||||
}
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
|
||||
$allowed_columns = ['name', 'serial','asset_tag'];
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
$assets = $assets->orderBy($sort, $order);
|
||||
|
||||
$assetsCount = $assets->count();
|
||||
$assets = $assets->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
$all_custom_fields = CustomField::all();
|
||||
foreach ($assets as $asset) {
|
||||
|
||||
$rows[] = $asset->present()->forDataTable($all_custom_fields);
|
||||
}
|
||||
|
||||
$data = array('total' => $assetsCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view that allows the user to bulk edit model attrbutes
|
||||
|
|
|
@ -673,7 +673,8 @@ class AssetsController extends Controller
|
|||
return response()->file($barcode_file, $header);
|
||||
} else {
|
||||
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode, $asset->asset_tag, 250, 20);
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode,$asset->asset_tag,300,50);
|
||||
|
||||
file_put_contents($barcode_file, $barcode_obj->getPngData());
|
||||
return response($barcode_obj->getPngData())->header('Content-type', 'image/png');
|
||||
}
|
||||
|
|
|
@ -288,35 +288,4 @@ class ComponentsController extends Controller
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return JSON data to populate the components view,
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see ComponentsController::getView() method that returns the view.
|
||||
* @since [v3.0]
|
||||
* @param int $componentId
|
||||
* @return string JSON
|
||||
*/
|
||||
public function getDataView($componentId)
|
||||
{
|
||||
if (is_null($component = Component::with('assets')->find($componentId))) {
|
||||
// Redirect to the component management page with error
|
||||
return redirect()->route('components.index')->with('error', trans('admin/components/message.not_found'));
|
||||
}
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($component)) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
}
|
||||
$this->authorize('view', $component);
|
||||
|
||||
$rows = array();
|
||||
$all_custom_fields = CustomField::all(); // Cached for table;
|
||||
foreach ($component->assets as $component_assignment) {
|
||||
$rows[] = $component_assignment->present()->forDataTable($all_custom_fields);
|
||||
}
|
||||
|
||||
$componentCount = $component->assets->count();
|
||||
$data = array('total' => $componentCount, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,61 +591,10 @@ class LicensesController extends Controller
|
|||
$file = $log->get_src('licenses');
|
||||
return Response::download($file);
|
||||
}
|
||||
// Prepare the error message
|
||||
$error = trans('admin/licenses/message.does_not_exist', compact('id'));
|
||||
// Redirect to the licence management page
|
||||
return redirect()->route('licenses.index')->with('error', $error);
|
||||
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a JSON response to populate the licence index datatables.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getIndex() method that provides the view
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$this->authorize('view', License::class);
|
||||
$licenses = Company::scopeCompanyables(License::with('company', 'licenseSeatsRelation', 'manufacturer'));
|
||||
|
||||
if (Input::has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$allowed_columns = ['id','name','purchase_cost','expiration_date','purchase_order','order_number','notes','purchase_date','serial','manufacturer','company'];
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
|
||||
switch ($sort) {
|
||||
case 'manufacturer':
|
||||
$licenses = $licenses->OrderManufacturer($order);
|
||||
break;
|
||||
case 'company':
|
||||
$licenses = $licenses->OrderCompany($order);
|
||||
break;
|
||||
default:
|
||||
$licenses = $licenses->orderBy($sort, $order);
|
||||
break;
|
||||
}
|
||||
|
||||
$licenseCount = $licenses->count();
|
||||
$licenses = $licenses->skip($offset)->take($limit)->get();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$rows[] = $license->present()->forDataTable();
|
||||
}
|
||||
|
||||
$data = array('total' => $licenseCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the next free seat ID for checkout.
|
||||
|
|
|
@ -212,116 +212,5 @@ class ManufacturersController extends Controller
|
|||
|
||||
}
|
||||
|
||||
protected function getDataAssetsView(Manufacturer $manufacturer, Request $request)
|
||||
{
|
||||
$manufacturer = $manufacturer->load('assets.model', 'assets.assignedTo', 'assets.assetstatus', 'assets.company');
|
||||
$manufacturer_assets = $manufacturer->assets();
|
||||
|
||||
if ($request->has('search')) {
|
||||
$manufacturer_assets = $manufacturer_assets->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$order = $request->input('order') === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
$allowed_columns = ['id','name','serial','asset_tag'];
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
|
||||
$count = $manufacturer_assets->count();
|
||||
$manufacturer_assets = $manufacturer_assets->skip($offset)->take($limit)->get();
|
||||
$rows = array();
|
||||
$all_custom_fields = CustomField::all(); // cached;
|
||||
foreach ($manufacturer_assets as $asset) {
|
||||
$rows[] = $asset->present()->forDataTable($all_custom_fields);
|
||||
}
|
||||
|
||||
$data = array('total' => $count, 'rows' => $rows);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getDataLicensesView(Manufacturer $manufacturer, Request $request)
|
||||
{
|
||||
$manufacturer = $manufacturer->load('licenses.company', 'licenses.manufacturer', 'licenses.licenseSeatsRelation');
|
||||
$licenses = $manufacturer->licenses;
|
||||
|
||||
if ($request->has('search')) {
|
||||
$licenses = $licenses->TextSearch($request->input('search'));
|
||||
}
|
||||
|
||||
$licenseCount = $licenses->count();
|
||||
|
||||
$rows = array();
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$rows[] = $license->present()->forDataTable();
|
||||
}
|
||||
|
||||
$data = array('total' => $licenseCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataAccessoriesView(Manufacturer $manufacturer, Request $request)
|
||||
{
|
||||
$manufacturer = $manufacturer->load(
|
||||
'accessories.location',
|
||||
'accessories.company',
|
||||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'accessories.users'
|
||||
);
|
||||
$accessories = $manufacturer->accessories();
|
||||
|
||||
if ($request->has('search')) {
|
||||
$accessories = $accessories->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
$accessCount = $accessories->count();
|
||||
$accessories = $accessories->skip($offset)->take($limit)->get();
|
||||
$rows = array();
|
||||
|
||||
foreach ($accessories as $accessory) {
|
||||
$rows[] = $accessory->present()->forDataTable();
|
||||
}
|
||||
|
||||
$data = array('total'=>$accessCount, 'rows'=>$rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getDataConsumablesView($manufacturer, Request $request)
|
||||
{
|
||||
$manufacturer = $manufacturer->load(
|
||||
'consumables.location',
|
||||
'consumables.company',
|
||||
'consumables.category',
|
||||
'consumables.manufacturer',
|
||||
'consumables.users'
|
||||
);
|
||||
$consumables = $manufacturer->consumables();
|
||||
|
||||
if ($request->has('search')) {
|
||||
$consumables = $consumables->TextSearch(e($request->input('search')));
|
||||
}
|
||||
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
|
||||
$consumCount = $consumables->count();
|
||||
$consumables = $consumables->skip($offset)->take($limit)->get();
|
||||
$rows = array();
|
||||
|
||||
foreach ($consumables as $consumable) {
|
||||
$rows[] = $consumable->present()->forDataTable();
|
||||
}
|
||||
|
||||
$data = array('total' => $consumCount, 'rows' => $rows);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,6 @@ class AccessoriesTransformer
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,22 @@ class ComponentsTransformer
|
|||
}
|
||||
|
||||
|
||||
public function transformCheckedoutComponents(Collection $components_users, $total)
|
||||
public function transformCheckedoutComponents(Collection $components_assets, $total)
|
||||
{
|
||||
$array = array();
|
||||
foreach ($components_users as $user) {
|
||||
$array[] = (new UsersTransformer)->transformUser($user);
|
||||
foreach ($components_assets as $asset) {
|
||||
$array[] = [
|
||||
'assigned_pivot_id' => $asset->pivot->id,
|
||||
'id' => (int) $asset->id,
|
||||
'name' => e($asset->model->present()->name) .' '.e($asset->present()->name),
|
||||
'qty' => $asset->pivot->assigned_qty,
|
||||
'type' => 'asset',
|
||||
'created_at' => Helper::getFormattedDateObject($asset->pivot->created_at, 'datetime'),
|
||||
'available_actions' => ['checkin' => true]
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ class UsersTransformer
|
|||
'id' => (int) $user->userloc->id,
|
||||
'name'=> e($user->userloc->name)
|
||||
] : null,
|
||||
'notes'=> e($user->notes),
|
||||
'permissions' => $user->decodePermissions(),
|
||||
'activated' => ($user->activated =='1') ? true : false,
|
||||
'two_factor_activated' => ($user->two_factor_active()) ? true : false,
|
||||
|
|
|
@ -64,7 +64,7 @@ class Component extends SnipeModel
|
|||
|
||||
public function assets()
|
||||
{
|
||||
return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('assigned_qty', 'created_at', 'user_id');
|
||||
return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'user_id');
|
||||
}
|
||||
|
||||
public function admin()
|
||||
|
|
|
@ -122,55 +122,6 @@ class AccessoryPresenter extends Presenter
|
|||
return json_encode($layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON representation of Accessory for datatable.
|
||||
* @return array
|
||||
*/
|
||||
public function forDataTable()
|
||||
{
|
||||
|
||||
$actions = '<nobr>';
|
||||
if (Gate::allows('checkout', $this->model)) {
|
||||
$actions .= Helper::generateDatatableButton(
|
||||
'checkout',
|
||||
route('checkout/accessory', $this->id),
|
||||
$this->numRemaining() > 0
|
||||
);
|
||||
}
|
||||
if (Gate::allows('update', $this->model)) {
|
||||
$actions .= Helper::generateDatatableButton('edit', route('accessories.edit', $this->id));
|
||||
}
|
||||
if (Gate::allows('delete', $this->model)) {
|
||||
$actions .= Helper::generateDatatableButton(
|
||||
'delete',
|
||||
route('accessories.destroy', $this->id),
|
||||
true, /*enabled*/
|
||||
trans('admin/accessories/message.delete.confirm'),
|
||||
$this->name
|
||||
);
|
||||
}
|
||||
$actions .= '</nobr>';
|
||||
|
||||
$results = [];
|
||||
$results['name'] = $this->nameUrl();
|
||||
$results['category'] = '';
|
||||
if ($this->model->category) {
|
||||
$results['category'] = $this->model->category->present()->nameUrl();
|
||||
}
|
||||
$results['model_number'] = $this->model_number;
|
||||
$results['qty'] = $this->qty;
|
||||
$results['order_number'] = $this->order_number;
|
||||
$results['min_amt'] = $this->min_amt;
|
||||
$results['location'] = $this->model->location ? $this->model->location->present()->nameUrl() : '';
|
||||
$results['purchase_date'] = $this->purchase_date;
|
||||
$results['purchase_cost'] = Helper::formatCurrencyOutput($this->purchase_cost);
|
||||
$results['numRemaining'] = $this->numRemaining();
|
||||
$results['companyName'] = $this->model->company ? $this->model->company->present()->nameUrl() : '';
|
||||
$results['manufacturer'] = $this->model->manufacturer ? $this->model->manufacturer->present()->nameUrl() : '';
|
||||
$results['actions'] = $actions;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pregenerated link to this accessories view page.
|
||||
|
|
|
@ -120,5 +120,14 @@ class ComponentPresenter extends Presenter
|
|||
return (string) link_to_route('consumables.show', e($this->name), $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Url to view this item.
|
||||
* @return string
|
||||
*/
|
||||
public function viewUrl()
|
||||
{
|
||||
return route('accessories.show', $this->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -110,6 +110,12 @@ class LicensePresenter extends Presenter
|
|||
"sortable" => true,
|
||||
"visible" => false,
|
||||
"title" => trans('general.order_number'),
|
||||
], [
|
||||
"field" => "notes",
|
||||
"searchable" => true,
|
||||
"sortable" => true,
|
||||
"visible" => false,
|
||||
"title" => trans('general.notes'),
|
||||
]
|
||||
];
|
||||
|
||||
|
|
65
database/factories/AccessoryFactory.php
Normal file
65
database/factories/AccessoryFactory.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Accessory::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Accessory::class, 'apple-bt-keyboard', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Bluetooth Keyboard',
|
||||
'category_id' => 8,
|
||||
'manufacturer_id' => 1,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Accessory::class, 'apple-usb-keyboard', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'USB Keyboard',
|
||||
'category_id' => 8,
|
||||
'manufacturer_id' => 1,
|
||||
'qty' => 15,
|
||||
'min_amt' => 2
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Accessory::class, 'apple-mouse', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Magic Mouse',
|
||||
'category_id' => 9,
|
||||
'manufacturer_id' => 1,
|
||||
'qty' => 13,
|
||||
'min_amt' => 2
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Accessory::class, 'microsoft-mouse', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Sculpt Comfort Mouse\'',
|
||||
'category_id' => 9,
|
||||
'manufacturer_id' => 2,
|
||||
'qty' => 13,
|
||||
'min_amt' => 2
|
||||
];
|
||||
|
||||
});
|
||||
|
|
@ -1,76 +1,101 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use App\Models\Location;
|
||||
use App\Models\Asset;
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'asset-upload', function ($faker) {
|
||||
$asset = factory(App\Models\Asset::class)->create();
|
||||
|
||||
$factory->define(Actionlog::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'item_type' => get_class($asset),
|
||||
'item_id' => $asset->id,
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'filename' => $faker->word,
|
||||
'action_type' => 'uploaded'
|
||||
'note' => 'Sample checkout from DB seeder!',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
do {
|
||||
$item = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
||||
} while (!$item->isValid());
|
||||
// dd($item);
|
||||
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'asset-checkout-user', function (Faker\Generator $faker) {
|
||||
$target = User::inRandomOrder()->first();
|
||||
$item = 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(
|
||||
[
|
||||
'assigned_to' => $target->id,
|
||||
'assigned_type' => App\Models\User::class
|
||||
]
|
||||
);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'created_at' => $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,
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\License::class)->create(['company_id' => $company->id]);
|
||||
$factory->defineAs(Actionlog::class, 'asset-checkout-location', function (Faker\Generator $faker) {
|
||||
$target = Location::inRandomOrder()->first();
|
||||
$item = 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(
|
||||
[
|
||||
'assigned_to' => $target->id,
|
||||
'assigned_type' => App\Models\Location::class
|
||||
]
|
||||
);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'created_at' => $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,
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
];
|
||||
});
|
||||
|
||||
// This doesn't work - we need to assign a seat
|
||||
$factory->defineAs(Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
||||
$target = Asset::inRandomOrder()->RTD()->first();
|
||||
$item = License::inRandomOrder()->first();
|
||||
$user_id = rand(1,2); // keep it simple - make it one of the two superadmins
|
||||
|
||||
return [
|
||||
'user_id' => $user_id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
'note' => $faker->sentence
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\Accessory::class)->create(['company_id' => $company->id]);
|
||||
$target = Asset::inRandomOrder()->RTD()->first();
|
||||
$item = Accessory::inRandomOrder()->first();
|
||||
$user_id = rand(1,2); // keep it simple - make it one of the two superadmins
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user_id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
'note' => $faker->sentence
|
||||
];
|
||||
});
|
||||
|
||||
|
|
|
@ -15,89 +15,186 @@ use App\Models\Category;
|
|||
|
||||
$factory->define(Asset::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'model_id' => function () {
|
||||
return factory(App\Models\AssetModel::class)->create()->id;
|
||||
},
|
||||
'rtd_location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'name' => null,
|
||||
'rtd_location_id' => 1,
|
||||
'serial' => $faker->uuid,
|
||||
'status_id' => function () {
|
||||
return factory(App\Models\Statuslabel::class)->states('rtd')->create()->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'status_id' => 1,
|
||||
'user_id' => 1,
|
||||
'asset_tag' => $faker->unixTime('now'),
|
||||
'notes' => $faker->sentence,
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'notes' => 'Created by DB seeder',
|
||||
'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
|
||||
'purchase_cost' => $faker->randomFloat(2, '299.99', '2999.99'),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'supplier_id' => function () {
|
||||
return factory(App\Models\Supplier::class)->create()->id;
|
||||
},
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'supplier_id' => 1,
|
||||
'requestable' => $faker->boolean()
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'deleted', function ($faker) {
|
||||
|
||||
|
||||
|
||||
$factory->state(Asset::class, 'laptop-mbp', function ($faker) {
|
||||
return [
|
||||
'deleted_at' => $faker->dateTime(),
|
||||
'model_id' => 1
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-mbp-pending', function ($faker) {
|
||||
return [
|
||||
'model_id' => 1,
|
||||
'status_id' => 2,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-mbp-archived', function ($faker) {
|
||||
return [
|
||||
'model_id' => 1,
|
||||
'status_id' => 3,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-air', function ($faker) {
|
||||
return [
|
||||
'model_id' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-surface', function ($faker) {
|
||||
return [
|
||||
'model_id' => 3
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-xps', function ($faker) {
|
||||
return [
|
||||
'model_id' => 4
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-spectre', function ($faker) {
|
||||
return [
|
||||
'model_id' => 5
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-zenbook', function ($faker) {
|
||||
return [
|
||||
'model_id' => 6
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'laptop-yoga', function ($faker) {
|
||||
return [
|
||||
'model_id' => 7
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'desktop-macpro', function ($faker) {
|
||||
return [
|
||||
'model_id' => 8
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'desktop-lenovo-i5', function ($faker) {
|
||||
return [
|
||||
'model_id' => 9
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'desktop-optiplex', function ($faker) {
|
||||
return [
|
||||
'model_id' => 10
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'conf-polycom', function ($faker) {
|
||||
return [
|
||||
'model_id' => 11
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'conf-polycomcx', function ($faker) {
|
||||
return [
|
||||
'model_id' => 12
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'tablet-ipad', function ($faker) {
|
||||
return [
|
||||
'model_id' => 13
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'tablet-tab3', function ($faker) {
|
||||
return [
|
||||
'model_id' => 14
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'phone-iphone6s', function ($faker) {
|
||||
return [
|
||||
'model_id' => 15
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'phone-iphone7', function ($faker) {
|
||||
return [
|
||||
'model_id' => 16
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'ultrafine', function ($faker) {
|
||||
return [
|
||||
'model_id' => 17
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'ultrasharp', function ($faker) {
|
||||
return [
|
||||
'model_id' => 18
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// These are just for unit tests, not to generate data
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-user', function ($faker) {
|
||||
return [
|
||||
'model_id' => 1,
|
||||
'assigned_to' => factory(App\Models\User::class)->create()->id,
|
||||
'assigned_type' => App\Models\User::class,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-location', function ($faker) {
|
||||
return [
|
||||
'model_id' => 1,
|
||||
'assigned_to' => factory(App\Models\Location::class)->create()->id,
|
||||
'assigned_type' => App\Models\Location::class,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-asset', function ($faker) {
|
||||
return [
|
||||
'model_id' => 1,
|
||||
'assigned_to' => factory(App\Models\Asset::class)->create()->id,
|
||||
'assigned_type' => App\Models\Asset::class,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'requires-acceptance', function ($faker) {
|
||||
$cat = factory(Category::class)->states('asset-category', 'requires-acceptance')->create();
|
||||
$model = factory(AssetModel::class)->create(['category_id' => $cat->id]);
|
||||
return [
|
||||
'model_id' => $model->id
|
||||
'model_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\AssetModel::class, function (Faker\Generator $faker) {
|
||||
|
||||
$factory->state(Asset::class, 'deleted', function ($faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->states('asset-category')->create()->id;
|
||||
},
|
||||
'model_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'eol' => 1,
|
||||
'notes' => $faker->paragraph(),
|
||||
'requestable' => $faker->boolean(),
|
||||
'depreciation_id' => function () {
|
||||
return factory(App\Models\Depreciation::class)->create()->id;
|
||||
},
|
||||
'model_id' => 1,
|
||||
'deleted_at' => $faker->dateTime()
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->define(App\Models\AssetMaintenance::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'asset_id' => function () {
|
||||
|
|
255
database/factories/AssetModelFactory.php
Normal file
255
database/factories/AssetModelFactory.php
Normal file
|
@ -0,0 +1,255 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Laptops
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
$factory->define(App\Models\AssetModel::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'model_number' => $faker->creditCardNumber(),
|
||||
'notes' => 'Created by demo seeder',
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// 1
|
||||
$factory->state(App\Models\AssetModel::class, 'mbp-13-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Macbook Pro 13"',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 2
|
||||
$factory->state(App\Models\AssetModel::class, 'mbp-air-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Macbook Air',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 3
|
||||
$factory->state(App\Models\AssetModel::class, 'surface-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Surface',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 2,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 4
|
||||
$factory->state(App\Models\AssetModel::class, 'xps13-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'XPS 13',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 3,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 5
|
||||
$factory->state(App\Models\AssetModel::class, 'zenbook-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'ZenBook UX310',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 4,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 6
|
||||
$factory->state(App\Models\AssetModel::class, 'spectre-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Spectre',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 5,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
// 7
|
||||
$factory->state(App\Models\AssetModel::class, 'yoga-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Yoga 910',
|
||||
'category_id' => 1,
|
||||
'manufacturer_id' => 6,
|
||||
'eol' => '36',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Desktops
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'macpro-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'iMac Pro',
|
||||
'category_id' => 2,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '24',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'lenovo-i5-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Lenovo Intel Core i5',
|
||||
'category_id' => 2,
|
||||
'manufacturer_id' => 6,
|
||||
'eol' => '24',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'optiplex-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'OptiPlex',
|
||||
'category_id' => 2,
|
||||
'manufacturer_id' => 3,
|
||||
'model_number' => '5040 (MRR81)',
|
||||
'eol' => '24',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Conference Phones
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'polycom-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'SoundStation 2',
|
||||
'category_id' => 6,
|
||||
'manufacturer_id' => 8,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'polycomcx-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Polycom CX3000 IP Conference Phone',
|
||||
'category_id' => 6,
|
||||
'manufacturer_id' => 8,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Tablets
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'ipad-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'iPad Pro',
|
||||
'category_id' => 3,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'tab3-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'Tab3',
|
||||
'category_id' => 3,
|
||||
'manufacturer_id' => 6,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mobile Phones
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'iphone6s-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'iPhone 6s',
|
||||
'category_id' => 4,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 3,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'iphone7-model', function ($faker) {
|
||||
return [
|
||||
'name' => 'iPhone 7',
|
||||
'category_id' => 4,
|
||||
'manufacturer_id' => 1,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Displays
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'ultrafine', function ($faker) {
|
||||
return [
|
||||
'name' => 'Ultrafine 4k',
|
||||
'category_id' => 5,
|
||||
'manufacturer_id' => 7,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 2,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\AssetModel::class, 'ultrasharp', function ($faker) {
|
||||
return [
|
||||
'name' => 'Ultrasharp U2415',
|
||||
'category_id' => 5,
|
||||
'manufacturer_id' => 3,
|
||||
'eol' => '12',
|
||||
'depreciation_id' => 2,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -12,41 +12,105 @@
|
|||
|
||||
$factory->define(App\Models\Category::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'category_type' => $faker->randomElement(['asset', 'accessory', 'component', 'consumable']),
|
||||
'eula_text' => $faker->paragraph(),
|
||||
'require_acceptance' => false,
|
||||
'use_default_eula' => $faker->boolean(),
|
||||
'checkin_email' => $faker->boolean()
|
||||
'user_id' => 1,
|
||||
'eula_text' => $faker->paragraph(),
|
||||
'require_acceptance' => false,
|
||||
'use_default_eula' => $faker->boolean(),
|
||||
'checkin_email' => $faker->boolean()
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-laptop-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Laptops',
|
||||
'category_type' => 'asset',
|
||||
'require_acceptance' => true,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-category', function ($faker) {
|
||||
$factory->state(App\Models\Category::class, 'asset-desktop-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Desktops',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'accessory-category', function ($faker) {
|
||||
$factory->state(App\Models\Category::class, 'asset-display-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Displays',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-tablet-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Tablets',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-mobile-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Mobile Phones',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-conference-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Conference Phones',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-voip-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'VOIP Phones',
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->state(App\Models\Category::class, 'accessory-keyboard-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Keyboards',
|
||||
'category_type' => 'accessory',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'component-category', function ($faker) {
|
||||
$factory->state(App\Models\Category::class, 'accessory-mouse-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Mouse',
|
||||
'category_type' => 'accessory',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->state(App\Models\Category::class, 'component-hdd-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'HDD/SSD',
|
||||
'category_type' => 'component',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'consumable-category', function ($faker) {
|
||||
$factory->state(App\Models\Category::class, 'component-ram-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'RAM',
|
||||
'category_type' => 'component',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'consumable-paper-category', function ($faker) {
|
||||
return [
|
||||
'name' => 'Printer Paper',
|
||||
'category_type' => 'consumable',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'requires-acceptance', function ($faker) {
|
||||
$factory->state(App\Models\Category::class, 'consumable-ink-category', function ($faker) {
|
||||
return [
|
||||
'require_acceptance' => true,
|
||||
'name' => 'Printer Ink',
|
||||
'category_type' => 'consumable',
|
||||
];
|
||||
});
|
||||
|
||||
|
|
64
database/factories/ComponentsFactory.php
Normal file
64
database/factories/ComponentsFactory.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Components Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating components ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Component::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
|
||||
'purchase_cost' => $faker->randomFloat(2, 1, 50),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ram-crucial4', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
|
||||
'category_id' => 13,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ram-crucial8', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial 8GB DDR3L-1600 SODIMM Memory for Mac',
|
||||
'category_id' => 13,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ssd-crucial120', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial BX300 120GB SATA Internal SSD',
|
||||
'category_id' => 12,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Component::class, 'ssd-crucial240', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Crucial BX300 240GB SATA Internal SSD',
|
||||
'category_id' => 12,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
58
database/factories/ConsumableFactory.php
Normal file
58
database/factories/ConsumableFactory.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Consumables Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating consumables ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Consumable::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'item_no' => $faker->numberBetween(1000000, 50000000),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
|
||||
'purchase_cost' => $faker->randomFloat(2, 1, 50),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Consumable::class, 'cardstock', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Cardstock (White)',
|
||||
'category_id' => 10,
|
||||
'manufacturer_id' => 10,
|
||||
'qty' => 10,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Consumable::class, 'paper', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Laserjet Paper (Ream)',
|
||||
'category_id' => 10,
|
||||
'manufacturer_id' => 10,
|
||||
'qty' => 20,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Consumable::class, 'ink', function ($faker) {
|
||||
|
||||
return [
|
||||
'name' => 'Laserjet Toner (black)',
|
||||
'category_id' => 11,
|
||||
'manufacturer_id' => 5,
|
||||
'qty' => 20,
|
||||
'min_amt' => 2
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
62
database/factories/DepartmentsFactory.php
Normal file
62
database/factories/DepartmentsFactory.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Department::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'location_id' => rand(1,5),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'hr', function ($faker) {
|
||||
return [
|
||||
'name' => 'Human Resources',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'engineering', function ($faker) {
|
||||
return [
|
||||
'name' => 'Engineering',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'marketing', function ($faker) {
|
||||
return [
|
||||
'name' => 'Marketing',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'client', function ($faker) {
|
||||
return [
|
||||
'name' => 'Client Services',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'design', function ($faker) {
|
||||
return [
|
||||
'name' => 'Graphic Design',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'product', function ($faker) {
|
||||
return [
|
||||
'name' => 'Product Management',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Department::class, 'silly', function ($faker) {
|
||||
return [
|
||||
'name' => 'Dept of Silly Walks',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
41
database/factories/DepreciationFactory.php
Normal file
41
database/factories/DepreciationFactory.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Depreciation::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Depreciation::class, 'computer', function ($faker) {
|
||||
return [
|
||||
'name' => 'Computer Depreciation',
|
||||
'months' => 36,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Depreciation::class, 'display', function ($faker) {
|
||||
return [
|
||||
'name' => 'Display Depreciation',
|
||||
'months' => 12,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Depreciation::class, 'mobile-phones', function ($faker) {
|
||||
return [
|
||||
'name' => 'Mobile Phone Depreciation',
|
||||
'months' => 24,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
101
database/factories/LicenseFactory.php
Normal file
101
database/factories/LicenseFactory.php
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\License::class, function (Faker\Generator $faker) {
|
||||
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'license_name' => $faker->name,
|
||||
'license_email' => $faker->safeEmail,
|
||||
'serial' => $faker->uuid,
|
||||
'notes' => 'Created by DB seeder',
|
||||
'purchase_date' => $faker->dateTimeBetween('-1 years','now', date_default_timezone_get()),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
];
|
||||
});
|
||||
|
||||
// 1
|
||||
$factory->state(App\Models\License::class, 'photoshop', function ($faker) {
|
||||
$data = [
|
||||
'name' => 'Photoshop',
|
||||
'manufacturer_id' => 9,
|
||||
'purchase_cost' => '299.99',
|
||||
'seats' => 10,
|
||||
];
|
||||
|
||||
|
||||
for ($x = 0; $x < $data['seats']; $x++) {
|
||||
$seat = new App\Models\LicenseSeat;
|
||||
$seat->license_id = 1;
|
||||
$seat->create();
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
});
|
||||
|
||||
// 2
|
||||
$factory->state(App\Models\License::class, 'acrobat', function ($faker) {
|
||||
|
||||
$data = [
|
||||
'name' => 'Acrobat',
|
||||
'manufacturer_id' => 9,
|
||||
'purchase_cost' => '29.99',
|
||||
'seats' => 10,
|
||||
];
|
||||
|
||||
for ($x = 0; $x < $data['seats']; $x++) {
|
||||
$seat = new App\Models\LicenseSeat;
|
||||
$seat->license_id = 2;
|
||||
$seat->create();
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
// 3
|
||||
$factory->state(App\Models\License::class, 'indesign', function ($faker) {
|
||||
$data = [
|
||||
'name' => 'InDesign',
|
||||
'manufacturer_id' => 9,
|
||||
'purchase_cost' => '199.99',
|
||||
'seats' => 10,
|
||||
];
|
||||
|
||||
for ($x = 0; $x < $data['seats']; $x++) {
|
||||
$seat = new App\Models\LicenseSeat;
|
||||
$seat->license_id = 3;
|
||||
$seat->create();
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
|
||||
// 4
|
||||
$factory->state(App\Models\License::class, 'office', function ($faker) {
|
||||
$data = [
|
||||
'name' => 'Office',
|
||||
'manufacturer_id' => 2,
|
||||
'purchase_cost' => '49.99',
|
||||
'seats' => 20,
|
||||
];
|
||||
|
||||
for ($x = 0; $x < $data['seats']; $x++) {
|
||||
$seat = new App\Models\LicenseSeat;
|
||||
$seat->license_id = 4;
|
||||
$seat->create();
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
|
123
database/factories/ManufacturerFactory.php
Normal file
123
database/factories/ManufacturerFactory.php
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Asset Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating models ..
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Models\Manufacturer::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'support_phone' => $faker->phoneNumber(),
|
||||
'url' => $faker->url(),
|
||||
'support_email' => $faker->safeEmail(),
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// 1
|
||||
$factory->state(App\Models\Manufacturer::class, 'apple', function ($faker) {
|
||||
return [
|
||||
'name' => 'Apple',
|
||||
'url' => 'https://apple.com',
|
||||
'support_url' => 'https://support.apple.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 2
|
||||
$factory->state(App\Models\Manufacturer::class, 'microsoft', function ($faker) {
|
||||
return [
|
||||
'name' => 'Microsoft',
|
||||
'url' => 'https://microsoft.com',
|
||||
'support_url' => 'https://support.microsoft.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 3
|
||||
$factory->state(App\Models\Manufacturer::class, 'dell', function ($faker) {
|
||||
return [
|
||||
'name' => 'Dell',
|
||||
'url' => 'https://dell.com',
|
||||
'support_url' => 'https://support.dell.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 4
|
||||
$factory->state(App\Models\Manufacturer::class, 'asus', function ($faker) {
|
||||
return [
|
||||
'name' => 'Asus',
|
||||
'url' => 'https://asus.com',
|
||||
'support_url' => 'https://support.asus.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 5
|
||||
$factory->state(App\Models\Manufacturer::class, 'hp', function ($faker) {
|
||||
return [
|
||||
'name' => 'HP',
|
||||
'url' => 'https://hp.com',
|
||||
'support_url' => 'https://support.hp.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 6
|
||||
$factory->state(App\Models\Manufacturer::class, 'lenovo', function ($faker) {
|
||||
return [
|
||||
'name' => 'Lenovo',
|
||||
'url' => 'https://lenovo.com',
|
||||
'support_url' => 'https://support.lenovo.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 7
|
||||
$factory->state(App\Models\Manufacturer::class, 'lg', function ($faker) {
|
||||
return [
|
||||
'name' => 'LG',
|
||||
'url' => 'https://lg.com',
|
||||
'support_url' => 'https://support.lg.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 8
|
||||
$factory->state(App\Models\Manufacturer::class, 'polycom', function ($faker) {
|
||||
return [
|
||||
'name' => 'Polycom',
|
||||
'url' => 'https://polycom.com',
|
||||
'support_url' => 'https://support.polycom.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 9
|
||||
$factory->state(App\Models\Manufacturer::class, 'adobe', function ($faker) {
|
||||
return [
|
||||
'name' => 'Adobe',
|
||||
'url' => 'https://adobe.com',
|
||||
'support_url' => 'https://support.adobe.com'
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// 10
|
||||
$factory->state(App\Models\Manufacturer::class, 'avery', function ($faker) {
|
||||
return [
|
||||
'name' => 'Avery',
|
||||
'url' => 'https://avery.com',
|
||||
'support_url' => 'https://support.avery.com'
|
||||
];
|
||||
});
|
||||
|
||||
// 11
|
||||
$factory->state(App\Models\Manufacturer::class, 'crucial', function ($faker) {
|
||||
return [
|
||||
'name' => 'Crucial',
|
||||
'url' => 'https://crucial.com',
|
||||
'support_url' => 'https://support.crucial.com'
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -19,28 +19,6 @@ use App\Models\Manufacturer;
|
|||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
|
||||
$factory->define(App\Models\Accessory::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'name' => $faker->text(20),
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->states('accessory-category')->create()->id;
|
||||
},
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Company::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
|
@ -54,9 +32,7 @@ $factory->define(App\Models\Component::class, function (Faker\Generator $faker)
|
|||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'location_id' => 1,
|
||||
'serial' => $faker->uuid,
|
||||
'qty' => $faker->numberBetween(3, 10),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
|
@ -69,94 +45,10 @@ $factory->define(App\Models\Component::class, function (Faker\Generator $faker)
|
|||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Consumable::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'model_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'item_no' => $faker->numberBetween(1000000, 50000000),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Department::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'user_id' => '1',
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'manager_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Depreciation::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'months' => $faker->numberBetween(1, 10),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\License::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'serial' => $faker->uuid,
|
||||
'seats' => $faker->numberBetween(1, 10),
|
||||
'license_email' => $faker->safeEmail,
|
||||
'license_name' => $faker->name,
|
||||
'order_number' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_order' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'notes' => $faker->sentence,
|
||||
'supplier_id' => function () {
|
||||
return factory(App\Models\Supplier::class)->create()->id;
|
||||
},
|
||||
'company_id' =>function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\LicenseSeat::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'license_id' => function () {
|
||||
return factory(App\Models\License::class)->create()->id;
|
||||
},
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'notes' => $faker->sentence,
|
||||
'user_id' => '1',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Location::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'name' => $faker->city,
|
||||
'address' => $faker->streetAddress,
|
||||
'address2' => $faker->secondaryAddress,
|
||||
'city' => $faker->city,
|
||||
|
@ -167,11 +59,6 @@ $factory->define(App\Models\Location::class, function (Faker\Generator $faker) {
|
|||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Manufacturer::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->company,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Supplier::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
use App\Models\Company;
|
||||
|
||||
|
||||
|
||||
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'username' => $faker->username,
|
||||
'password' => $faker->password,
|
||||
'password' => bcrypt('password'),
|
||||
'permissions' => '{"user":"0"}',
|
||||
'email' => $faker->safeEmail,
|
||||
'company_id' => function () {
|
||||
|
@ -15,14 +17,36 @@ $factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
|||
},
|
||||
'locale' => $faker->locale,
|
||||
'employee_num' => $faker->numberBetween(3500, 35050),
|
||||
'jobtitle' => $faker->word,
|
||||
'jobtitle' => $faker->jobTitle,
|
||||
'department_id' => rand(1,6),
|
||||
'phone' => $faker->phoneNumber,
|
||||
'notes' => $faker->sentence,
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'notes' => 'Created by DB seeder',
|
||||
'location_id' => rand(1,5),
|
||||
'activated' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->state(App\Models\User::class, 'first-admin', function ($faker) {
|
||||
return [
|
||||
'first_name' => 'Admin',
|
||||
'last_name' => 'User',
|
||||
'username' => 'admin',
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\User::class, 'snipe-admin', function ($faker) {
|
||||
return [
|
||||
'first_name' => 'Snipe E.',
|
||||
'last_name' => 'Head',
|
||||
'username' => 'snipe',
|
||||
'email' => 'snipe@snipe.net',
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
// USER GLOBAL PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'superuser', function ($faker) {
|
||||
return [
|
||||
|
@ -33,6 +57,7 @@ $factory->state(App\Models\User::class, 'superuser', function ($faker) {
|
|||
$factory->state(App\Models\User::class, 'admin', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"admin":"1"}',
|
||||
'manager_id' => rand(1,2),
|
||||
];
|
||||
});
|
||||
// USER ASSET PERMISSION STATES
|
||||
|
|
|
@ -2,11 +2,16 @@
|
|||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Accessory;
|
||||
|
||||
|
||||
class AccessorySeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Accessory::truncate();
|
||||
factory(Accessory::class,15)->create();
|
||||
Accessory::truncate();
|
||||
DB::table('accessories_users')->truncate();
|
||||
factory(Accessory::class, 1)->states('apple-usb-keyboard')->create();
|
||||
factory(Accessory::class, 1)->states('apple-bt-keyboard')->create();
|
||||
factory(Accessory::class, 1)->states('apple-mouse')->create();
|
||||
factory(Accessory::class, 1)->states('microsoft-mouse')->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@ class ActionlogSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Actionlog::truncate();
|
||||
factory(Actionlog::class, 'asset-checkout',25)->create();
|
||||
// factory(Actionlog::class, 'accessory-checkout',15)->create();
|
||||
// factory(Actionlog::class, 'consumable-checkout', 15)->create();
|
||||
// factory(Actionlog::class, 'component-checkout', 15)->create();
|
||||
// factory(Actionlog::class, 'license-checkout-asset', 15)->create();
|
||||
factory(Actionlog::class, 'asset-checkout-user',5)->create();
|
||||
factory(Actionlog::class, 'asset-checkout-location',5)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,38 @@ class AssetModelSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
AssetModel::truncate();
|
||||
factory(AssetModel::class,5)->create();
|
||||
|
||||
// Laptops
|
||||
factory(AssetModel::class, 1)->states('mbp-13-model')->create(); // 1
|
||||
factory(AssetModel::class, 1)->states('mbp-air-model')->create(); // 2
|
||||
factory(AssetModel::class, 1)->states('surface-model')->create(); // 3
|
||||
factory(AssetModel::class, 1)->states('xps13-model')->create(); // 4
|
||||
factory(AssetModel::class, 1)->states('spectre-model')->create(); // 5
|
||||
factory(AssetModel::class, 1)->states('zenbook-model')->create(); // 6
|
||||
factory(AssetModel::class, 1)->states('yoga-model')->create(); // 7
|
||||
|
||||
// Desktops
|
||||
factory(AssetModel::class, 1)->states('macpro-model')->create(); // 8
|
||||
factory(AssetModel::class, 1)->states('lenovo-i5-model')->create(); // 9
|
||||
factory(AssetModel::class, 1)->states('optiplex-model')->create(); // 10
|
||||
|
||||
// Conference Phones
|
||||
factory(AssetModel::class, 1)->states('polycom-model')->create(); // 11
|
||||
factory(AssetModel::class, 1)->states('polycomcx-model')->create(); // 12
|
||||
|
||||
// Tablets
|
||||
factory(AssetModel::class, 1)->states('ipad-model')->create(); // 13
|
||||
factory(AssetModel::class, 1)->states('tab3-model')->create(); // 14
|
||||
|
||||
// Phones
|
||||
factory(AssetModel::class, 1)->states('iphone6s-model')->create(); // 15
|
||||
factory(AssetModel::class, 1)->states('iphone7-model')->create(); // 16
|
||||
|
||||
// Displays
|
||||
factory(AssetModel::class, 1)->states('ultrafine')->create(); // 17
|
||||
factory(AssetModel::class, 1)->states('ultrasharp')->create(); // 18
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,32 @@ class AssetSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Asset::truncate();
|
||||
factory(Asset::class, 100)->create();
|
||||
factory(Asset::class, 10)->states('laptop-mbp')->create();
|
||||
factory(Asset::class, 5)->states('laptop-mbp-pending')->create();
|
||||
factory(Asset::class, 5)->states('laptop-mbp-archived')->create();
|
||||
factory(Asset::class, 10)->states('laptop-air')->create();
|
||||
factory(Asset::class, 5)->states('laptop-surface')->create();
|
||||
factory(Asset::class, 5)->states('laptop-xps')->create();
|
||||
factory(Asset::class, 5)->states('laptop-spectre')->create();
|
||||
factory(Asset::class, 5)->states('laptop-zenbook')->create();
|
||||
factory(Asset::class, 3)->states('laptop-yoga')->create();
|
||||
|
||||
factory(Asset::class, 3)->states('desktop-macpro')->create();
|
||||
factory(Asset::class, 3)->states('desktop-lenovo-i5')->create();
|
||||
factory(Asset::class, 10)->states('desktop-optiplex')->create();
|
||||
|
||||
factory(Asset::class, 5)->states('conf-polycom')->create();
|
||||
factory(Asset::class, 2)->states('conf-polycomcx')->create();
|
||||
|
||||
factory(Asset::class, 12)->states('tablet-ipad')->create();
|
||||
factory(Asset::class, 4)->states('tablet-tab3')->create();
|
||||
|
||||
factory(Asset::class, 27)->states('phone-iphone6s')->create();
|
||||
factory(Asset::class, 40)->states('phone-iphone7')->create();
|
||||
|
||||
factory(Asset::class, 10)->states('ultrafine')->create();
|
||||
factory(Asset::class, 10)->states('ultrasharp')->create();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,20 @@ class CategorySeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Category::truncate();
|
||||
factory(Category::class, 10)->states('asset-category')->create();
|
||||
factory(Category::class, 10)->states('accessory-category')->create();
|
||||
factory(Category::class, 10)->states('component-category')->create();
|
||||
factory(Category::class, 10)->states('consumable-category')->create();
|
||||
|
||||
factory(Category::class, 1)->states('asset-laptop-category')->create(); // 1
|
||||
factory(Category::class, 1)->states('asset-desktop-category')->create(); // 2
|
||||
factory(Category::class, 1)->states('asset-tablet-category')->create(); // 3
|
||||
factory(Category::class, 1)->states('asset-mobile-category')->create(); // 4
|
||||
factory(Category::class, 1)->states('asset-display-category')->create(); // 5
|
||||
factory(Category::class, 1)->states('asset-voip-category')->create(); // 6
|
||||
factory(Category::class, 1)->states('asset-conference-category')->create(); // 7
|
||||
factory(Category::class, 1)->states('accessory-keyboard-category')->create(); // 8
|
||||
factory(Category::class, 1)->states('accessory-mouse-category')->create(); // 9
|
||||
factory(Category::class, 1)->states('consumable-paper-category')->create(); // 10
|
||||
factory(Category::class, 1)->states('consumable-ink-category')->create(); // 11
|
||||
factory(Category::class, 1)->states('component-hdd-category')->create(); // 12
|
||||
factory(Category::class, 1)->states('component-ram-category')->create(); // 13
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ class ComponentSeeder extends Seeder
|
|||
{
|
||||
Component::truncate();
|
||||
DB::table('components_assets')->truncate();
|
||||
factory(Component::class, 10)->create();
|
||||
factory(Component::class, 1)->states('ram-crucial4')->create(); // 1
|
||||
factory(Component::class, 1)->states('ram-crucial8')->create(); // 1
|
||||
factory(Component::class, 1)->states('ssd-crucial120')->create(); // 1
|
||||
factory(Component::class, 1)->states('ssd-crucial240')->create(); // 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ class ConsumableSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Consumable::truncate();
|
||||
factory(Consumable::class, 25)->create();
|
||||
DB::table('consumables_users')->truncate();
|
||||
factory(Consumable::class, 1)->states('cardstock')->create(); // 1
|
||||
factory(Consumable::class, 1)->states('paper')->create(); // 2
|
||||
factory(Consumable::class, 1)->states('ink')->create(); // 3
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ class DatabaseSeeder extends Seeder
|
|||
$this->call(CategorySeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(DepreciationSeeder::class);
|
||||
$this->call(DepartmentSeeder::class);
|
||||
$this->call(ManufacturerSeeder::class);
|
||||
$this->call(LocationSeeder::class);
|
||||
$this->call(SupplierSeeder::class);
|
||||
|
@ -29,7 +30,6 @@ class DatabaseSeeder extends Seeder
|
|||
$this->call(LicenseSeeder::class);
|
||||
$this->call(ComponentSeeder::class);
|
||||
$this->call(ConsumableSeeder::class);
|
||||
$this->call(LicenseSeeder::class);
|
||||
$this->call(ActionlogSeeder::class);
|
||||
$this->call(CustomFieldSeeder::class);
|
||||
|
||||
|
|
17
database/seeds/DepartmentSeeder.php
Normal file
17
database/seeds/DepartmentSeeder.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Department;
|
||||
|
||||
class DepartmentSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Department::truncate();
|
||||
factory(Department::class, 1)->states('hr')->create(); // 1
|
||||
factory(Department::class, 1)->states('engineering')->create(); // 2
|
||||
factory(Department::class, 1)->states('marketing')->create(); // 3
|
||||
factory(Department::class, 1)->states('client')->create(); // 4
|
||||
factory(Department::class, 1)->states('product')->create(); // 5
|
||||
factory(Department::class, 1)->states('silly')->create(); // 6
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ class DepreciationSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Depreciation::truncate();
|
||||
factory(Depreciation::class, 5)->create();
|
||||
factory(Depreciation::class, 1)->states('computer')->create(); // 1
|
||||
factory(Depreciation::class, 1)->states('display')->create(); // 2
|
||||
factory(Depreciation::class, 1)->states('mobile-phones')->create(); // 3
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@ class LicenseSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
License::truncate();
|
||||
factory(License::class, 10)->create();
|
||||
|
||||
LicenseSeat::truncate();
|
||||
factory(LicenseSeat::class, 10)->create();
|
||||
factory(License::class, 1)->states('photoshop')->create();
|
||||
factory(License::class, 1)->states('acrobat')->create();
|
||||
factory(License::class, 1)->states('indesign')->create();
|
||||
factory(License::class, 1)->states('office')->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,16 @@ class ManufacturerSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Manufacturer::truncate();
|
||||
factory(Manufacturer::class, 10)->create();
|
||||
factory(Manufacturer::class, 1)->states('apple')->create(); // 1
|
||||
factory(Manufacturer::class, 1)->states('microsoft')->create(); // 2
|
||||
factory(Manufacturer::class, 1)->states('dell')->create(); // 3
|
||||
factory(Manufacturer::class, 1)->states('asus')->create(); // 4
|
||||
factory(Manufacturer::class, 1)->states('hp')->create(); // 5
|
||||
factory(Manufacturer::class, 1)->states('lenovo')->create(); // 6
|
||||
factory(Manufacturer::class, 1)->states('lg')->create(); // 7
|
||||
factory(Manufacturer::class, 1)->states('polycom')->create(); // 8
|
||||
factory(Manufacturer::class, 1)->states('adobe')->create(); // 9
|
||||
factory(Manufacturer::class, 1)->states('avery')->create(); // 10
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,45 @@ class UserSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// Don't truncate the user column, that might suck.
|
||||
factory(User::class, 10)->create();
|
||||
User::truncate();
|
||||
factory(User::class, 1)->states('first-admin')->create();
|
||||
factory(User::class, 1)->states('snipe-admin')->create();
|
||||
factory(User::class, 3)->states('superuser')->create();
|
||||
factory(User::class, 3)->states('admin')->create();
|
||||
factory(User::class, 1)->states('view-assets')->create();
|
||||
// factory(User::class, 1)->states('create-assets')->create();
|
||||
// factory(User::class, 1)->states('edit-assets')->create();
|
||||
// factory(User::class, 1)->states('delete-assets')->create();
|
||||
// factory(User::class, 1)->states('checkin-assets')->create();
|
||||
// factory(User::class, 1)->states('checkout-assets')->create();
|
||||
// factory(User::class, 1)->states('view-requestable-assets')->create();
|
||||
// factory(User::class, 1)->states('view-accessories')->create();
|
||||
// factory(User::class, 1)->states('create-accessories')->create();
|
||||
// factory(User::class, 1)->states('view-accessories')->create();
|
||||
// factory(User::class, 1)->states('delete-accessories')->create();
|
||||
// factory(User::class, 1)->states('edit-accessories')->create();
|
||||
// factory(User::class, 1)->states('checkout-accessories')->create();
|
||||
// factory(User::class, 1)->states('checkin-accessories')->create();
|
||||
// factory(User::class, 1)->states('view-consumables')->create();
|
||||
// factory(User::class, 1)->states('create-consumables')->create();
|
||||
// factory(User::class, 1)->states('edit-consumables')->create();
|
||||
// factory(User::class, 1)->states('delete-consumables')->create();
|
||||
// factory(User::class, 1)->states('checkout-consumables')->create();
|
||||
// factory(User::class, 1)->states('view-licenses')->create();
|
||||
// factory(User::class, 1)->states('edit-licenses')->create();
|
||||
// factory(User::class, 1)->states('delete-licenses')->create();
|
||||
// factory(User::class, 1)->states('create-licenses')->create();
|
||||
// factory(User::class, 1)->states('checkout-licenses')->create();
|
||||
// factory(User::class, 1)->states('view-keys-licenses')->create();
|
||||
// factory(User::class, 1)->states('view-components')->create();
|
||||
// factory(User::class, 1)->states('edit-components')->create();
|
||||
// factory(User::class, 1)->states('create-components')->create();
|
||||
// factory(User::class, 1)->states('delete-components')->create();
|
||||
// factory(User::class, 1)->states('checkout-components')->create();
|
||||
// factory(User::class, 1)->states('checkin-components')->create();
|
||||
// factory(User::class, 1)->states('view-users')->create();
|
||||
// factory(User::class, 1)->states('edit-users')->create();
|
||||
// factory(User::class, 1)->states('delete-users')->create();
|
||||
// factory(User::class, 1)->states('create-users')->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<tr>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="name" data-formatter="hardwareLinkFormatter">{{ trans('general.asset') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="qty">{{ trans('general.qty') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="created_at">{{ trans('general.date') }}</th>
|
||||
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="created_at" data-formatter="dateDisplayFormatter">{{ trans('general.date') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue