/** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); GenericContainer::creating(function ($genericContainer) { return $genericContainer->isCreating(); }); GenericContainer::saving(function ($genericContainer) { return $genericContainer->isSaving(); }); InboundOrder::creating(function ($inboundOrder) { return $inboundOrder->isCreating(); }); InboundOrderDetail::creating(function ($inboundOrderDetail) { return $inboundOrderDetail->isCreating(); }); Inventory::creating(function ($inventory) { return $inventory->isCreating(); }); Inventory::saving(function ($inventory) { return $inventory->isSaving(); }); Item::creating(function ($item) { return $item->isCreating(); }); JobExperience::creating(function ($jobExperience) { return $jobExperience->isCreating(); }); JobStatus::creating(function ($jobStatus) { return $jobStatus->isCreating(); }); Location::creating(function ($location) { return $location->isCreating(); }); Location::saving(function ($location) { return $location->isSaving(); }); Pallet::creating(function ($pallet) { return $pallet->isCreating(); }); Pallet::saving(function ($pallet) { return $pallet->isSaving(); }); PerformanceTally::creating(function ($performanceTally) { return $performanceTally->isCreating(); }); User::creating(function ($user) { return $user->isCreating(); }); }
/** * Implement putLocationIntoWarehouse($locationID, $warehouseID) */ public function putLocationIntoWarehouse($locationID, $warehouseID) { $location = Location::findOrFail($locationID); $warehouse = Warehouse::findOrFail($warehouseID); $container = DB::connection('vitaldev')->table('container')->where('objectID', $locationID)->first(); Log::info("Put Location {$locationID} into Warehouse {$warehouseID}"); if (isset($container)) { $result = DB::connection('vitaldev')->table('container')->where('containerID', $container->containerID)->update(['parentID' => $warehouseID, 'objectID' => $locationID]); // $result === 1/true if the container was updated // $result === 0/false if no containers were updated if ($result === 1 or $result === 0) { return true; } } else { $result = Container::create(['parentID' => $warehouseID, 'objectID' => $locationID]); // $result == container object created if (isset($result) and get_class($result) == 'App\\vital3\\Container') { return true; } } Log::error('putLocationIntoWarehouse failed'); //dd(__METHOD__.'('.__LINE__.')',compact('locationID','warehouseID','location','warehouse','container','result')); return ['putLocationIntoWarehouse failed']; }