Change user_id to created_by

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-17 22:16:41 +01:00
parent 6c996b7759
commit 1582d81e5b
115 changed files with 572 additions and 270 deletions

View file

@ -50,7 +50,7 @@ class SendAcceptanceReminder extends Command
$query->where('accepted_at', null) $query->where('accepted_at', null)
->where('declined_at', null); ->where('declined_at', null);
}) })
->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.admin']) ->with(['assignedTo', 'checkoutable.assignedTo', 'checkoutable.model', 'checkoutable.adminuser'])
->get(); ->get();
$count = 0; $count = 0;

View file

@ -73,7 +73,7 @@ class AccessoriesController extends Controller
$accessory->purchase_date = request('purchase_date'); $accessory->purchase_date = request('purchase_date');
$accessory->purchase_cost = request('purchase_cost'); $accessory->purchase_cost = request('purchase_cost');
$accessory->qty = request('qty'); $accessory->qty = request('qty');
$accessory->user_id = auth()->id(); $accessory->created_by = auth()->id();
$accessory->supplier_id = request('supplier_id'); $accessory->supplier_id = request('supplier_id');
$accessory->notes = request('notes'); $accessory->notes = request('notes');

View file

@ -78,7 +78,7 @@ class AccessoryCheckoutController extends Controller
AccessoryCheckout::create([ AccessoryCheckout::create([
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => Auth::id(), 'created_by' => auth()->id(),
'assigned_to' => $target->id, 'assigned_to' => $target->id,
'assigned_type' => $target::class, 'assigned_type' => $target::class,
'note' => $request->input('note'), 'note' => $request->input('note'),

View file

@ -56,7 +56,8 @@ class AccessoriesController extends Controller
]; ];
$accessories = Accessory::select('accessories.*')->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier') $accessories = Accessory::select('accessories.*')
->with('category', 'company', 'manufacturer', 'checkouts', 'location', 'supplier', 'adminuser')
->withCount('checkouts as checkouts_count'); ->withCount('checkouts as checkouts_count');
if ($request->filled('search')) { if ($request->filled('search')) {
@ -287,7 +288,7 @@ class AccessoriesController extends Controller
AccessoryCheckout::create([ AccessoryCheckout::create([
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => Auth::id(), 'created_by' => auth()->id(),
'assigned_to' => $target->id, 'assigned_to' => $target->id,
'assigned_type' => $target::class, 'assigned_type' => $target::class,
'note' => $request->input('note'), 'note' => $request->input('note'),

View file

@ -34,7 +34,7 @@ class AssetMaintenancesController extends Controller
$this->authorize('view', Asset::class); $this->authorize('view', Asset::class);
$maintenances = AssetMaintenance::select('asset_maintenances.*') $maintenances = AssetMaintenance::select('asset_maintenances.*')
->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'asset.assetstatus', 'admin'); ->with('asset', 'asset.model', 'asset.location', 'asset.defaultLoc', 'supplier', 'asset.company', 'asset.assetstatus', 'adminuser');
if ($request->filled('search')) { if ($request->filled('search')) {
$maintenances = $maintenances->TextSearch($request->input('search')); $maintenances = $maintenances->TextSearch($request->input('search'));
@ -69,7 +69,7 @@ class AssetMaintenancesController extends Controller
'asset_tag', 'asset_tag',
'asset_name', 'asset_name',
'serial', 'serial',
'user_id', 'created_by',
'supplier', 'supplier',
'is_warranty', 'is_warranty',
'status_label', 'status_label',
@ -79,7 +79,7 @@ class AssetMaintenancesController extends Controller
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at'; $sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
switch ($sort) { switch ($sort) {
case 'user_id': case 'created_by':
$maintenances = $maintenances->OrderAdmin($order); $maintenances = $maintenances->OrderAdmin($order);
break; break;
case 'supplier': case 'supplier':
@ -124,7 +124,7 @@ class AssetMaintenancesController extends Controller
// create a new model instance // create a new model instance
$maintenance = new AssetMaintenance(); $maintenance = new AssetMaintenance();
$maintenance->fill($request->all()); $maintenance->fill($request->all());
$maintenance->user_id = Auth::id(); $maintenance->created_by = Auth::id();
// Was the asset maintenance created? // Was the asset maintenance created?
if ($maintenance->save()) { if ($maintenance->save()) {

View file

@ -121,7 +121,7 @@ class AssetsController extends Controller
} }
$assets = Asset::select('assets.*') $assets = Asset::select('assets.*')
->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo', ->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo', 'adminuser','model.depreciation',
'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users. 'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
@ -568,7 +568,7 @@ class AssetsController extends Controller
$asset->model()->associate(AssetModel::find((int) $request->get('model_id'))); $asset->model()->associate(AssetModel::find((int) $request->get('model_id')));
$asset->fill($request->validated()); $asset->fill($request->validated());
$asset->user_id = Auth::id(); $asset->created_by = auth()->id();
/** /**
* this is here just legacy reasons. Api\AssetController * this is here just legacy reasons. Api\AssetController

View file

@ -47,7 +47,7 @@ class ComponentsController extends Controller
]; ];
$components = Component::select('components.*') $components = Component::select('components.*')
->with('company', 'location', 'category', 'assets', 'supplier'); ->with('company', 'location', 'category', 'assets', 'supplier', 'adminuser');
if ($request->filled('search')) { if ($request->filled('search')) {
$components = $components->TextSearch($request->input('search')); $components = $components->TextSearch($request->input('search'));
@ -270,7 +270,7 @@ class ComponentsController extends Controller
'component_id' => $component->id, 'component_id' => $component->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'assigned_qty' => $request->get('assigned_qty', 1), 'assigned_qty' => $request->get('assigned_qty', 1),
'user_id' => auth()->id(), 'created_by' => auth()->id(),
'asset_id' => $request->get('assigned_to'), 'asset_id' => $request->get('assigned_to'),
'note' => $request->get('note'), 'note' => $request->get('note'),
]); ]);

View file

@ -228,7 +228,7 @@ class ConsumablesController extends Controller
'name' => ($consumable_assignment->user) ? $consumable_assignment->user->present()->nameUrl() : 'Deleted User', 'name' => ($consumable_assignment->user) ? $consumable_assignment->user->present()->nameUrl() : 'Deleted User',
'created_at' => Helper::getFormattedDateObject($consumable_assignment->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($consumable_assignment->created_at, 'datetime'),
'note' => ($consumable_assignment->note) ? e($consumable_assignment->note) : null, 'note' => ($consumable_assignment->note) ? e($consumable_assignment->note) : null,
'admin' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : null, 'created_by' => ($consumable_assignment->admin) ? $consumable_assignment->admin->present()->nameUrl() : null,
]; ];
} }
@ -277,7 +277,7 @@ class ConsumablesController extends Controller
$consumable->users()->attach($consumable->id, $consumable->users()->attach($consumable->id,
[ [
'consumable_id' => $consumable->id, 'consumable_id' => $consumable->id,
'user_id' => $user->id, 'created_by' => $user->id,
'assigned_to' => $request->input('assigned_to'), 'assigned_to' => $request->input('assigned_to'),
'note' => $request->input('note'), 'note' => $request->input('note'),
] ]

View file

@ -97,7 +97,7 @@ class DepartmentsController extends Controller
$department->fill($request->all()); $department->fill($request->all());
$department = $request->handleImages($department); $department = $request->handleImages($department);
$department->user_id = auth()->id(); $department->created_by = auth()->id();
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null); $department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
if ($department->save()) { if ($department->save()) {

View file

@ -32,7 +32,8 @@ class DepreciationsController extends Controller
'licenses_count', 'licenses_count',
]; ];
$depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','user_id','created_at','updated_at') $depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','created_at','updated_at')
->with('adminuser')
->withCount('assets as assets_count') ->withCount('assets as assets_count')
->withCount('models as models_count') ->withCount('models as models_count')
->withCount('licenses as licenses_count'); ->withCount('licenses as licenses_count');

View file

@ -107,7 +107,7 @@ class LicenseSeatsController extends Controller
// attempt to update the license seat // attempt to update the license seat
$licenseSeat->fill($request->all()); $licenseSeat->fill($request->all());
$licenseSeat->user_id = auth()->id(); $licenseSeat->created_by = auth()->id();
// check if this update is a checkin operation // check if this update is a checkin operation
// 1. are relevant fields touched at all? // 1. are relevant fields touched at all?

View file

@ -70,8 +70,8 @@ class LicensesController extends Controller
$licenses->where('depreciation_id', '=', $request->input('depreciation_id')); $licenses->where('depreciation_id', '=', $request->input('depreciation_id'));
} }
if ($request->filled('user_id')) { if ($request->filled('created_by')) {
$licenses->where('user_id', '=', $request->input('user_id')); $licenses->where('created_by', '=', $request->input('created_by'));
} }
if (($request->filled('maintained')) && ($request->input('maintained')=='true')) { if (($request->filled('maintained')) && ($request->input('maintained')=='true')) {

View file

@ -181,7 +181,7 @@ class ManufacturersController extends Controller
$logaction->item_type = Manufacturer::class; $logaction->item_type = Manufacturer::class;
$logaction->item_id = $manufacturer->id; $logaction->item_id = $manufacturer->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');
return response()->json(Helper::formatStandardApiResponse('success', trans('admin/manufacturers/message.restore.success')), 200); return response()->json(Helper::formatStandardApiResponse('success', trans('admin/manufacturers/message.restore.success')), 200);

View file

@ -20,7 +20,7 @@ class ReportsController extends Controller
{ {
$this->authorize('reports.view'); $this->authorize('reports.view');
$actionlogs = Actionlog::with('item', 'user', 'admin', 'target', 'location'); $actionlogs = Actionlog::with('item', 'user', 'adminuser', 'target', 'location');
if ($request->filled('search')) { if ($request->filled('search')) {
$actionlogs = $actionlogs->TextSearch(e($request->input('search'))); $actionlogs = $actionlogs->TextSearch(e($request->input('search')));
@ -48,8 +48,8 @@ class ReportsController extends Controller
$actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc'); $actionlogs = $actionlogs->where('action_type', '=', $request->input('action_type'))->orderBy('created_at', 'desc');
} }
if ($request->filled('user_id')) { if ($request->filled('created_by')) {
$actionlogs = $actionlogs->where('user_id', '=', $request->input('user_id')); $actionlogs = $actionlogs->where('created_by', '=', $request->input('created_by'));
} }
if ($request->filled('action_source')) { if ($request->filled('action_source')) {
@ -68,7 +68,7 @@ class ReportsController extends Controller
'id', 'id',
'created_at', 'created_at',
'target_id', 'target_id',
'user_id', 'created_by',
'accept_signature', 'accept_signature',
'action_type', 'action_type',
'note', 'note',
@ -86,7 +86,7 @@ class ReportsController extends Controller
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc'; $order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
switch ($request->input('sort')) { switch ($request->input('sort')) {
case 'admin': case 'created_by':
$actionlogs->OrderAdmin($order); $actionlogs->OrderAdmin($order);
break; break;
default: default:

View file

@ -691,7 +691,7 @@ class UsersController extends Controller
$logaction->item_type = User::class; $logaction->item_type = User::class;
$logaction->item_id = $user->id; $logaction->item_id = $user->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('2FA reset'); $logaction->logaction('2FA reset');
return response()->json(['message' => trans('admin/settings/general.two_factor_reset_success')], 200); return response()->json(['message' => trans('admin/settings/general.two_factor_reset_success')], 200);
@ -741,7 +741,7 @@ class UsersController extends Controller
$logaction->item_type = User::class; $logaction->item_type = User::class;
$logaction->item_id = $user->id; $logaction->item_id = $user->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.success.restored')), 200); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/users/message.success.restored')), 200);

View file

@ -109,7 +109,7 @@ class AssetMaintenancesController extends Controller
$assetMaintenance->title = $request->input('title'); $assetMaintenance->title = $request->input('title');
$assetMaintenance->start_date = $request->input('start_date'); $assetMaintenance->start_date = $request->input('start_date');
$assetMaintenance->completion_date = $request->input('completion_date'); $assetMaintenance->completion_date = $request->input('completion_date');
$assetMaintenance->user_id = Auth::id(); $assetMaintenance->created_by = auth()->id();
if (($assetMaintenance->completion_date !== null) if (($assetMaintenance->completion_date !== null)
&& ($assetMaintenance->start_date !== '') && ($assetMaintenance->start_date !== '')

View file

@ -78,7 +78,7 @@ class AssetModelsController extends Controller
$model->manufacturer_id = $request->input('manufacturer_id'); $model->manufacturer_id = $request->input('manufacturer_id');
$model->category_id = $request->input('category_id'); $model->category_id = $request->input('category_id');
$model->notes = $request->input('notes'); $model->notes = $request->input('notes');
$model->user_id = Auth::id(); $model->created_by = auth()->id();
$model->requestable = $request->has('requestable'); $model->requestable = $request->has('requestable');
if ($request->input('fieldset_id') != '') { if ($request->input('fieldset_id') != '') {
@ -237,7 +237,7 @@ class AssetModelsController extends Controller
$logaction->item_type = AssetModel::class; $logaction->item_type = AssetModel::class;
$logaction->item_id = $model->id; $logaction->item_id = $model->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');

View file

@ -133,7 +133,7 @@ class AssetsController extends Controller
$asset->model_id = $request->input('model_id'); $asset->model_id = $request->input('model_id');
$asset->order_number = $request->input('order_number'); $asset->order_number = $request->input('order_number');
$asset->notes = $request->input('notes'); $asset->notes = $request->input('notes');
$asset->user_id = Auth::id(); $asset->created_by = auth()->id();
$asset->status_id = request('status_id'); $asset->status_id = request('status_id');
$asset->warranty_months = request('warranty_months', null); $asset->warranty_months = request('warranty_months', null);
$asset->purchase_cost = request('purchase_cost'); $asset->purchase_cost = request('purchase_cost');
@ -747,7 +747,7 @@ class AssetsController extends Controller
Actionlog::firstOrCreate([ Actionlog::firstOrCreate([
'item_id' => $asset->id, 'item_id' => $asset->id,
'item_type' => Asset::class, 'item_type' => Asset::class,
'user_id' => auth()->id(), 'created_by' => auth()->id(),
'note' => 'Checkout imported by '.auth()->user()->present()->fullName().' from history importer', 'note' => 'Checkout imported by '.auth()->user()->present()->fullName().' from history importer',
'target_id' => $item[$asset_tag][$batch_counter]['user_id'], 'target_id' => $item[$asset_tag][$batch_counter]['user_id'],
'target_type' => User::class, 'target_type' => User::class,
@ -775,7 +775,7 @@ class AssetsController extends Controller
Actionlog::firstOrCreate([ Actionlog::firstOrCreate([
'item_id' => $item[$asset_tag][$batch_counter]['asset_id'], 'item_id' => $item[$asset_tag][$batch_counter]['asset_id'],
'item_type' => Asset::class, 'item_type' => Asset::class,
'user_id' => auth()->id(), 'created_by' => auth()->id(),
'note' => 'Checkin imported by '.auth()->user()->present()->fullName().' from history importer', 'note' => 'Checkin imported by '.auth()->user()->present()->fullName().' from history importer',
'target_id' => null, 'target_id' => null,
'created_at' => $checkin_date, 'created_at' => $checkin_date,

View file

@ -69,7 +69,7 @@ class CategoriesController extends Controller
$category->use_default_eula = $request->input('use_default_eula', '0'); $category->use_default_eula = $request->input('use_default_eula', '0');
$category->require_acceptance = $request->input('require_acceptance', '0'); $category->require_acceptance = $request->input('require_acceptance', '0');
$category->checkin_email = $request->input('checkin_email', '0'); $category->checkin_email = $request->input('checkin_email', '0');
$category->user_id = Auth::id(); $category->created_by = auth()->id();
$category = $request->handleImages($category); $category = $request->handleImages($category);
if ($category->save()) { if ($category->save()) {

View file

@ -106,7 +106,7 @@ class ComponentCheckoutController extends Controller
$component->asset_id = $request->input('asset_id'); $component->asset_id = $request->input('asset_id');
$component->assets()->attach($component->id, [ $component->assets()->attach($component->id, [
'component_id' => $component->id, 'component_id' => $component->id,
'user_id' => auth()->user()->id, 'created_by' => auth()->user()->id,
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'assigned_qty' => $request->input('assigned_qty'), 'assigned_qty' => $request->input('assigned_qty'),
'asset_id' => $request->input('asset_id'), 'asset_id' => $request->input('asset_id'),

View file

@ -81,7 +81,7 @@ class ComponentsController extends Controller
$component->purchase_date = $request->input('purchase_date', null); $component->purchase_date = $request->input('purchase_date', null);
$component->purchase_cost = $request->input('purchase_cost', null); $component->purchase_cost = $request->input('purchase_cost', null);
$component->qty = $request->input('qty'); $component->qty = $request->input('qty');
$component->user_id = Auth::id(); $component->created_by = Auth::id();
$component->notes = $request->input('notes'); $component->notes = $request->input('notes');
$component = $request->handleImages($component); $component = $request->handleImages($component);

View file

@ -95,7 +95,7 @@ class ConsumableCheckoutController extends Controller
for($i = 0; $i < $quantity; $i++){ for($i = 0; $i < $quantity; $i++){
$consumable->users()->attach($consumable->id, [ $consumable->users()->attach($consumable->id, [
'consumable_id' => $consumable->id, 'consumable_id' => $consumable->id,
'user_id' => $admin_user->id, 'created_by' => $admin_user->id,
'assigned_to' => e($request->input('assigned_to')), 'assigned_to' => e($request->input('assigned_to')),
'note' => $request->input('note'), 'note' => $request->input('note'),
]); ]);

View file

@ -81,7 +81,7 @@ class ConsumablesController extends Controller
$consumable->purchase_date = $request->input('purchase_date'); $consumable->purchase_date = $request->input('purchase_date');
$consumable->purchase_cost = $request->input('purchase_cost'); $consumable->purchase_cost = $request->input('purchase_cost');
$consumable->qty = $request->input('qty'); $consumable->qty = $request->input('qty');
$consumable->user_id = Auth::id(); $consumable->created_by = Auth::id();
$consumable->notes = $request->input('notes'); $consumable->notes = $request->input('notes');
@ -221,7 +221,7 @@ class ConsumablesController extends Controller
$consumable = clone $consumable_to_close; $consumable = clone $consumable_to_close;
$consumable->id = null; $consumable->id = null;
$consumable->image = null; $consumable->image = null;
$consumable->user_id = null; $consumable->created_by = null;
return view('consumables/edit')->with('item', $consumable); return view('consumables/edit')->with('item', $consumable);
} }

View file

@ -248,7 +248,7 @@ class CustomFieldsController extends Controller
$field->name = trim(e($request->get("name"))); $field->name = trim(e($request->get("name")));
$field->element = e($request->get("element")); $field->element = e($request->get("element"));
$field->field_values = $request->get("field_values"); $field->field_values = $request->get("field_values");
$field->user_id = Auth::id(); $field->created_by = Auth::id();
$field->help_text = $request->get("help_text"); $field->help_text = $request->get("help_text");
$field->show_in_email = $show_in_email; $field->show_in_email = $show_in_email;
$field->is_unique = $request->get("is_unique", 0); $field->is_unique = $request->get("is_unique", 0);

View file

@ -90,7 +90,7 @@ class CustomFieldsetsController extends Controller
$fieldset = new CustomFieldset([ $fieldset = new CustomFieldset([
'name' => $request->get('name'), 'name' => $request->get('name'),
'user_id' => auth()->id(), 'created_by' => auth()->id(),
]); ]);
$validator = Validator::make($request->all(), $fieldset->rules); $validator = Validator::make($request->all(), $fieldset->rules);

View file

@ -51,7 +51,7 @@ class DepartmentsController extends Controller
$this->authorize('create', Department::class); $this->authorize('create', Department::class);
$department = new Department; $department = new Department;
$department->fill($request->all()); $department->fill($request->all());
$department->user_id = auth()->id(); $department->created_by = auth()->id();
$department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null); $department->manager_id = ($request->filled('manager_id') ? $request->input('manager_id') : null);
$department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null); $department->location_id = ($request->filled('location_id') ? $request->input('location_id') : null);
$department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null); $department->company_id = ($request->filled('company_id') ? $request->input('company_id') : null);

View file

@ -61,7 +61,7 @@ class DepreciationsController extends Controller
// Depreciation data // Depreciation data
$depreciation->name = $request->input('name'); $depreciation->name = $request->input('name');
$depreciation->months = $request->input('months'); $depreciation->months = $request->input('months');
$depreciation->user_id = Auth::id(); $depreciation->created_by = auth()->id();
$request->validate([ $request->validate([
'depreciation_min' => [ 'depreciation_min' => [

View file

@ -77,7 +77,7 @@ class LicenseCheckoutController extends Controller
$this->authorize('checkout', $license); $this->authorize('checkout', $license);
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId); $licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
$licenseSeat->user_id = Auth::id(); $licenseSeat->created_by = auth()->id();
$licenseSeat->notes = $request->input('notes'); $licenseSeat->notes = $request->input('notes');

View file

@ -99,7 +99,7 @@ class LicensesController extends Controller
$license->supplier_id = $request->input('supplier_id'); $license->supplier_id = $request->input('supplier_id');
$license->category_id = $request->input('category_id'); $license->category_id = $request->input('category_id');
$license->termination_date = $request->input('termination_date'); $license->termination_date = $request->input('termination_date');
$license->user_id = Auth::id(); $license->created_by = Auth::id();
$license->min_amt = $request->input('min_amt'); $license->min_amt = $request->input('min_amt');
session()->put(['redirect_option' => $request->get('redirect_option')]); session()->put(['redirect_option' => $request->get('redirect_option')]);

View file

@ -75,7 +75,7 @@ class LocationsController extends Controller
$location->zip = $request->input('zip'); $location->zip = $request->input('zip');
$location->ldap_ou = $request->input('ldap_ou'); $location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id'); $location->manager_id = $request->input('manager_id');
$location->user_id = auth()->id(); $location->created_by = auth()->id();
$location->phone = request('phone'); $location->phone = request('phone');
$location->fax = request('fax'); $location->fax = request('fax');
@ -278,7 +278,7 @@ class LocationsController extends Controller
$logaction->item_type = Location::class; $logaction->item_type = Location::class;
$logaction->item_id = $location->id; $logaction->item_id = $location->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');
return redirect()->route('locations.index')->with('success', trans('admin/locations/message.restore.success')); return redirect()->route('locations.index')->with('success', trans('admin/locations/message.restore.success'));

View file

@ -61,7 +61,7 @@ class ManufacturersController extends Controller
$this->authorize('create', Manufacturer::class); $this->authorize('create', Manufacturer::class);
$manufacturer = new Manufacturer; $manufacturer = new Manufacturer;
$manufacturer->name = $request->input('name'); $manufacturer->name = $request->input('name');
$manufacturer->user_id = Auth::id(); $manufacturer->created_by = auth()->id();
$manufacturer->url = $request->input('url'); $manufacturer->url = $request->input('url');
$manufacturer->support_url = $request->input('support_url'); $manufacturer->support_url = $request->input('support_url');
$manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url'); $manufacturer->warranty_lookup_url = $request->input('warranty_lookup_url');
@ -219,7 +219,7 @@ class ManufacturersController extends Controller
$logaction->item_type = Manufacturer::class; $logaction->item_type = Manufacturer::class;
$logaction->item_id = $manufacturer->id; $logaction->item_id = $manufacturer->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');
// Redirect them to the deleted page if there are more, otherwise the section index // Redirect them to the deleted page if there are more, otherwise the section index

View file

@ -181,7 +181,7 @@ class SettingsController extends Controller
$settings->brand = 1; $settings->brand = 1;
$settings->locale = $request->input('locale', 'en-US'); $settings->locale = $request->input('locale', 'en-US');
$settings->default_currency = $request->input('default_currency', 'USD'); $settings->default_currency = $request->input('default_currency', 'USD');
$settings->user_id = 1; $settings->created_by = 1;
$settings->email_domain = $request->input('email_domain'); $settings->email_domain = $request->input('email_domain');
$settings->email_format = $request->input('email_format'); $settings->email_format = $request->input('email_format');
$settings->next_auto_tag_base = 1; $settings->next_auto_tag_base = 1;

View file

@ -69,7 +69,7 @@ class StatuslabelsController extends Controller
// Save the Statuslabel data // Save the Statuslabel data
$statusLabel->name = $request->input('name'); $statusLabel->name = $request->input('name');
$statusLabel->user_id = Auth::id(); $statusLabel->created_by = auth()->id();
$statusLabel->notes = $request->input('notes'); $statusLabel->notes = $request->input('notes');
$statusLabel->deployable = $statusType['deployable']; $statusLabel->deployable = $statusType['deployable'];
$statusLabel->pending = $statusType['pending']; $statusLabel->pending = $statusType['pending'];

View file

@ -62,7 +62,7 @@ class SuppliersController extends Controller
$supplier->email = request('email'); $supplier->email = request('email');
$supplier->notes = request('notes'); $supplier->notes = request('notes');
$supplier->url = $supplier->addhttp(request('url')); $supplier->url = $supplier->addhttp(request('url'));
$supplier->user_id = Auth::id(); $supplier->created_by = auth()->id();
$supplier = $request->handleImages($supplier); $supplier = $request->handleImages($supplier);
if ($supplier->save()) { if ($supplier->save()) {

View file

@ -293,7 +293,7 @@ class BulkUsersController extends Controller
$logAction->item_type = $itemType; $logAction->item_type = $itemType;
$logAction->target_id = $item->assigned_to; $logAction->target_id = $item->assigned_to;
$logAction->target_type = User::class; $logAction->target_type = User::class;
$logAction->user_id = Auth::id(); $logAction->created_at = auth()->id();
$logAction->note = 'Bulk checkin items'; $logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from'); $logAction->logaction('checkin from');
} }
@ -307,7 +307,7 @@ class BulkUsersController extends Controller
$logAction->item_type = Accessory::class; $logAction->item_type = Accessory::class;
$logAction->target_id = $accessoryUserRow->assigned_to; $logAction->target_id = $accessoryUserRow->assigned_to;
$logAction->target_type = User::class; $logAction->target_type = User::class;
$logAction->user_id = Auth::id(); $logAction->created_at = auth()->id();
$logAction->note = 'Bulk checkin items'; $logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from'); $logAction->logaction('checkin from');
} }
@ -321,7 +321,7 @@ class BulkUsersController extends Controller
$logAction->item_type = Consumable::class; $logAction->item_type = Consumable::class;
$logAction->target_id = $consumableUserRow->assigned_to; $logAction->target_id = $consumableUserRow->assigned_to;
$logAction->target_type = User::class; $logAction->target_type = User::class;
$logAction->user_id = Auth::id(); $logAction->created_at = auth()->id();
$logAction->note = 'Bulk checkin items'; $logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from'); $logAction->logaction('checkin from');
} }

View file

@ -46,7 +46,7 @@ class UserFilesController extends Controller
$logAction = new Actionlog(); $logAction = new Actionlog();
$logAction->item_id = $user->id; $logAction->item_id = $user->id;
$logAction->item_type = User::class; $logAction->item_type = User::class;
$logAction->user_id = Auth::id(); $logaction->created_by = Auth::id();
$logAction->note = $request->input('notes'); $logAction->note = $request->input('notes');
$logAction->target_id = null; $logAction->target_id = null;
$logAction->created_at = date("Y-m-d H:i:s"); $logAction->created_at = date("Y-m-d H:i:s");

View file

@ -372,7 +372,7 @@ class UsersController extends Controller
$logaction->item_type = User::class; $logaction->item_type = User::class;
$logaction->item_id = $user->id; $logaction->item_id = $user->id;
$logaction->created_at = date('Y-m-d H:i:s'); $logaction->created_at = date('Y-m-d H:i:s');
$logaction->user_id = auth()->id(); $logaction->created_by = auth()->id();
$logaction->logaction('restore'); $logaction->logaction('restore');
// Redirect them to the deleted page if there are more, otherwise the section index // Redirect them to the deleted page if there are more, otherwise the section index

View file

@ -40,7 +40,10 @@ class AccessoriesTransformer
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null, 'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
'remaining_qty' => (int) $accessory->numRemaining(), 'remaining_qty' => (int) $accessory->numRemaining(),
'checkouts_count' => $accessory->checkouts_count, 'checkouts_count' => $accessory->checkouts_count,
'created_by' => ($accessory->adminuser) ? [
'id' => (int) $accessory->adminuser->id,
'name'=> e($accessory->adminuser->present()->fullName()),
] : null,
'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'),

View file

@ -176,11 +176,17 @@ class ActionlogsTransformer
'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null, 'next_audit_date' => ($actionlog->itemType()=='asset') ? Helper::getFormattedDateObject($actionlog->calcNextAuditDate(null, $actionlog->item), 'date'): null,
'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item), 'days_to_next_audit' => $actionlog->daysUntilNextAudit($settings->audit_interval, $actionlog->item),
'action_type' => $actionlog->present()->actionType(), 'action_type' => $actionlog->present()->actionType(),
'admin' => ($actionlog->admin) ? [ 'admin' => ($actionlog->adminuser) ? [
'id' => (int) $actionlog->admin->id, 'id' => (int) $actionlog->adminuser->id,
'name' => e($actionlog->admin->getFullNameAttribute()), 'name' => e($actionlog->adminuser->getFullNameAttribute()),
'first_name'=> e($actionlog->admin->first_name), 'first_name'=> e($actionlog->adminuser->first_name),
'last_name'=> e($actionlog->admin->last_name) 'last_name'=> e($actionlog->adminuser->last_name)
] : null,
'created_by' => ($actionlog->adminuser) ? [
'id' => (int) $actionlog->adminuser->id,
'name' => e($actionlog->adminuser->getFullNameAttribute()),
'first_name'=> e($actionlog->adminuser->first_name),
'last_name'=> e($actionlog->adminuser->last_name)
] : null, ] : null,
'target' => ($actionlog->target) ? [ 'target' => ($actionlog->target) ? [
'id' => (int) $actionlog->target->id, 'id' => (int) $actionlog->target->id,

View file

@ -47,6 +47,10 @@ class ComponentsTransformer
'name' => e($component->company->name), 'name' => e($component->company->name),
] : null, ] : null,
'notes' => ($component->notes) ? Helper::parseEscapedMarkedownInline($component->notes) : null, 'notes' => ($component->notes) ? Helper::parseEscapedMarkedownInline($component->notes) : null,
'created_by' => ($component->adminuser) ? [
'id' => (int) $component->adminuser->id,
'name'=> e($component->adminuser->present()->fullName()),
] : null,
'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'),
'user_can_checkout' => ($component->numRemaining() > 0) ? 1 : 0, 'user_can_checkout' => ($component->numRemaining() > 0) ? 1 : 0,

View file

@ -40,6 +40,10 @@ class ConsumablesTransformer
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'), 'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
'qty' => (int) $consumable->qty, 'qty' => (int) $consumable->qty,
'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedownInline($consumable->notes) : null, 'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedownInline($consumable->notes) : null,
'created_by' => ($consumable->adminuser) ? [
'id' => (int) $consumable->adminuser->id,
'name'=> e($consumable->adminuser->present()->fullName()),
] : null,
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'), 'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'), 'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
]; ];

View file

@ -186,7 +186,7 @@ class AssetImporter extends ItemImporter
} }
} }
$asset->fresh()->checkOut($target, $this->user_id, $checkout_date, null, 'Checkout from CSV Importer', $asset->name); $asset->fresh()->checkOut($target, $this->created_by, $checkout_date, null, 'Checkout from CSV Importer', $asset->name);
} }
return; return;

View file

@ -58,7 +58,7 @@ class ComponentImporter extends ItemImporter
if (isset($this->item['asset_tag']) && ($asset = Asset::where('asset_tag', $this->item['asset_tag'])->first())) { if (isset($this->item['asset_tag']) && ($asset = Asset::where('asset_tag', $this->item['asset_tag'])->first())) {
$component->assets()->attach($component->id, [ $component->assets()->attach($component->id, [
'component_id' => $component->id, 'component_id' => $component->id,
'user_id' => $this->user_id, 'user_id' => $this->created_by,
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'assigned_qty' => 1, // Only assign the first one to the asset 'assigned_qty' => 1, // Only assign the first one to the asset
'asset_id' => $asset->id, 'asset_id' => $asset->id,

View file

@ -418,7 +418,7 @@ abstract class Importer
*/ */
public function setUserId($user_id) public function setUserId($user_id)
{ {
$this->user_id = $user_id; $this->created_by = $user_id;
return $this; return $this;
} }

View file

@ -94,7 +94,7 @@ class ItemImporter extends Importer
$this->item['qty'] = $this->findCsvMatch($row, 'quantity'); $this->item['qty'] = $this->findCsvMatch($row, 'quantity');
$this->item['requestable'] = $this->findCsvMatch($row, 'requestable'); $this->item['requestable'] = $this->findCsvMatch($row, 'requestable');
$this->item['user_id'] = $this->user_id; $this->item['user_id'] = $this->created_by;
$this->item['serial'] = $this->findCsvMatch($row, 'serial'); $this->item['serial'] = $this->findCsvMatch($row, 'serial');
// NO need to call this method if we're running the user import. // NO need to call this method if we're running the user import.
// TODO: Merge these methods. // TODO: Merge these methods.
@ -301,7 +301,7 @@ class ItemImporter extends Importer
$category = new Category(); $category = new Category();
$category->name = $asset_category; $category->name = $asset_category;
$category->category_type = $item_type; $category->category_type = $item_type;
$category->user_id = $this->user_id; $category->created_by = $this->created_by;
if ($category->save()) { if ($category->save()) {
$this->log('Category '.$asset_category.' was created'); $this->log('Category '.$asset_category.' was created');
@ -425,7 +425,7 @@ class ItemImporter extends Importer
//Otherwise create a manufacturer. //Otherwise create a manufacturer.
$manufacturer = new Manufacturer(); $manufacturer = new Manufacturer();
$manufacturer->name = trim($item_manufacturer); $manufacturer->name = trim($item_manufacturer);
$manufacturer->user_id = $this->user_id; $manufacturer->created_by = $this->created_by;
if ($manufacturer->save()) { if ($manufacturer->save()) {
$this->log('Manufacturer '.$manufacturer->name.' was created'); $this->log('Manufacturer '.$manufacturer->name.' was created');
@ -466,7 +466,7 @@ class ItemImporter extends Importer
$location->city = ''; $location->city = '';
$location->state = ''; $location->state = '';
$location->country = ''; $location->country = '';
$location->user_id = $this->user_id; $location->created_by = $this->created_by;
if ($location->save()) { if ($location->save()) {
$this->log('Location '.$asset_location.' was created'); $this->log('Location '.$asset_location.' was created');
@ -502,7 +502,7 @@ class ItemImporter extends Importer
$supplier = new Supplier(); $supplier = new Supplier();
$supplier->name = $item_supplier; $supplier->name = $item_supplier;
$supplier->user_id = $this->user_id; $supplier->created_by = $this->created_by;
if ($supplier->save()) { if ($supplier->save()) {
$this->log('Supplier '.$item_supplier.' was created'); $this->log('Supplier '.$item_supplier.' was created');

View file

@ -103,13 +103,13 @@ class LicenseImporter extends ItemImporter
if ($checkout_target) { if ($checkout_target) {
$targetLicense->assigned_to = $checkout_target->id; $targetLicense->assigned_to = $checkout_target->id;
$targetLicense->user_id = Auth::id(); $targetLicense->created_by = auth()->id();
if ($asset) { if ($asset) {
$targetLicense->asset_id = $asset->id; $targetLicense->asset_id = $asset->id;
} }
$targetLicense->save(); $targetLicense->save();
} elseif ($asset) { } elseif ($asset) {
$targetLicense->user_id = Auth::id(); $targetLicense->created_by = auth()->id();
$targetLicense->asset_id = $asset->id; $targetLicense->asset_id = $asset->id;
$targetLicense->save(); $targetLicense->save();
} }

View file

@ -165,7 +165,7 @@ class UserImporter extends ItemImporter
$department = new department(); $department = new department();
$department->name = $department_name; $department->name = $department_name;
$department->user_id = $this->user_id; $department->created_by = $this->created_by;
if ($department->save()) { if ($department->save()) {
$this->log('department ' . $department_name . ' was created'); $this->log('department ' . $department_name . ' was created');

View file

@ -111,7 +111,7 @@ class LogListener
$logaction->target_type = User::class; $logaction->target_type = User::class;
$logaction->action_type = 'merged'; $logaction->action_type = 'merged';
$logaction->note = trans('general.merged_log_this_user_from', $to_from_array); $logaction->note = trans('general.merged_log_this_user_from', $to_from_array);
$logaction->user_id = $event->admin->id ?? null; $logaction->created_by = $event->admin->id ?? null;
$logaction->save(); $logaction->save();
// Add a record to the users being merged TO // Add a record to the users being merged TO
@ -122,7 +122,7 @@ class LogListener
$logaction->item_type = User::class; $logaction->item_type = User::class;
$logaction->action_type = 'merged'; $logaction->action_type = 'merged';
$logaction->note = trans('general.merged_log_this_user_into', $to_from_array); $logaction->note = trans('general.merged_log_this_user_into', $to_from_array);
$logaction->user_id = $event->admin->id ?? null; $logaction->created_by = $event->admin->id ?? null;
$logaction->save(); $logaction->save();

View file

@ -47,10 +47,10 @@ class OauthClients extends Component
{ {
// test for safety // test for safety
// ->delete must be of type Client - thus the model binding // ->delete must be of type Client - thus the model binding
if ($clientId->user_id == auth()->id()) { if ($clientId->created_by == auth()->id()) {
app(ClientRepository::class)->delete($clientId); app(ClientRepository::class)->delete($clientId);
} else { } else {
Log::warning('User ' . auth()->id() . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->user_id); Log::warning('User ' . auth()->id() . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->created_by);
$this->authorizationError = 'You are not authorized to delete this client.'; $this->authorizationError = 'You are not authorized to delete this client.';
} }
} }
@ -58,10 +58,10 @@ class OauthClients extends Component
public function deleteToken($tokenId): void public function deleteToken($tokenId): void
{ {
$token = app(TokenRepository::class)->find($tokenId); $token = app(TokenRepository::class)->find($tokenId);
if ($token->user_id == auth()->id()) { if ($token->created_by == auth()->id()) {
app(TokenRepository::class)->revokeAccessToken($tokenId); app(TokenRepository::class)->revokeAccessToken($tokenId);
} else { } else {
Log::warning('User ' . auth()->id() . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->user_id); Log::warning('User ' . auth()->id() . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->created_by);
$this->authorizationError = 'You are not authorized to delete this token.'; $this->authorizationError = 'You are not authorized to delete this token.';
} }
} }
@ -84,12 +84,12 @@ class OauthClients extends Component
]); ]);
$client = app(ClientRepository::class)->find($editClientId->id); $client = app(ClientRepository::class)->find($editClientId->id);
if ($client->user_id == auth()->id()) { if ($client->created_by == auth()->id()) {
$client->name = $this->editName; $client->name = $this->editName;
$client->redirect = $this->editRedirect; $client->redirect = $this->editRedirect;
$client->save(); $client->save();
} else { } else {
Log::warning('User ' . auth()->id() . ' attempted to edit client ' . $editClientId->id . ' which belongs to user ' . $client->user_id); Log::warning('User ' . auth()->id() . ' attempted to edit client ' . $editClientId->id . ' which belongs to user ' . $client->created_by);
$this->authorizationError = 'You are not authorized to edit this client.'; $this->authorizationError = 'You are not authorized to edit this client.';
} }

View file

@ -259,6 +259,18 @@ class Accessory extends SnipeModel
->with('assignedTo'); ->with('assignedTo');
} }
/**
* Establishes the accessory -> admin user relationship
*
* @author A. Gianotto <snipe@snipe.net>
* @since [v7.0.13]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function adminuser()
{
return $this->belongsTo(\App\Models\User::class, 'created_by');
}
/** /**
* Checks whether or not the accessory has users * Checks whether or not the accessory has users
* *

View file

@ -22,7 +22,7 @@ class AccessoryCheckout extends Model
{ {
use Searchable; use Searchable;
protected $fillable = ['user_id', 'accessory_id', 'assigned_to', 'assigned_type', 'note']; protected $fillable = ['created_by', 'accessory_id', 'assigned_to', 'assigned_type', 'note'];
protected $table = 'accessories_checkout'; protected $table = 'accessories_checkout';
/** /**

View file

@ -21,7 +21,7 @@ class Actionlog extends SnipeModel
// This is to manually set the source (via setActionSource()) for determineActionSource() // This is to manually set the source (via setActionSource()) for determineActionSource()
protected ?string $source = null; protected ?string $source = null;
protected $with = ['admin']; protected $with = ['adminuser'];
protected $presenter = \App\Presenters\ActionlogPresenter::class; protected $presenter = \App\Presenters\ActionlogPresenter::class;
use SoftDeletes; use SoftDeletes;
@ -32,7 +32,7 @@ class Actionlog extends SnipeModel
protected $fillable = [ protected $fillable = [
'created_at', 'created_at',
'item_type', 'item_type',
'user_id', 'created_by',
'item_id', 'item_id',
'action_type', 'action_type',
'note', 'note',
@ -52,7 +52,7 @@ class Actionlog extends SnipeModel
'action_type', 'action_type',
'note', 'note',
'log_meta', 'log_meta',
'user_id', 'created_by',
'remote_ip', 'remote_ip',
'user_agent', 'user_agent',
'action_source' 'action_source'
@ -65,7 +65,7 @@ class Actionlog extends SnipeModel
*/ */
protected $searchableRelations = [ protected $searchableRelations = [
'company' => ['name'], 'company' => ['name'],
'admin' => ['first_name','last_name','username', 'email'], 'adminuser' => ['first_name','last_name','username', 'email'],
'user' => ['first_name','last_name','username', 'email'], 'user' => ['first_name','last_name','username', 'email'],
'assets' => ['asset_tag','name'], 'assets' => ['asset_tag','name'],
]; ];
@ -198,9 +198,9 @@ class Actionlog extends SnipeModel
* @since [v3.0] * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function admin() public function adminuser()
{ {
return $this->belongsTo(User::class, 'user_id') return $this->belongsTo(User::class, 'created_by')
->withTrashed(); ->withTrashed();
} }
@ -376,6 +376,6 @@ class Actionlog extends SnipeModel
public function scopeOrderAdmin($query, $order) public function scopeOrderAdmin($query, $order)
{ {
return $query->leftJoin('users as admin_sort', 'action_logs.user_id', '=', 'admin_sort.id')->select('action_logs.*')->orderBy('admin_sort.first_name', $order)->orderBy('admin_sort.last_name', $order); return $query->leftJoin('users as admin_sort', 'action_logs.created_by', '=', 'admin_sort.id')->select('action_logs.*')->orderBy('admin_sort.first_name', $order)->orderBy('admin_sort.last_name', $order);
} }
} }

View file

@ -30,7 +30,7 @@ class Asset extends Depreciable
{ {
protected $presenter = AssetPresenter::class; protected $presenter = AssetPresenter::class;
protected $with = ['model', 'admin']; protected $with = ['model', 'adminuser'];
use CompanyableTrait; use CompanyableTrait;
use HasFactory, Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait; use HasFactory, Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait;
@ -108,7 +108,6 @@ class Asset extends Depreciable
'expected_checkin' => ['nullable', 'date'], 'expected_checkin' => ['nullable', 'date'],
'last_audit_date' => ['nullable', 'date_format:Y-m-d H:i:s'], 'last_audit_date' => ['nullable', 'date_format:Y-m-d H:i:s'],
'next_audit_date' => ['nullable', 'date'], 'next_audit_date' => ['nullable', 'date'],
//'after:last_audit_date'],
'location_id' => ['nullable', 'exists:locations,id'], 'location_id' => ['nullable', 'exists:locations,id'],
'rtd_location_id' => ['nullable', 'exists:locations,id'], 'rtd_location_id' => ['nullable', 'exists:locations,id'],
'purchase_date' => ['nullable', 'date', 'date_format:Y-m-d'], 'purchase_date' => ['nullable', 'date', 'date_format:Y-m-d'],
@ -716,9 +715,9 @@ class Asset extends Depreciable
* @since [v1.0] * @since [v1.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function admin() public function adminuser()
{ {
return $this->belongsTo(\App\Models\User::class, 'user_id'); return $this->belongsTo(\App\Models\User::class, 'created_by');
} }

View file

@ -36,7 +36,7 @@ class AssetModel extends SnipeModel
protected $injectUniqueIdentifier = true; protected $injectUniqueIdentifier = true;
use ValidatingTrait; use ValidatingTrait;
protected $table = 'models'; protected $table = 'models';
protected $hidden = ['user_id', 'deleted_at']; protected $hidden = ['created_by', 'deleted_at'];
protected $presenter = AssetModelPresenter::class; protected $presenter = AssetModelPresenter::class;
// Declare the rules for the model validation // Declare the rules for the model validation

View file

@ -29,17 +29,17 @@ class Category extends SnipeModel
use SoftDeletes; use SoftDeletes;
protected $table = 'categories'; protected $table = 'categories';
protected $hidden = ['user_id', 'deleted_at']; protected $hidden = ['created_by', 'deleted_at'];
protected $casts = [ protected $casts = [
'user_id' => 'integer', 'created_by' => 'integer',
]; ];
/** /**
* Category validation rules * Category validation rules
*/ */
public $rules = [ public $rules = [
'user_id' => 'numeric|nullable', 'created_by' => 'numeric|nullable',
'name' => 'required|min:1|max:255|two_column_unique_undeleted:category_type', 'name' => 'required|min:1|max:255|two_column_unique_undeleted:category_type',
'require_acceptance' => 'boolean', 'require_acceptance' => 'boolean',
'use_default_eula' => 'boolean', 'use_default_eula' => 'boolean',
@ -70,7 +70,7 @@ class Category extends SnipeModel
'name', 'name',
'require_acceptance', 'require_acceptance',
'use_default_eula', 'use_default_eula',
'user_id', 'created_by',
]; ];
use Searchable; use Searchable;

View file

@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class CheckoutRequest extends Model class CheckoutRequest extends Model
{ {
use SoftDeletes; use SoftDeletes;
protected $fillable = ['user_id']; protected $fillable = ['created_by'];
protected $table = 'checkout_requests'; protected $table = 'checkout_requests';
public function user() public function user()

View file

@ -67,6 +67,7 @@ final class Company extends SnipeModel
'phone', 'phone',
'fax', 'fax',
'email', 'email',
'created_by'
]; ];
private static function isFullMultipleCompanySupportEnabled() private static function isFullMultipleCompanySupportEnabled()

View file

@ -130,7 +130,7 @@ class Component extends SnipeModel
*/ */
public function assets() public function assets()
{ {
return $this->belongsToMany(\App\Models\Asset::class, 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'user_id', 'note'); return $this->belongsToMany(\App\Models\Asset::class, 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'created_by', 'note');
} }
/** /**
@ -142,9 +142,9 @@ class Component extends SnipeModel
* @since [v3.0] * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function admin() public function adminuser()
{ {
return $this->belongsTo(\App\Models\User::class, 'user_id'); return $this->belongsTo(\App\Models\User::class, 'created_by');
} }
/** /**

View file

@ -154,9 +154,9 @@ class Consumable extends SnipeModel
* @since [v3.0] * @since [v3.0]
* @return \Illuminate\Database\Eloquent\Relations\Relation * @return \Illuminate\Database\Eloquent\Relations\Relation
*/ */
public function admin() public function adminuser()
{ {
return $this->belongsTo(User::class, 'user_id'); return $this->belongsTo(User::class, 'created_by');
} }
/** /**
@ -256,7 +256,7 @@ class Consumable extends SnipeModel
*/ */
public function users() : Relation public function users() : Relation
{ {
return $this->belongsToMany(User::class, 'consumables_users', 'consumable_id', 'assigned_to')->withPivot('user_id')->withTrashed()->withTimestamps(); return $this->belongsToMany(User::class, 'consumables_users', 'consumable_id', 'assigned_to')->withPivot('created_by')->withTrashed()->withTimestamps();
} }
/** /**

View file

@ -26,8 +26,8 @@ class ConsumableAssignment extends Model
return $this->belongsTo(\App\Models\User::class, 'assigned_to'); return $this->belongsTo(\App\Models\User::class, 'assigned_to');
} }
public function admin() public function adminuser()
{ {
return $this->belongsTo(\App\Models\User::class, 'user_id'); return $this->belongsTo(\App\Models\User::class, 'created_by');
} }
} }

View file

@ -42,7 +42,7 @@ class Department extends SnipeModel
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'user_id', 'created_by',
'name', 'name',
'phone', 'phone',
'fax', 'fax',

View file

@ -82,7 +82,7 @@ class License extends Depreciable
'supplier_id', 'supplier_id',
'termination_date', 'termination_date',
'free_seat_count', 'free_seat_count',
'user_id', 'created_by',
'min_amt', 'min_amt',
]; ];
@ -184,7 +184,7 @@ class License extends Depreciable
$logAction = new Actionlog; $logAction = new Actionlog;
$logAction->item_type = self::class; $logAction->item_type = self::class;
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->user_id = Auth::id() ?: 1; // We don't have an id while running the importer from CLI. $logAction->created_by = Auth::id() ?: 1; // We don't have an id while running the importer from CLI.
$logAction->note = "deleted ${change} seats"; $logAction->note = "deleted ${change} seats";
$logAction->target_id = null; $logAction->target_id = null;
$logAction->logaction('delete seats'); $logAction->logaction('delete seats');
@ -196,7 +196,7 @@ class License extends Depreciable
$licenseInsert = []; $licenseInsert = [];
for ($i = $oldSeats; $i < $newSeats; $i++) { for ($i = $oldSeats; $i < $newSeats; $i++) {
$licenseInsert[] = [ $licenseInsert[] = [
'user_id' => Auth::id(), 'created_by' => auth()->id(),
'license_id' => $license->id, 'license_id' => $license->id,
'created_at' => now(), 'created_at' => now(),
'updated_at' => now() 'updated_at' => now()
@ -216,7 +216,7 @@ class License extends Depreciable
$logAction = new Actionlog(); $logAction = new Actionlog();
$logAction->item_type = self::class; $logAction->item_type = self::class;
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->user_id = Auth::id() ?: 1; // Importer. $logAction->created_by = Auth::id() ?: 1; // Importer.
$logAction->note = "added ${change} seats"; $logAction->note = "added ${change} seats";
$logAction->target_id = null; $logAction->target_id = null;
$logAction->logaction('add seats'); $logAction->logaction('add seats');
@ -434,7 +434,7 @@ class License extends Depreciable
*/ */
public function adminuser() public function adminuser()
{ {
return $this->belongsTo(\App\Models\User::class, 'user_id'); return $this->belongsTo(\App\Models\User::class, 'created_by');
} }
/** /**
@ -747,6 +747,6 @@ class License extends Depreciable
*/ */
public function scopeOrderCreatedBy($query, $order) public function scopeOrderCreatedBy($query, $order)
{ {
return $query->leftJoin('users as users_sort', 'licenses.user_id', '=', 'users_sort.id')->select('licenses.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order); return $query->leftJoin('users as users_sort', 'licenses.created_by', '=', 'users_sort.id')->select('licenses.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order);
} }
} }

View file

@ -37,7 +37,7 @@ trait Loggable
$log = new Actionlog; $log = new Actionlog;
$log = $this->determineLogItemType($log); $log = $this->determineLogItemType($log);
if (auth()->user()) { if (auth()->user()) {
$log->user_id = auth()->id(); $log->created_by = auth()->id();
} }
if (! isset($target)) { if (! isset($target)) {
@ -149,7 +149,7 @@ trait Loggable
} }
if (auth()->user()) { if (auth()->user()) {
$log->user_id = auth()->id(); $log->created_by = auth()->id();
} }
$changed = []; $changed = [];
@ -225,7 +225,7 @@ trait Loggable
} }
$log->location_id = ($location_id) ? $location_id : null; $log->location_id = ($location_id) ? $location_id : null;
$log->note = $note; $log->note = $note;
$log->user_id = auth()->id(); $log->created_by = auth()->id();
$log->filename = $filename; $log->filename = $filename;
$log->logaction('audit'); $log->logaction('audit');
@ -248,9 +248,9 @@ trait Loggable
*/ */
public function logCreate($note = null) public function logCreate($note = null)
{ {
$user_id = -1; $created_by = -1;
if (auth()->user()) { if (auth()->user()) {
$user_id = auth()->id(); $created_by = auth()->id();
} }
$log = new Actionlog; $log = new Actionlog;
if (static::class == LicenseSeat::class) { if (static::class == LicenseSeat::class) {
@ -262,7 +262,7 @@ trait Loggable
} }
$log->location_id = null; $log->location_id = null;
$log->note = $note; $log->note = $note;
$log->user_id = $user_id; $log->created_by = $created_by;
$log->logaction('create'); $log->logaction('create');
$log->save(); $log->save();
@ -284,7 +284,7 @@ trait Loggable
$log->item_type = static::class; $log->item_type = static::class;
$log->item_id = $this->id; $log->item_id = $this->id;
} }
$log->user_id = auth()->id(); $log->created_by = auth()->id();
$log->note = $note; $log->note = $note;
$log->target_id = null; $log->target_id = null;
$log->created_at = date('Y-m-d H:i:s'); $log->created_at = date('Y-m-d H:i:s');

View file

@ -20,7 +20,7 @@ class AccessoryObserver
$logAction->item_type = Accessory::class; $logAction->item_type = Accessory::class;
$logAction->item_id = $accessory->id; $logAction->item_id = $accessory->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -37,7 +37,7 @@ class AccessoryObserver
$logAction->item_type = Accessory::class; $logAction->item_type = Accessory::class;
$logAction->item_id = $accessory->id; $logAction->item_id = $accessory->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
if($accessory->imported) { if($accessory->imported) {
$logAction->setActionSource('importer'); $logAction->setActionSource('importer');
} }
@ -56,7 +56,7 @@ class AccessoryObserver
$logAction->item_type = Accessory::class; $logAction->item_type = Accessory::class;
$logAction->item_id = $accessory->id; $logAction->item_id = $accessory->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
} }

View file

@ -62,7 +62,7 @@ class AssetObserver
$logAction->item_type = Asset::class; $logAction->item_type = Asset::class;
$logAction->item_id = $asset->id; $logAction->item_id = $asset->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->log_meta = json_encode($changed); $logAction->log_meta = json_encode($changed);
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -108,7 +108,7 @@ class AssetObserver
$logAction->item_type = Asset::class; // can we instead say $logAction->item = $asset ? $logAction->item_type = Asset::class; // can we instead say $logAction->item = $asset ?
$logAction->item_id = $asset->id; $logAction->item_id = $asset->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
if($asset->imported) { if($asset->imported) {
$logAction->setActionSource('importer'); $logAction->setActionSource('importer');
} }
@ -127,7 +127,7 @@ class AssetObserver
$logAction->item_type = Asset::class; $logAction->item_type = Asset::class;
$logAction->item_id = $asset->id; $logAction->item_id = $asset->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
@ -143,7 +143,7 @@ class AssetObserver
$logAction->item_type = Asset::class; $logAction->item_type = Asset::class;
$logAction->item_id = $asset->id; $logAction->item_id = $asset->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('restore'); $logAction->logaction('restore');
} }

View file

@ -20,7 +20,7 @@ class ComponentObserver
$logAction->item_type = Component::class; $logAction->item_type = Component::class;
$logAction->item_id = $component->id; $logAction->item_id = $component->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -37,7 +37,7 @@ class ComponentObserver
$logAction->item_type = Component::class; $logAction->item_type = Component::class;
$logAction->item_id = $component->id; $logAction->item_id = $component->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
if($component->imported) { if($component->imported) {
$logAction->setActionSource('importer'); $logAction->setActionSource('importer');
} }
@ -56,7 +56,7 @@ class ComponentObserver
$logAction->item_type = Component::class; $logAction->item_type = Component::class;
$logAction->item_id = $component->id; $logAction->item_id = $component->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
} }

View file

@ -34,7 +34,7 @@ class ConsumableObserver
$logAction->item_type = Consumable::class; $logAction->item_type = Consumable::class;
$logAction->item_id = $consumable->id; $logAction->item_id = $consumable->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->log_meta = json_encode($changed); $logAction->log_meta = json_encode($changed);
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -53,7 +53,7 @@ class ConsumableObserver
$logAction->item_type = Consumable::class; $logAction->item_type = Consumable::class;
$logAction->item_id = $consumable->id; $logAction->item_id = $consumable->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
if($consumable->imported) { if($consumable->imported) {
$logAction->setActionSource('importer'); $logAction->setActionSource('importer');
} }
@ -98,7 +98,7 @@ class ConsumableObserver
$logAction->item_type = Consumable::class; $logAction->item_type = Consumable::class;
$logAction->item_id = $consumable->id; $logAction->item_id = $consumable->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
} }

View file

@ -20,7 +20,7 @@ class LicenseObserver
$logAction->item_type = License::class; $logAction->item_type = License::class;
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -37,7 +37,7 @@ class LicenseObserver
$logAction->item_type = License::class; $logAction->item_type = License::class;
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
if($license->imported) { if($license->imported) {
$logAction->setActionSource('importer'); $logAction->setActionSource('importer');
} }
@ -56,7 +56,7 @@ class LicenseObserver
$logAction->item_type = License::class; $logAction->item_type = License::class;
$logAction->item_id = $license->id; $logAction->item_id = $license->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
} }

View file

@ -83,7 +83,7 @@ class UserObserver
$logAction->target_type = User::class; // can we instead say $logAction->item = $asset ? $logAction->target_type = User::class; // can we instead say $logAction->item = $asset ?
$logAction->target_id = $user->id; $logAction->target_id = $user->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->log_meta = json_encode($changed); $logAction->log_meta = json_encode($changed);
$logAction->logaction('update'); $logAction->logaction('update');
} }
@ -105,7 +105,7 @@ class UserObserver
$logAction->item_type = User::class; // can we instead say $logAction->item = $asset ? $logAction->item_type = User::class; // can we instead say $logAction->item = $asset ?
$logAction->item_id = $user->id; $logAction->item_id = $user->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('create'); $logAction->logaction('create');
} }
@ -123,7 +123,7 @@ class UserObserver
$logAction->target_type = User::class; // can we instead say $logAction->item = $asset ? $logAction->target_type = User::class; // can we instead say $logAction->item = $asset ?
$logAction->target_id = $user->id; $logAction->target_id = $user->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('delete'); $logAction->logaction('delete');
} }
@ -141,7 +141,7 @@ class UserObserver
$logAction->target_type = User::class; // can we instead say $logAction->item = $asset ? $logAction->target_type = User::class; // can we instead say $logAction->item = $asset ?
$logAction->target_id = $user->id; $logAction->target_id = $user->id;
$logAction->created_at = date('Y-m-d H:i:s'); $logAction->created_at = date('Y-m-d H:i:s');
$logAction->user_id = Auth::id(); $logAction->created_by = auth()->id();
$logAction->logaction('restore'); $logAction->logaction('restore');
} }

