Example #1
0
 /**
  * Creates a stock record as well as a first record movement.
  *
  * @return bool|static
  */
 public function create()
 {
     $this->dbStartTransaction();
     try {
         /*
          * Set insert data
          */
         $insert = ['inventory_id' => $this->getInput('inventory_id'), 'location_id' => $this->getInput('location_id'), 'quantity' => $this->getInput('quantity')];
         /*
          * Create the stock record
          */
         $record = $this->model->create($insert);
         if ($record) {
             /*
              * Fire stock created event
              */
             $this->fireEvent('maintenance.inventory.stock.created', ['stock' => $record]);
             $this->dbCommitTransaction();
             return $record;
         }
         $this->dbRollbackTransaction();
         return false;
     } catch (\Exception $e) {
         $this->dbRollbackTransaction();
         return false;
     }
 }