コード例 #1
0
 /**
  * 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();
     });
 }
コード例 #2
0
 /**
  * Implement increment($input)
  */
 public function increment($input)
 {
     $userName = Auth::user()->name;
     $dateStamp = Carbon::now()->minute(00)->second(00);
     // find or create
     $performanceTally = PerformanceTally::where('userName', $userName)->where('dateStamp', $dateStamp)->first();
     if (isset($performanceTally) == false) {
         $performanceTally = $this->create([]);
     }
     Log::debug(__METHOD__ . "(" . __LINE__ . "):  performanceTally class: " . (is_array($performanceTally) ? "array()" : get_class($performanceTally)));
     // increment each attribute in $input
     foreach ($input as $key => $value) {
         $currentValue = $performanceTally->getAttribute($key);
         if (isset($currentValue)) {
             $performanceTally->setAttribute($key, $currentValue + $value);
         }
     }
     // update new values
     $performanceTally->update();
 }