当前位置: 首页>>代码示例>>PHP>>正文


PHP Inventory::create方法代码示例

本文整理汇总了PHP中Inventory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::create方法的具体用法?PHP Inventory::create怎么用?PHP Inventory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Inventory::create([]);
     }
 }
开发者ID:jonagoldman,项目名称:channelmanager,代码行数:7,代码来源:InventoriesTableSeeder.php

示例2: store

 /**
  * Store a newly created inventory in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Inventory::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['purchase_date'] = strtotime($data['purchase_date']);
     $data['warranty_expiration'] = strtotime($data['warranty_expiration']);
     Inventory::create($data);
     return Redirect::route('inventories.index');
 }
开发者ID:kicohen,项目名称:TechTracker,代码行数:16,代码来源:InventoriesController.php

示例3: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $item = Input::all();
     $data = array('product_id' => $item['pro_name'], 'eng_no' => $item['eng_no'], 'chs_no' => $item['chs_no'], 'is_sell' => '0', 'color' => $item['pro_color'], 'quantity' => 1, 'buy_rate' => $item['pro_buy_rate'], 'sell_rate' => $item['pro_sell_rate'], 'comision_tk' => $item['pro_comi_rate'], 'img' => 'NA', 'item_no' => 'NA', 'supplyir_id' => $item['supplyir_id']);
     try {
         $insert = Inventory::create($data);
         if ($insert) {
             return json_encode(array('error' => 0, 'success' => 1));
         } else {
             return json_encode(array('error' => 1, 'success' => 0));
         }
     } catch (Exception $e) {
         print_r($e);
     }
 }
开发者ID:rana7cse,项目名称:motoshop,代码行数:20,代码来源:InventoryController.php

示例4: run

 public function run()
 {
     foreach (range(1, 100) as $index) {
         Inventory::create(['item_name' => "Monkey Coffee Cup", 'price' => 2.5, 'image' => '/uploaded/monkeycup.jpg']);
     }
 }
开发者ID:automotivecapstone,项目名称:capstone.dev,代码行数:6,代码来源:InventoriesTableSeeder.php

示例5: finalize_delivery

 public function finalize_delivery()
 {
     $id1 = Input::get('orderID');
     $id2 = Input::get('deliverID');
     $orderproducts = OrderProduct::where('strOPOrdersID', '=', $id1)->get();
     $a = 1;
     $b = 1;
     foreach ($orderproducts as $orderproduct) {
         $details = DeliveryDetail::create(array('strDetID' => $id2, 'strDetProdID' => $orderproduct->strOPProdID, 'intDetQty' => $orderproduct->intOPQuantity));
         $details->save();
         $ids = DB::table('tblInventory')->select('strBatchID')->orderBy('strBatchID', 'desc')->take(1)->get();
         $ID = $ids["0"]->strBatchID;
         $newID = $this->smart($ID);
         $inv = Inventory::create(array('strBatchID' => $newID, 'strProdID' => $orderproduct->strOPProdID, 'strDlvryID' => $id2, 'intAvailQty' => $orderproduct->intOPQuantity, 'dblCurRetPrice' => Input::get($b + 'Rprice'), 'dblCurWPrice' => Input::get($a + 'Wprice')));
         $inv->save();
         $a++;
         $b++;
     }
     $notesID = $id1;
     $notes = OrderNotes::find($notesID);
     $notes->strOrdNotesStat = "Accepted";
     $notes->save();
     return Redirect::to('/delivery');
 }
开发者ID:ExperimentalGroup,项目名称:inventoryfinal,代码行数:24,代码来源:HomeController.php

示例6: getMap

 /**
  * Show the form for editing the specified room.
  *
  * @param int $id
  * @param int $channelId
  * @return Response
  */
 public function getMap($id, $channelId)
 {
     $room = Room::find($id);
     $channelSettings = PropertiesChannel::getSettings($channelId, Property::getLoggedId());
     $channel = ChannelFactory::create($channelSettings);
     $result = $channel->getInventoryList();
     //todo temp
     //        file_put_contents('1.txt', serialize($result));
     //        $result = unserialize(file_get_contents('1.txt'));
     //add Inventories and Plans to DB//TODO move to another place
     //delete exist maps
     Inventory::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
     //delete exist plan maps
     InventoryPlan::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
     if ($result) {
         foreach ($result as $inventory) {
             Inventory::create(['code' => $inventory['code'], 'name' => $inventory['name'], 'channel_id' => $channelId, 'property_id' => $channelSettings->property_id]);
             if ($inventory['plans']) {
                 foreach ($inventory['plans'] as $plan) {
                     InventoryPlan::create(['code' => $plan['code'], 'name' => $plan['name'], 'channel_id' => $channelId, 'inventory_code' => $inventory['code'], 'property_id' => $channelSettings->property_id]);
                 }
             }
         }
     }
     $existMapping = [];
     //        $mapCollection = InventoryMap::where(
     //            [
     //                'channel_id' => $channelId,
     //                'property_id' => $channelSettings->property_id
     //            ]
     //        )
     ////            ->where('room_id', '<>', $id)
     //            ->lists('inventory_code', 'room_id');
     //        if ($mapCollection) {
     //            foreach ($mapCollection as $map) {
     //                $existMapping[] = $map;
     //            }
     //        }>F
     $inventories = Channel::find($channelId)->inventory()->where('property_id', Property::getLoggedId());
     $inventoryList = [];
     $inventoryPlans = [];
     foreach ($inventories->get() as $inventory) {
         //            if (in_array($inventory->code, $existMapping)) {
         //                continue;
         //            }
         $inventoryList[$inventory->code] = $inventory->name;
         $plans = $inventory->plans()->get(['name', 'code']);
         for ($i = 0; $i < count($plans); $i++) {
             //TODO rewrite to ONE query
             $plans[$i]->selected = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id, $plans[$i]['code'])->first() ? true : false;
         }
         $inventoryPlans[$inventory->code] = $plans;
     }
     $inventoryPlans = json_encode($inventoryPlans);
     $mapping = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id)->first();
     return View::make('rooms.map', compact('room', 'channel', 'inventoryList', 'inventoryPlans', 'channelId', 'mapping'));
 }
