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


PHP Item::where方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     $folderpath = base_path() . '/database/seeds/templates/';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", str_replace('\\', '/', $value));
         $cnt = count($_dir);
         $name = $_dir[$cnt - 1];
         $latest_date = DateTime::createFromFormat('mdY', $latest);
         $now = DateTime::createFromFormat('mdY', $name);
         if ($now > $latest_date) {
             $latest = $name;
         }
     }
     $filePath = $folderpath . $latest . '/Masterfile.xlsx';
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $reader->open($filePath);
     DB::table('channel_items')->truncate();
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'MKL Mapping') {
             $cnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($row[0] != '') {
                     if ($cnt > 0) {
                         // dd($row);
                         if (!ctype_digit(trim($row[4])) || !ctype_digit(trim($row[5])) || !ctype_digit(trim($row[6]))) {
                             InvalidMapping::create(['premise_code' => trim($row[0]), 'customer_code' => trim($row[1]), 'store_code' => trim($row[2]), 'sku_code' => trim($row[3]), 'ig' => trim($row[4]), 'multiplier' => trim($row[5]), 'minstock' => trim($row[6]), 'type' => 'MKL Mapping', 'remarks' => 'Invalid mapping']);
                         } else {
                             $channel = '';
                             if (trim($row[0]) != '') {
                                 $channel = Channel::where('channel_code', trim($row[0]))->first();
                             }
                             $item = Item::where('sku_code', trim($row[3]))->first();
                             if (!empty($item)) {
                                 $item_type = ItemType::where('type', "MKL")->first();
                                 $osa_tagging = 0;
                                 if (isset($row[7])) {
                                     $osa_tagging = trim($row[7]);
                                 }
                                 $npi_tagging = 0;
                                 if (isset($row[8])) {
                                     $npi_tagging = trim($row[8]);
                                 }
                                 ChannelItem::firstOrCreate(['channel_id' => $channel->id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => $osa_tagging, 'npi_tagged' => $npi_tagging]);
                             }
                         }
                     }
                     $cnt++;
                 }
             }
         }
     }
     $reader->close();
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:64,代码来源:UploadChannelItemsTableSeeder.php

示例2: run

 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     $folderpath = base_path() . '/database/seeds/seed_files/';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", str_replace('\\', '/', $value));
         $cnt = count($_dir);
         $name = $_dir[$cnt - 1];
         $latest_date = DateTime::createFromFormat('mdY', $latest);
         $now = DateTime::createFromFormat('mdY', $name);
         if ($now > $latest_date) {
             $latest = $name;
         }
     }
     $filePath = $folderpath . $latest . '/Masterfile.xlsx';
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $reader->open($filePath);
     echo 'Seeding ' . $filePath . PHP_EOL;
     // DB::table('other_barcodes')->truncate();
     Item::where('active', 1)->update(['cleared' => 0]);
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Other Codes') {
             $cnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if (!is_null($row[0]) && trim($row[0]) != '') {
                     if ($cnt > 0) {
                         $item = Item::where('sku_code', trim($row[0]))->first();
                         if (!empty($item)) {
                             if ($item->cleared == 0) {
                                 OtherBarcode::where('item_id', $item->id)->delete();
                                 $item->cleared = 1;
                                 $item->save();
                             }
                             $area = Area::where('area', strtoupper($row[1]))->first();
                             if (!empty($item) && !empty($area)) {
                                 OtherBarcode::firstOrCreate(['item_id' => $item->id, 'area_id' => $area->id, 'other_barcode' => trim($row[2])]);
                             }
                         } else {
                             // dd($row);
                         }
                     }
                     $cnt++;
                 }
             }
         }
     }
     $reader->close();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:54,代码来源:UploadOtherBarcodesTableSeeder.php