View file

@ -135,6 +135,29 @@ class AccessoryPresenter extends Presenter
'title' => trans('general.change'), 'title' => trans('general.change'),
'formatter' => 'accessoriesInOutFormatter', 'formatter' => 'accessoriesInOutFormatter',
], [ ], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
],[
'field' => 'actions', 'field' => 'actions',
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,

View file

@ -123,6 +123,29 @@ class AssetMaintenancesPresenter extends Presenter
'title' => trans('general.admin'), 'title' => trans('general.admin'),
'formatter' => 'usersLinkObjFormatter', 'formatter' => 'usersLinkObjFormatter',
], [ ], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
],[
'field' => 'actions', 'field' => 'actions',
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,

View file

@ -135,19 +135,27 @@ class AssetModelPresenter extends Presenter
'formatter' => 'notesFormatter', 'formatter' => 'notesFormatter',
], ],
[ [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at', 'field' => 'created_at',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.created_at'), 'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], ], [
[
'field' => 'updated_at', 'field' => 'updated_at',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.updated_at'), 'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], ],

View file

@ -233,18 +233,28 @@ class AssetPresenter extends Presenter
'title' => trans('general.user_requests_count'), 'title' => trans('general.user_requests_count'),
], [ ], [
'field' => 'created_at', 'field' => 'created_by',
'searchable' => false, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false, 'visible' => false,
'formatter' => 'usersLinkObjFormatter',
],
[
'field' => 'created_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_at'), 'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'updated_at', 'field' => 'updated_at',
'searchable' => false, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.updated_at'), 'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'last_checkout', 'field' => 'last_checkout',

