本文整理汇总了PHP中app\models\Item::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::select方法的具体用法?PHP Item::select怎么用?PHP Item::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Item
的用法示例。
在下文中一共展示了Item::select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: items
public function items()
{
$fileName = "Items Mastefile.csv";
$writer = WriterFactory::create(Type::CSV);
// for CSV files
$writer->openToBrowser($fileName);
// stream data directly to the browser
$writer->addRow(array('Category Long Description', 'Category Short Description', 'SKU Code', 'Barcode', 'Item Short Description', 'Item Long Description', 'Conversion', 'Sub Category', 'Brand', 'Division', 'LPBT/Cond Value (PC)', 'Status'));
$items = Item::select(\DB::raw('category_long, category, sku_code, barcode, description,
description_long, conversion, sub_category, brand, division, lpbt, items.active'))->join('categories', 'categories.id', '=', 'items.category_id')->join('sub_categories', 'sub_categories.id', '=', 'items.sub_category_id')->join('brands', 'brands.id', '=', 'items.brand_id')->join('divisions', 'divisions.id', '=', 'items.division_id')->get();
$pluckdata = [];
foreach ($items as $item) {
$data[0] = $item->category_long;
$data[1] = $item->category;
$data[2] = $item->sku_code;
$data[3] = $item->barcode;
$data[4] = $item->description;
$data[5] = $item->description_long;
$data[6] = $item->conversion;
$data[7] = $item->sub_category;
$data[8] = $item->brand;
$data[9] = $item->division;
$data[10] = $item->lpbt;
if ($item->active == '1') {
$data[11] = 'Active';
} else {
$data[11] = 'In-active';
}
$pluckdata[] = $data;
}
$writer->addRows($pluckdata);
// add multiple rows at a time
$writer->close();
}
示例2: item_data
public function item_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$items = Item::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'name']);
return Datatables::of($items)->addColumn('action', function ($item) {
return '<a href="./item/edit/' . $item->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})->make(true);
}
示例3: itemDetails
/**
* Fetch item details
* If item_id is provided then details of only that item will be fetched
* Else complete list will be retrieved
*
* @param null $item_id
* @return object
*/
public function itemDetails($item_id = NULL)
{
$item = Item::select('id', 'name', 'unit', 'rate', 'tax_id', 'description');
if (!is_null($item_id)) {
$item = $item->where('id', $item_id)->first();
}
return $item;
}
示例4: autocomplete
/**
* Get matching items for autocompletion stuff
*
* @return array
*/
public function autocomplete()
{
// Request data
$query = $this->getInput('q');
$language = $this->requestedLanguage();
// No search for too short queries
if (strlen($query) < 3) {
return $this->apiResponse([], 2678400);
}
// Return the items that match the search query
$matching = Item::select(['id', 'name_' . $language . ' AS name', 'image', 'rarity', 'level'])->where('name_' . $language, 'LIKE', '%' . $query . '%')->take(25)->get()->toArray();
return $this->apiResponse($matching, 86400);
}
示例5: getItemData
public function getItemData()
{
$obj = new Item();
$cols = $obj->current_columns();
$item = Item::select(array('items.id', 'items.measure', 'vendors.name', 'items.date', 'items.container', 'items.receive'))->join('vendors', 'items.vendor_id', '=', 'vendors.id');
return Datatables::of($item)->make(true);
}
示例6: resolveItemsBySkinName
private function resolveItemsBySkinName($skins)
{
$skinName = function ($skin) {
return $skin . ' Skin';
};
// Grab the names of the remaining skins
$names = array_map($skinName, array_pluck($skins, 'name'));
// Try to find them
$name_items = Item::select('name_en', DB::raw("GROUP_CONCAT(DISTINCT id SEPARATOR ',') AS items"))->whereIn('name_en', $names)->groupBy('name_en')->lists('items', 'name_en');
foreach ($skins as &$skin) {
$name = $skinName($skin['name']);
if (!isset($name_items[$name])) {
continue;
}
$skin_items = explode(',', $name_items[$name]);
if (isset($skin['items'])) {
$skin['items'] = array_merge($skin['items'], $skin_items);
} else {
$skin['items'] = $skin_items;
}
}
$this->info('Resolved ' . count($name_items) . ' skins by skin name lookup...');
return $skins;
}