public function StockCreationExample() { $metric = new Metric(); $metric->name = 'Unit'; $metric->symbol = 'U'; $metric->save(); //Now, create a category to store the inventory record under: $category = new Category(); $category->name = 'VoIP'; $category->save(); $item = new Inventory(); $item->metric_id = $metric->id; $item->category_id = $category->id; $item->name = 'SNOM Headset'; $item->description = 'Very nice for the ear'; $item->save(); $location = new Location(); $location->name = 'Snowball Small Stock Room'; $location->save(); $item->createStockOnLocation(2, $location); $item->createSku('PART1234'); dd($item->sku_code); //$res = Inventory::findBySku(Input::get('sku')); //$item = Inventory::find(1); //dd($item); $supplier = new Supplier(); //Mandatory fields $supplier->name = 'Miro Distribution'; //Optional fields $supplier->address = 'Montague Gardens'; $supplier->postal_code = '8000'; $supplier->zip_code = '12345'; $supplier->country = 'South Africa'; $supplier->region = 'Western Cape'; $supplier->city = 'Cape Town'; $supplier->contact_title = 'Sales Rep'; $supplier->contact_name = 'Mark Sparky'; $supplier->contact_phone = '555 555-5555'; $supplier->contact_fax = '555 555-5556'; $supplier->contact_email = '*****@*****.**'; $supplier->save(); $item = Inventory::find(1); //$supplier = Supplier::find(1); $item->addSupplier($supplier); }
public function testNewVariant() { $this->newInventory(); $milk = Inventory::find(1); $chocolateMilk = $milk->newVariant(); $chocolateMilk->name = 'Chocolate Milk'; DB::shouldReceive('beginTransaction')->once()->andReturn(true); DB::shouldReceive('commit')->once()->andReturn(true); Event::shouldReceive('fire')->once()->andReturn(true); $chocolateMilk->save(); $this->assertEquals($chocolateMilk->parent_id, $milk->id); $this->assertEquals($chocolateMilk->category_id, $milk->category_id); $this->assertEquals($chocolateMilk->metric_id, $milk->metric_id); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = Input::all(); Inventory::find($id)->update($input); return Redirect::route('inventory.index')->with('message', 'Inventory item updated.'); }
public function testInventoryDoesNotHaveCategory() { $this->newInventory(); $item = Inventory::find(1); $item->category_id = null; $item->save(); $this->assertFalse($item->hasCategory()); }
public function testInventoryGetStockFromLocationInvalidLocation() { $this->newInventoryStock(); $item = Inventory::find(1); Lang::shouldReceive('get')->once(); try { $item->getStockFromLocation('testing'); $passes = false; } catch (\Exception $e) { $passes = true; } $this->assertTrue($passes); }