View file

@ -77,19 +77,28 @@ class CategoryPresenter extends Presenter
"title" => trans('admin/categories/general.use_default_eula_column'), "title" => trans('admin/categories/general.use_default_eula_column'),
'visible' => true, 'visible' => true,
"formatter" => 'trueFalseFormatter', "formatter" => 'trueFalseFormatter',
],[
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [ ], [
'field' => 'created_at', 'field' => 'created_at',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.created_at'), 'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'updated_at', 'field' => 'updated_at',
'searchable' => true, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.updated_at'), 'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'actions', 'field' => 'actions',

View file

@ -105,20 +105,29 @@ class CompanyPresenter extends Presenter
'title' => trans('general.components'), 'title' => trans('general.components'),
'visible' => true, 'visible' => true,
'class' => 'css-component', 'class' => 'css-component',
], [ ],[
'field' => 'updated_at', 'field' => 'created_by',
'searchable' => false, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false, 'visible' => false,
'title' => trans('general.updated_at'), 'formatter' => 'usersLinkObjFormatter',
'formatter' => 'createdAtFormatter',
], [ ], [
'field' => 'created_at', 'field' => 'created_at',
'searchable' => false, 'searchable' => true,
'sortable' => true, 'sortable' => true,
'visible' => false, 'switchable' => true,
'title' => trans('general.created_at'), 'title' => trans('general.created_at'),
'formatter' => 'createdAtFormatter', 'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'actions', 'field' => 'actions',
'searchable' => false, 'searchable' => false,

View file

@ -119,6 +119,27 @@ class ComponentPresenter extends Presenter
'visible' => false, 'visible' => false,
'title' => trans('general.notes'), 'title' => trans('general.notes'),
'formatter' => 'notesFormatter', 'formatter' => 'notesFormatter',
],[
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
],[
'field' => 'created_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.created_at'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.updated_at'),
'formatter' => 'dateDisplayFormatter',
], ],
]; ];

