Наследование: extends Model
Пример #1
1
 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);
 }
Пример #2
0
 public function testScopedInventories()
 {
     $metric = new Metric();
     $metric->name = 'Test Metric';
     $metric->symbol = 'Test Symbol';
     $metric->save();
     $productsCategory = Category::create(['name' => 'Products', 'belongs_to' => 'Products']);
     $miscCategory = Category::create(['name' => 'Misc', 'belongs_to' => 'Misc']);
     $noItemCategory = Category::create(['name' => 'No Items']);
     $productItem = Inventory::create(['name' => '', 'category_id' => $productsCategory->id, 'metric_id' => $metric->id]);
     $miscItem = Inventory::create(['name' => 'Item 1', 'category_id' => $miscCategory->id, 'metric_id' => $metric->id]);
     $miscItem2 = Inventory::create(['name' => 'Item 2', 'category_id' => $miscCategory->id, 'metric_id' => $metric->id]);
     $this->assertEquals(0, $noItemCategory->inventories()->count());
     $this->assertEquals(1, $productsCategory->inventories()->count());
     $this->assertEquals(2, $miscCategory->inventories()->count());
 }
Пример #3
0
 public function testInventoryDoesNotHaveMetric()
 {
     $item = $this->newInventory();
     $metric = Metric::find(1);
     $metric->delete();
     $this->assertFalse($item->hasMetric());
 }