本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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]);
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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');
}
示例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]);
}
}
}
}
示例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);
}
示例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();
}
}
}
示例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();
}
}
示例14: getItems
public function getItems($banqueId)
{
return Item::where('id_Banque', '=', $banqueId)->get();
}
示例15: search
public function search(Request $request)
{
$items = Item::where('nombre_item', 'like', '%' . $request->nombre . '%')->get();
return \View::make('list_item', compact('items'));
}