View file

@ -131,6 +131,27 @@ class ConsumablePresenter extends Presenter
'visible' => false, 'visible' => false,
'title' => trans('general.notes'), 'title' => trans('general.notes'),
'formatter' => 'notesFormatter', 'formatter' => 'notesFormatter',
], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
],[
'field' => 'created_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.created_at'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => false,
'sortable' => true,
'visible' => false,
'title' => trans('general.updated_at'),
'formatter' => 'dateDisplayFormatter',
], [ ], [
'field' => 'change', 'field' => 'change',
'searchable' => false, 'searchable' => false,

View file

@ -65,8 +65,30 @@ class DepreciationPresenter extends Presenter
'sortable' => true, 'sortable' => true,
'title' => trans('general.licenses'), 'title' => trans('general.licenses'),
'visible' => true, 'visible' => true,
], ],[
[ 'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'actions', 'field' => 'actions',
'searchable' => false, 'searchable' => false,
'sortable' => false, 'sortable' => false,

View file

@ -162,7 +162,7 @@ class LicensePresenter extends Presenter
'field' => 'created_by', 'field' => 'created_by',
'searchable' => false, 'searchable' => false,
'sortable' => true, 'sortable' => true,
'title' => trans('general.admin'), 'title' => trans('general.created_by'),
'visible' => false, 'visible' => false,
'formatter' => 'usersLinkObjFormatter', 'formatter' => 'usersLinkObjFormatter',
], [ ], [

View file

@ -27,6 +27,29 @@ class PredefinedKitPresenter extends Presenter
'sortable' => true, 'sortable' => true,
'title' => trans('general.name'), 'title' => trans('general.name'),
'formatter' => 'kitsLinkFormatter', 'formatter' => 'kitsLinkFormatter',
], [
'field' => 'created_by',
'searchable' => false,
'sortable' => true,
'title' => trans('general.created_by'),
'visible' => false,
'formatter' => 'usersLinkObjFormatter',
], [
'field' => 'created_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.created_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], ],
]; ];