示例3: run

 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     $folderpath = base_path() . '/database/seeds/seed_files/';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", str_replace('\\', '/', $value));
         $cnt = count($_dir);
         $name = $_dir[$cnt - 1];
         $latest_date = DateTime::createFromFormat('mdY', $latest);
         $now = DateTime::createFromFormat('mdY', $name);
         if ($now > $latest_date) {
             $latest = $name;
         }
     }
     $filePath = $folderpath . $latest . '/Masterfile.xlsx';
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $reader->open($filePath);
     // DB::table('store_items');
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Assortment Mapping') {
             $cnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($row[0] != '') {
                     if ($cnt > 0) {
                         if (!ctype_digit(trim($row[4]))) {
                             InvalidMapping::create(['premise_code' => trim($row[0]), 'customer_code' => trim($row[1]), 'store_code' => trim($row[2]), 'sku_code' => trim($row[3]), 'ig' => trim($row[4]), 'multiplier' => trim($row[5]), 'minstock' => trim($row[6]), 'type' => 'Assortment Mapping', 'remarks' => 'Invalid mapping']);
                         } else {
                             $channel = '';
                             $customer = '';
                             $store = '';
                             if (trim($row[0]) != '') {
                                 $channel = Channel::where('channel_code', trim($row[0]))->get();
                             }
                             if (trim($row[1]) != '') {
                                 $customer = Customer::where('customer_code', trim($row[1]))->get();
                             }
                             if (trim($row[2]) != '') {
                                 $store = Store::where('store_code', trim($row[2]))->first();
                             }
                             // dd($store);
                             $stores = Store::where(function ($query) use($channel) {
                                 if (!empty($channel)) {
                                     $channel_id = [];
                                     foreach ($channel as $value) {
                                         $channel_id[] = $value->id;
                                     }
                                     $query->whereIn('channel_id', $channel_id);
                                 }
                             })->where(function ($query) use($customer) {
                                 if (!empty($customer)) {
                                     $customer_id = [];
                                     foreach ($customer as $value) {
                                         $customer_id[] = $value->id;
                                     }
                                     $query->whereIn('customer_id', $customer_id);
                                 }
                             })->where(function ($query) use($store) {
                                 if (!empty($store)) {
                                     $query->where('store', $store->id);
                                 }
                             })->get();
                             // dd($stores);
                             $item = Item::where('sku_code', trim($row[3]))->first();
                             if (!empty($item)) {
                                 $item_type = ItemType::where('type', "ASSORTMENT")->first();
                                 foreach ($stores as $store) {
                                     $w_mkl = StoreItem::where('store_id', $store->id)->where('item_id', $item->id)->get();
                                     $cw_mkl = ChannelItem::where('channel_id', $store->channel_id)->where('item_id', $item->id)->get();
                                     if (count($w_mkl) == 0) {
                                         StoreItem::firstOrCreate(['store_id' => $store->id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => 0, 'npi_tagged' => 0]);
                                     }
                                     if (count($cw_mkl) == 0) {
                                         ChannelItem::firstOrCreate(['channel_id' => $store->channel_id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => 0, 'npi_tagged' => 0]);
                                     }
                                 }
                             }
                         }
                     }
                     $cnt++;
                 }
             }
         }
     }
     $reader->close();
     $hash = UpdateHash::find(1);
     if (empty($hash)) {
         UpdateHash::create(['hash' => \Hash::make(date('Y-m-d H:i:s'))]);
     } else {
         $hash->hash = md5(date('Y-m-d H:i:s'));
         $hash->update();
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:98,代码来源:UploadAssortmentTableSeeder.php

示例4: viewAll

 public function viewAll()
 {
     $error = \Session::get('error');
     $messages = \Session::get('messages');
     $items = Item::where('active', Constants::ACTIVE)->get();
     return view('items.viewAll', ['items' => $items, 'error' => $error, 'messages' => $messages]);
 }
开发者ID:totomakers,项目名称:lutin-manager,代码行数:7,代码来源:ItemController.php

示例5: siblings

 /**
  *
  * @return mixed
  */
 public function siblings()
 {
     if (!$this->parent) {
         return Item::forCurrentUser()->whereNull('parent_id')->where('id', '!=', $this->id)->get();
     }
     return Item::where('parent_id', $this->parent_id)->where('id', '!=', $this->id)->get();
 }
开发者ID:JennySwift,项目名称:lists,代码行数:11,代码来源:Item.php

示例6: get_item_by_category

 public function get_item_by_category(Request $request)
 {
     if ($request->ajax()) {
         $category_id = $request->input('category_id');
         $iteminfo = Item::where('itemssubgroupid', $category_id)->get();
         return response()->json($iteminfo);
     }
 }
开发者ID:richardkeep,项目名称:prct,代码行数:8,代码来源:PurchaseController.php

示例7: duplicateField

 /**
  * Count duplicate fields
  * If check is done while updating data then check except this id
  *
  * @param string $field_name
  * @param array $fields
  * @return int
  */
 public function duplicateField($field_name, $fields)
 {
     $field_count = Item::where($field_name, $fields['name']);
     if (!empty($fields['item_id'])) {
         $field_count = $field_count->where('id', '!=', $fields['item_id']);
     }
     $field_count = $field_count->count();
     return $field_count;
 }
开发者ID:sabihk,项目名称:soft,代码行数:17,代码来源:Item.php

示例8: delete

 public function delete(Request $request, $banqueId, $itemId)
 {
     // verify request inputs
     if (is_null($itemId)) {
         return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
     } else {
         $item = Item::where('id_Item', '=', $itemId)->delete();
         return is_null($item) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $item;
     }
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:10,代码来源:ItemController.php

示例9: add

 public function add($itemId)
 {
     //   Cart::add(455, 'Sample Item', 100.99, 2, array());
     /* 取得商品信息 */
     $item = Item::where('id', '=', $itemId)->first();
     //   var_dump($item);exit;
     /* 初始化要插入购物车的基本件数据 */
     $parent = array('user_id' => Auth::id(), 'goods_id' => $itemId, 'sku' => $item['sku'], 'item_name' => addslashes($item['name']), 'price' => $item['price']);
     Cart::add($itemId, addslashes($item['name']), $item['price'], '1', array());
     return redirect()->route('cart.index');
 }
开发者ID:cdandy,项目名称:artup,代码行数:11,代码来源:CartController.php

示例10: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     set_time_limit(0);
     ini_set('memory_limit', -1);
     $updated_igs = UpdatedIg::all();
     foreach ($updated_igs as $row) {
         $store = Store::where('store_code', $row->store_code)->first();
         if (!empty($store)) {
             $item = Item::where('sku_code', $row->sku_code)->first();
             if (!empty($item)) {
                 StoreItem::where('store_id', $store->id)->where('item_id', $item->id)->update(['ig' => $row->ig, 'ig_updated' => 1]);
             }
         }
     }
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:20,代码来源:UpdateStoreItemIgTableSeeder.php

示例11: getDocumentItems

 public function getDocumentItems(Request $request)
 {
     $id = $request->get('document_id');
     $document = \App\Models\Document::find($id);
     $items = \App\Models\Item::where('document_id', '=', $id);
     if (Auth::user()->username == '1-0275071849') {
         $datatables = Datatables::of($items)->addColumn('action', function ($item) {
             return '<a href="/item/' . $item->id . '" class="actions icons"><i class="fa fa-eye"></i></a>';
         });
     } else {
         $datatables = Datatables::of($items)->addColumn('action', function ($item) {
             return '<a href="/item/' . $item->id . '" class="actions icons"><i class="fa fa-eye"></i></a><a href="/item/' . $item->id . '/edit" class="actions icons"><i class="fa fa-pencil-square-o"></i></a><a href="/item/destroy/' . $item->id . '" class="actions icons"><i class="fa fa-trash"></i></a>';
         });
     }
     return $datatables->make(true);
 }
开发者ID:alexsynarchin,项目名称:Itnk5,代码行数:16,代码来源:ItemController.php

示例12: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('updated_igs', function (Blueprint $table) {
         $table->string('area')->after('id');
         $table->string('region_code')->after('area');
         $table->string('region')->after('region_code');
         $table->string('distributor_code')->after('region');
         $table->string('distributor')->after('distributor_code');
         $table->string('agency_code')->after('distributor');
         $table->string('agency')->after('agency_code');
         $table->string('storeid')->after('agency');
         $table->string('channel_code')->after('store_name');
         $table->string('channel')->after('channel_code');
         $table->string('other_code')->after('channel');
     });
     set_time_limit(0);
     ini_set('memory_limit', -1);
     $updated_igs = UpdatedIg::all();
     foreach ($updated_igs as $updated_ig) {
         $store = Store::where('store_code', $updated_ig->store_code)->first();
         $item = Item::where('sku_code', $updated_ig->sku_code)->first();
         if (!empty($store) && !empty($item)) {
             $other_code = OtherBarcode::where('item_id', $item->id)->where('area_id', $store->area->id)->first();
             $updated_ig->area = $store->area->area;
             $updated_ig->region_code = $store->region->region_code;
             $updated_ig->region = $store->region->region;
             $updated_ig->distributor_code = $store->distributor->distributor_code;
             $updated_ig->distributor = $store->distributor->distributor;
             $updated_ig->agency_code = $store->agency->agency_code;
             $updated_ig->agency = $store->agency->agency_name;
             $updated_ig->storeid = $store->storeid;
             $updated_ig->channel_code = $store->channel->channel_code;
             $updated_ig->channel = $store->channel->channel_desc;
             if (!empty($other_code)) {
                 $updated_ig->other_code = $other_code->other_barcode;
             }
             $updated_ig->update();
         }
     }
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:45,代码来源:2016_05_16_145132_add_area_on_updated_igs_table.php

示例13: run

 public function run()
 {
     $divisions = ['HPC CATEGORY', 'FOODS CATEGORY'];
     $inventories = ItemInventories::whereNotIn('division', $divisions)->get();
     foreach ($inventories as $inventory) {
         $item = Item::where('sku_code', $inventory->sku_code)->first();
         $inventory->division = $item->division->division;
         $inventory->category = $item->category->category;
         $inventory->category_long = $item->category->category_long;
         $inventory->sub_category = $item->subcategory->sub_category;
         $inventory->brand = $item->brand->brand;
         $inventory->update();
     }
     $asinventories = AssortmentItemInventories::whereNotIn('division', $divisions)->get();
     foreach ($asinventories as $inventory) {
         $item = Item::where('sku_code', $inventory->sku_code)->first();
         $inventory->division = $item->division->division;
         $inventory->category = $item->category->category;
         $inventory->category_long = $item->category->category_long;
         $inventory->sub_category = $item->subcategory->sub_category;
         $inventory->brand = $item->brand->brand;
         $inventory->update();
     }
 }
开发者ID:renciebautista,项目名称:pcount2,代码行数:24,代码来源:FixWrongDivisionTableSeeder.php

示例14: getItems

 public function getItems($banqueId)
 {
     return Item::where('id_Banque', '=', $banqueId)->get();
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:4,代码来源:GestSession.php

示例15: search

 public function search(Request $request)
 {
     $items = Item::where('nombre_item', 'like', '%' . $request->nombre . '%')->get();
     return \View::make('list_item', compact('items'));
 }
开发者ID:Bienestar-Group,项目名称:Bienestar,代码行数:5,代码来源:ItemController.php


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