开发者ID:jonagoldman,项目名称:channelmanager,代码行数:64,代码来源:RoomsController.php

示例7: update

 /**
  * Updates a Quest for a Character. If the Quest is completed and turned in
  * the Character may receive some Quest rewards.
  *
  * @param int $quest The ID of the quest
  * @param int $character_id The ID of the Character
  * @param boolean $turnIn Whenever this quest is turning in
  */
 function update($quest_id = null, $character_id = null, $turnIn = false)
 {
     App::import('Model', 'CharactersQuest');
     $CharactersQuest = new CharactersQuest();
     $conditions = array();
     $conditions['CharactersQuest.completed !='] = 'finished';
     if (isset($quest_id)) {
         $conditions['CharactersQuest.quest_id'] = $quest_id;
     }
     if (isset($character_id)) {
         $conditions['CharactersQuest.character_id'] = $character_id;
     }
     $quests = $CharactersQuest->find('all', array('conditions' => array($conditions)));
     if (!empty($quests)) {
         // Inventory, Kill maybe needed
         App::import('Model', 'Inventory');
         $Inventory = new Inventory();
         App::import('Model', 'Kill');
         $Kill = new Kill();
         $charactersQuestsData = array();
         $i = 0;
         foreach ($quests as $quest) {
             $charactersQuestsData[$i]['id'] = $quest['CharactersQuest']['id'];
             // Get the needed things (items, object, whatever) here
             $itemsNeeded = $this->ItemsQuest->find('list', array('conditions' => array('ItemsQuest.quest_id' => $quest['CharactersQuest']['quest_id'], 'ItemsQuest.type' => 'needed'), 'fields' => array('ItemsQuest.item_id', 'ItemsQuest.amount')));
             $mobsNeeded = $this->MobsQuest->find('list', array('conditions' => array('MobsQuest.quest_id' => $quest['CharactersQuest']['quest_id']), 'fields' => array('MobsQuest.mob_id', 'MobsQuest.amount')));
             $itemsRewards = $this->ItemsQuest->find('list', array('conditions' => array('ItemsQuest.quest_id' => $quest['CharactersQuest']['quest_id'], 'ItemsQuest.type' => 'reward'), 'fields' => array('ItemsQuest.item_id', 'ItemsQuest.amount')));
             $statsRewards = $this->QuestsStat->find('list', array('conditions' => array('QuestsStat.quest_id' => $quest['CharactersQuest']['quest_id']), 'fields' => array('QuestsStat.stat_id', 'QuestsStat.amount')));
             $completed = '';
             if (empty($itemsNeeded) && empty($mobsNeeded)) {
                 // Geen items nodig.. Omdat er op het moment niks anders is om te controleren updaten we deze quest...
                 if ($turnIn == true && isset($character_id) && isset($quest_id)) {
                     $charactersQuestsData[$i]['completed'] = 'finished';
                 } else {
                     $charactersQuestsData[$i]['completed'] = 'yes';
                 }
             } else {
                 $completed = 'yes';
                 // Default it's completed.
                 $itemList = array();
                 $mobList = array();
                 foreach ($itemsNeeded as $item_id => $amount) {
                     $itemList[] = $item_id;
                 }
                 foreach ($mobsNeeded as $mob_id => $amount) {
                     $mobList[] = $mob_id;
                 }
                 // Er zijn items nodig voor deze quest..  Kijken of deze al gehaald zijn...
                 // ItemsNeeded: item_id => aantal_needed
                 $characterInventories = $Inventory->find('all', array('conditions' => array('Inventory.character_id' => $quest['CharactersQuest']['character_id'], 'Inventory.item_id' => $itemList), 'fields' => array('Inventory.item_id', 'COUNT(Inventory.item_id) as amount'), 'group' => array('Inventory.item_id')));
                 // Er zijn mobs nodig voor deze quest. Kijken of ze gekilled zijn NADAT de quest is geaccepteerd...
                 $characterKills = $Kill->find('all', array('conditions' => array('Kill.character_id' => $quest['CharactersQuest']['character_id'], 'Kill.mob_id' => $mobList, 'Kill.type' => 'mob', 'Kill.created >=' => $quest['CharactersQuest']['created']), 'fields' => array('Kill.mob_id', 'COUNT(Kill.target_id) as amount'), 'group' => array('Kill.target_id')));
                 // We hebben een lijst met items wat nodig is..
                 // En dit wordt een lijst met wat we hebben...
                 $itemsHave = array();
                 foreach ($characterInventories as $characterInventory) {
                     $itemsHave[$characterInventory['Inventory']['item_id']] = $characterInventory[0]['amount'];
                 }
                 // Opslaan yes/no of de quest compleet is...
                 foreach ($itemsNeeded as $item_id => $amount) {
                     if (!isset($itemsHave[$item_id]) || isset($itemsHave[$item_id]) && $itemsHave[$item_id] < $itemsNeeded[$item_id]) {
                         $completed = 'no';
                     }
                 }
                 // We hebben nu een lijst met mobs die nodig zijn, en een lijst met kills
                 $mobsHave = array();
                 foreach ($characterKills as $characterKill) {
                     $mobsHave[$characterKill['Kill']['mob_id']] = $characterKill[0]['amount'];
                 }
                 // Opslaan yes/no of de quest compleet is...
                 foreach ($mobsNeeded as $mob_id => $amount) {
                     if (!isset($mobsHave[$mob_id]) || isset($mobsHave[$mob_id]) && $mobsHave[$mob_id] < $mobsNeeded[$mob_id]) {
                         $completed = 'no';
                     }
                 }
                 // Maybe the character is turning in the quest...
                 if ($completed == 'yes' && $turnIn == true && isset($character_id) && isset($quest_id)) {
                     $completed = 'finished';
                 }
                 // Als de quest 'finished' is, dan moeten eventuele items uit de inventory verwijderd worden...
                 // Dat kan hier.
                 if ($completed == 'finished' && !empty($itemsNeeded)) {
                     foreach ($itemsNeeded as $item_id => $amount) {
                         for ($j = 1; $j <= $amount; $j++) {
                             $Inventory->deleteAll(array('Inventory.character_id' => $quest['CharactersQuest']['character_id'], 'Inventory.item_id' => $item_id));
                         }
                     }
                 }
                 $charactersQuestsData[$i]['completed'] = $completed;
             }
             // En voor het mooi, natuurlijk ook even de rewards geven...
             if ($completed == 'finished' && !empty($itemsRewards)) {
//.........这里部分代码省略.........
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:101,代码来源:quest.php


注:本文中的Inventory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。