View file

@ -361,6 +361,14 @@ class UserPresenter extends Presenter
'title' => trans('general.created_at'), 'title' => trans('general.created_at'),
'visible' => false, 'visible' => false,
'formatter' => 'dateDisplayFormatter', 'formatter' => 'dateDisplayFormatter',
], [
'field' => 'updated_at',
'searchable' => true,
'sortable' => true,
'switchable' => true,
'title' => trans('general.updated_at'),
'visible' => false,
'formatter' => 'dateDisplayFormatter',
], ],
[ [
'field' => 'start_date', 'field' => 'start_date',

View file

@ -157,7 +157,7 @@ class PredefinedKitCheckoutService
} }
// licenses // licenses
foreach ($license_seats_to_add as $licenseSeat) { foreach ($license_seats_to_add as $licenseSeat) {
$licenseSeat->user_id = $admin->id; $licenseSeat->created_by = $admin->id;
$licenseSeat->assigned_to = $user->id; $licenseSeat->assigned_to = $user->id;
if ($licenseSeat->save()) { if ($licenseSeat->save()) {
event(new CheckoutableCheckedOut($licenseSeat, $user, $admin, $note)); event(new CheckoutableCheckedOut($licenseSeat, $user, $admin, $note));

View file

@ -34,7 +34,7 @@ class AccessoryFactory extends Factory
$this->faker->randomElement(['Bluetooth', 'Wired']), $this->faker->randomElement(['Bluetooth', 'Wired']),
$this->faker->randomElement(['Keyboard', 'Wired']) $this->faker->randomElement(['Keyboard', 'Wired'])
), ),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'category_id' => Category::factory()->forAccessories(), 'category_id' => Category::factory()->forAccessories(),
'model_number' => $this->faker->numberBetween(1000000, 50000000), 'model_number' => $this->faker->numberBetween(1000000, 50000000),
'location_id' => Location::factory(), 'location_id' => Location::factory(),
@ -129,7 +129,7 @@ class AccessoryFactory extends Factory
$accessory->checkouts()->create([ $accessory->checkouts()->create([
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => $user->id, 'created_by' => $user->id,
'assigned_to' => $user->id, 'assigned_to' => $user->id,
'assigned_type' => User::class, 'assigned_type' => User::class,
'note' => '', 'note' => '',
@ -150,7 +150,7 @@ class AccessoryFactory extends Factory
$accessory->checkouts()->create([ $accessory->checkouts()->create([
'accessory_id' => $accessory->id, 'accessory_id' => $accessory->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => 1, 'created_by' => 1,
'assigned_to' => $user->id ?? User::factory()->create()->id, 'assigned_to' => $user->id ?? User::factory()->create()->id,
'assigned_type' => User::class, 'assigned_type' => User::class,
]); ]);

View file

@ -29,7 +29,7 @@ class ActionlogFactory extends Factory
return [ return [
'item_id' => Asset::factory(), 'item_id' => Asset::factory(),
'item_type' => Asset::class, 'item_type' => Asset::class,
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'action_type' => 'uploaded', 'action_type' => 'uploaded',
]; ];
} }
@ -92,7 +92,7 @@ class ActionlogFactory extends Factory
$licenseSeat->update([ $licenseSeat->update([
'assigned_to' => $target->id, 'assigned_to' => $target->id,
'user_id' => 1, // not ideal but works 'created_by' => 1, // not ideal but works
]); ]);
return [ return [

View file

@ -36,7 +36,7 @@ class AssetFactory extends Factory
'status_id' => function () { 'status_id' => function () {
return Statuslabel::where('name', 'Ready to Deploy')->first() ?? Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']); return Statuslabel::where('name', 'Ready to Deploy')->first() ?? Statuslabel::factory()->rtd()->create(['name' => 'Ready to Deploy']);
}, },
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'asset_tag' => $this->faker->unixTime('now'), 'asset_tag' => $this->faker->unixTime('now'),
'notes' => 'Created by DB seeder', 'notes' => 'Created by DB seeder',
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'), 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),

View file

@ -28,7 +28,7 @@ class AssetModelFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'name' => $this->faker->catchPhrase(), 'name' => $this->faker->catchPhrase(),
'category_id' => Category::factory(), 'category_id' => Category::factory(),
'model_number' => $this->faker->creditCardNumber(), 'model_number' => $this->faker->creditCardNumber(),

View file

@ -29,7 +29,7 @@ class CategoryFactory extends Factory
'eula_text' => $this->faker->paragraph(), 'eula_text' => $this->faker->paragraph(),
'require_acceptance' => false, 'require_acceptance' => false,
'use_default_eula' => $this->faker->boolean(), 'use_default_eula' => $this->faker->boolean(),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
]; ];
} }

View file

@ -23,6 +23,7 @@ class CompanyFactory extends Factory
{ {
return [ return [
'name' => $this->faker->unique()->company(), 'name' => $this->faker->unique()->company(),
'created_by' => 1,
]; ];
} }
} }

View file

@ -108,7 +108,7 @@ class ComponentFactory extends Factory
$component->assets()->attach($component->id, [ $component->assets()->attach($component->id, [
'component_id' => $component->id, 'component_id' => $component->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => 1, 'created_by' => 1,
'asset_id' => $asset->id ?? Asset::factory()->create()->id, 'asset_id' => $asset->id ?? Asset::factory()->create()->id,
]); ]);
}); });

View file

@ -30,7 +30,7 @@ class ConsumableFactory extends Factory
return [ return [
'name' => $this->faker->words(3, true), 'name' => $this->faker->words(3, true),
'category_id' => Category::factory(), 'category_id' => Category::factory(),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'item_no' => $this->faker->numberBetween(1000000, 50000000), 'item_no' => $this->faker->numberBetween(1000000, 50000000),
'order_number' => $this->faker->numberBetween(1000000, 50000000), 'order_number' => $this->faker->numberBetween(1000000, 50000000),
'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'), 'purchase_date' => $this->faker->dateTimeBetween('-1 years', 'now', date_default_timezone_get())->format('Y-m-d'),
@ -104,7 +104,7 @@ class ConsumableFactory extends Factory
$consumable->users()->attach($consumable->id, [ $consumable->users()->attach($consumable->id, [
'consumable_id' => $consumable->id, 'consumable_id' => $consumable->id,
'user_id' => $user->id, 'created_by' => $user->id,
'assigned_to' => $user->id, 'assigned_to' => $user->id,
'note' => '', 'note' => '',
]); ]);
@ -124,7 +124,7 @@ class ConsumableFactory extends Factory
$consumable->users()->attach($consumable->id, [ $consumable->users()->attach($consumable->id, [
'consumable_id' => $consumable->id, 'consumable_id' => $consumable->id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
'user_id' => User::factory()->create()->id, 'created_by' => User::factory()->create()->id,
'assigned_to' => $user->id ?? User::factory()->create()->id, 'assigned_to' => $user->id ?? User::factory()->create()->id,
]); ]);
}); });

View file

@ -25,7 +25,7 @@ class DepartmentFactory extends Factory
{ {
return [ return [
'name' => $this->faker->unique()->word() . ' Department', 'name' => $this->faker->unique()->word() . ' Department',
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'location_id' => Location::factory(), 'location_id' => Location::factory(),
]; ];
} }

View file

@ -24,7 +24,7 @@ class DepreciationFactory extends Factory
{ {
return [ return [
'name' => $this->faker->unique()->catchPhrase(), 'name' => $this->faker->unique()->catchPhrase(),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'months' => 36, 'months' => 36,
]; ];
} }

View file

@ -25,7 +25,7 @@ class LicenseFactory extends Factory
public function definition() public function definition()
{ {
return [ return [
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'name' => $this->faker->name(), 'name' => $this->faker->name(),
'license_email' => $this->faker->safeEmail(), 'license_email' => $this->faker->safeEmail(),
'serial' => $this->faker->uuid(), 'serial' => $this->faker->uuid(),

View file

@ -24,7 +24,7 @@ class ManufacturerFactory extends Factory
{ {
return [ return [
'name' => $this->faker->unique()->company(), 'name' => $this->faker->unique()->company(),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'support_phone' => $this->faker->phoneNumber(), 'support_phone' => $this->faker->phoneNumber(),
'url' => $this->faker->url(), 'url' => $this->faker->url(),
'support_email' => $this->faker->safeEmail(), 'support_email' => $this->faker->safeEmail(),

View file

@ -26,7 +26,7 @@ class StatuslabelFactory extends Factory
'name' => $this->faker->sentence(), 'name' => $this->faker->sentence(),
'created_at' => $this->faker->dateTime(), 'created_at' => $this->faker->dateTime(),
'updated_at' => $this->faker->dateTime(), 'updated_at' => $this->faker->dateTime(),
'user_id' => User::factory()->superuser(), 'created_by' => User::factory()->superuser(),
'deleted_at' => null, 'deleted_at' => null,
'deployable' => 0, 'deployable' => 0,
'pending' => 0, 'pending' => 0,

View file

@ -0,0 +1,93 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
foreach ($this->add_to_table_list() as $add_table) {
if (!Schema::hasColumn($add_table, 'created_by')) {
Schema::table($add_table, function (Blueprint $add_table) {
$add_table->unsignedBigInteger('created_by')->nullable()->before('created_at');
});
}
}
foreach ($this->existing_table_list() as $table) {
if (Schema::hasColumn($table, 'user_id')) {
Schema::table($table, function (Blueprint $table) {
$table->renameColumn('user_id', 'created_by');
});
}
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
foreach ($this->add_to_table_list() as $add_table) {
if (Schema::hasColumn($add_table, 'created_by')) {
Schema::table($add_table, function (Blueprint $add_table) {
$add_table->dropColumn('created_by');
});
}
}
foreach ($this->existing_table_list() as $table) {
if (Schema::hasColumn($table, 'user_id')) {
Schema::table($table, function (Blueprint $table) {
$table->renameColumn('created_by', 'user_id');
});
}
}
}
public function existing_table_list() {
return [
'accessories',
'accessories_checkout',
'action_logs',
'asset_maintenances',
'assets',
'categories',
'components',
'components_assets',
'consumables',
'consumables_users',
'custom_fields',
'custom_fieldsets',
'departments',
'depreciations',
'license_seats',
'licenses',
'locations',
'manufacturers',
'models',
'settings',
'status_labels',
'suppliers',
'users',
];
}
public function add_to_table_list() {
return [
'companies',
'imports',
'kits',
'kits_accessories',
'kits_consumables',
'kits_licenses',
'kits_models',
'users_groups',
];
}
};

View file

@ -35,25 +35,25 @@ class AccessorySeeder extends Seeder
Accessory::factory()->appleUsbKeyboard()->create([ Accessory::factory()->appleUsbKeyboard()->create([
'location_id' => $locationIds->random(), 'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(), 'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id, 'created_by' => $admin->id,
]); ]);
Accessory::factory()->appleBtKeyboard()->create([ Accessory::factory()->appleBtKeyboard()->create([
'location_id' => $locationIds->random(), 'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(), 'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id, 'created_by' => $admin->id,
]); ]);
Accessory::factory()->appleMouse()->create([ Accessory::factory()->appleMouse()->create([
'location_id' => $locationIds->random(), 'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(), 'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id, 'created_by' => $admin->id,
]); ]);
Accessory::factory()->microsoftMouse()->create([ Accessory::factory()->microsoftMouse()->create([
'location_id' => $locationIds->random(), 'location_id' => $locationIds->random(),
'supplier_id' => $supplierIds->random(), 'supplier_id' => $supplierIds->random(),
'user_id' => $admin->id, 'created_by' => $admin->id,
]); ]);

View file

@ -27,16 +27,16 @@ class ActionlogSeeder extends Seeder
Actionlog::factory() Actionlog::factory()
->count(300) ->count(300)
->assetCheckoutToUser() ->assetCheckoutToUser()
->create(['user_id' => $admin->id]); ->create(['created_by' => $admin->id]);
Actionlog::factory() Actionlog::factory()
->count(100) ->count(100)
->assetCheckoutToLocation() ->assetCheckoutToLocation()
->create(['user_id' => $admin->id]); ->create(['created_by' => $admin->id]);
Actionlog::factory() Actionlog::factory()
->count(20) ->count(20)
->licenseCheckoutToUser() ->licenseCheckoutToUser()
->create(['user_id' => $admin->id]); ->create(['created_by' => $admin->id]);
} }
} }

View file

@ -17,34 +17,34 @@ class AssetModelSeeder extends Seeder
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create(); $admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
// Laptops // Laptops
AssetModel::factory()->count(1)->mbp13Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->mbp13Model()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->mbpAirModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->mbpAirModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->surfaceModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->surfaceModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->xps13Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->xps13Model()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->spectreModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->spectreModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->zenbookModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->zenbookModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->yogaModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->yogaModel()->create(['created_by' => $admin->id]);
// Desktops // Desktops
AssetModel::factory()->count(1)->macproModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->macproModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->lenovoI5Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->lenovoI5Model()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->optiplexModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->optiplexModel()->create(['created_by' => $admin->id]);
// Conference Phones // Conference Phones
AssetModel::factory()->count(1)->polycomModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->polycomModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->polycomcxModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->polycomcxModel()->create(['created_by' => $admin->id]);
// Tablets // Tablets
AssetModel::factory()->count(1)->ipadModel()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->ipadModel()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->tab3Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->tab3Model()->create(['created_by' => $admin->id]);
// Phones // Phones
AssetModel::factory()->count(1)->iphone11Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->iphone11Model()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->iphone12Model()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->iphone12Model()->create(['created_by' => $admin->id]);
// Displays // Displays
AssetModel::factory()->count(1)->ultrafine()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->ultrafine()->create(['created_by' => $admin->id]);
AssetModel::factory()->count(1)->ultrasharp()->create(['user_id' => $admin->id]); AssetModel::factory()->count(1)->ultrasharp()->create(['created_by' => $admin->id]);
$src = public_path('/img/demo/models/'); $src = public_path('/img/demo/models/');
$dst = 'models'.'/'; $dst = 'models'.'/';

View file

@ -82,7 +82,7 @@ class AssetSeeder extends Seeder
return fn($sequence) => [ return fn($sequence) => [
'rtd_location_id' => $this->locationIds->random(), 'rtd_location_id' => $this->locationIds->random(),
'supplier_id' => $this->supplierIds->random(), 'supplier_id' => $this->supplierIds->random(),
'user_id' => $this->admin->id, 'created_by' => $this->admin->id,
]; ];
} }
} }

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