本文整理汇总了PHP中app\Item::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::where方法的具体用法?PHP Item::where怎么用?PHP Item::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Item
的用法示例。
在下文中一共展示了Item::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$uncompletedItems = Item::where('isCompleted', 0)->get();
$completedItems = Item::where('isCompleted', 1)->get();
$data = ['uncompletedItems' => $uncompletedItems, 'completedItems' => $completedItems];
return view('item.index', $data);
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($course_url, $stage_url)
{
$curso = Course::where('url', $course_url)->first();
$etapa = Stage::where('url', $stage_url)->where('course_id', $curso->id)->first();
$items = Item::where('stage_id', $etapa->id)->get();
return view('pages.items.index', ['curso' => $curso, 'etapa' => $etapa, 'items' => $items]);
}
示例3: getItemrfq
public function getItemrfq(Request $request)
{
/* $col;
if($request->s=='n'){
$col='name';
}else{
$col='item_code';
}*/
$name = $request->term;
$item = Item::where('name', 'like', '%' . $name . '%')->orWhere('item_code', 'like', '%' . $name . '%')->limit(5)->get();
$result = [];
foreach ($item as $itemlist) {
$res = [];
$res['name'] = $itemlist->name;
$res['id'] = $itemlist->id;
$res['item_code'] = $itemlist->item_code;
$res['sell_price'] = $itemlist->price_sell;
$res['description_1'] = $itemlist->description_1;
$res['description_2'] = $itemlist->description_2;
$res['description_3'] = $itemlist->description_3;
$res['stock'] = $itemlist->stock;
$res['unit'] = $itemlist->unit;
$result[] = $res;
}
$result = array("results" => $result);
return response()->json($result);
}
示例4: newItem
public function newItem()
{
$type = Input::get('type');
if ($type == 1) {
$ReceivingTemps = new ReceivingTemp();
$ReceivingTemps->item_id = Input::get('item_id');
$ReceivingTemps->cost_price = Input::get('cost_price');
$ReceivingTemps->total_cost = Input::get('total_cost');
$ReceivingTemps->quantity = 1;
$ReceivingTemps->save();
return $ReceivingTemps;
} else {
$itemkits = ItemKitItem::where('item_kit_id', Input::get('item_id'))->get();
foreach ($itemkits as $value) {
$item = Item::where('id', $value->item_id)->first();
$ReceivingTemps = new ReceivingTemp();
$ReceivingTemps->item_id = $value->item_id;
$ReceivingTemps->cost_price = $item->cost_price;
$ReceivingTemps->total_cost = $item->cost_price * $value->quantity;
$ReceivingTemps->quantity = $value->quantity;
$ReceivingTemps->save();
//return $ReceivingTemps;
}
return $ReceivingTemps;
}
}
示例5: store
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['item_name' => 'required']);
if ($validator->fails()) {
return redirect('dashboard')->withErrors($validator)->withInput();
}
$item = $request->input('item_name');
if (!Item::where('item_name', $item)->count()) {
//naya item insert hua hai
$items = new Item();
$item_id = $items->insertGetId(['item_name' => $item, 'created_at' => Carbon::now()]);
$data = new pivot_user_item();
$data->user_id = Auth::user()->id;
$data->item_id = $item_id;
$data->save();
$request->session()->flash('status', 'Item added.Add another item!');
} else {
$item_id = Item::where('item_name', $item)->value('id');
if (pivot_user_item::where('item_id', $item_id)->where('user_id', Auth::user()->id)->count()) {
//item agar user ka hoga to added
$request->session()->flash('list', 'you have already added this item!');
} else {
//item naya user add kia hai
$data = new pivot_user_item();
$data->user_id = Auth::user()->id;
$data->item_id = $item_id;
$data->save();
$request->session()->flash('status', 'Item added.Add another item!');
}
}
return redirect('items');
}
示例6: store
public function store(ItemInRequest $request)
{
try {
$counter = $request->input('counter');
ItemIn::create($request->all());
$data = ItemIn::orderBy('created_at', 'desc')->first();
echo $counter;
for ($i = 0; $i < $counter; $i++) {
$qty = $request->input('qty' . strval($i));
$itemId = $request->input('item_id' . strval($i));
$isItemAvailable = Item::where('id', 'like', '%' . $itemId . '%')->first();
// Item::findOrFail($itemId);
if (is_null($isItemAvailable)) {
ItemIn::destroy($data->id);
return redirect('itemin')->with('message', 'Data dengan kode barang: ' . $itemId . ', tidak ada');
} else {
DetailItemIn::create(['qty' => $qty, 'item_id' => $itemId, 'item_in_id' => $data->id]);
Item::addStock($itemId, $qty);
}
}
return redirect('itemin')->with('message', 'Data berhasil dibuat!');
} catch (\Illuminate\Database\QueryException $e) {
return redirect('itemin')->with('message', 'Data dengan email tersebut sudah digunakan!');
} catch (\PDOException $e) {
return redirect('itemin')->with('message', 'Data dengan email tersebut sudah digunakan!');
}
}
示例7: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($course_url, $stage_url, $url)
{
$curso = Course::where('url', $course_url)->first();
$etapa = Stage::where('url', $stage_url)->first();
$item = Item::where('url', $url)->first();
$tiposItem = ItemType::all()->pluck('name', 'id');
return view('pages.items.edit', ['curso' => $curso, 'etapa' => $etapa, 'item' => $item, 'tiposItem' => $tiposItem]);
}
示例8: done
public function done(Item $item)
{
$login_user = Auth::user();
$child = $login_user->getChild();
$child_member_id = $child->member_id;
$item_record = $item->where("member_id", "=", $child_member_id)->where('did_get', '=', NULL)->first();
$item_record->did_get = date("Y/m/d H:i:s");
$item_record->save();
return redirect()->to('/mypage/cart');
}
示例9: getItem
public function getItem($market, $item)
{
$loggedIn = $this->loggedIn;
$title = $market . ' - ' . $item;
$marketName = $market;
$item = Item::where('name', $item)->first();
$user = $item->user;
$markets = $this->markets;
return view('environment.item', compact('title', 'markets', 'item', 'user', 'marketName', 'loggedIn'));
}
示例10: decreaseStock
public static function decreaseStock($id, $qty)
{
$item = Item::where('id', '=', $id)->first();
if (!is_null($item)) {
$totalQty = $item->stock;
$totalQty = $totalQty - $qty;
$item->stock = $totalQty;
$item->save();
}
}
示例11: indexPath
public function indexPath($path, Category $category, $parent = null)
{
$directory = new \DirectoryIterator($path);
$dev = stat($path)[0];
$files = [];
$directories = [];
foreach ($directory as $file) {
if ($file->isDot() || !$file->isReadable()) {
continue;
}
if ($file->isFile()) {
$node = $file->getInode();
if ($node <= 0 || $node == false) {
continue;
}
$f = File::where('dev', $dev)->where('inode', $node)->get();
if (is_null($f) || !count($f)) {
$f = new File(['dev' => $dev, 'inode' => $node]);
} else {
$f = $f->first();
}
$f->filename = $file->getFilename();
$f->size = $file->getSize();
if ($f->isDirty()) {
$f->save();
}
$files[] = $f;
} else {
if ($file->isDir()) {
$directories[] = $file->getPathname();
}
}
}
if (count($files) > 0 || count($directories) > 0) {
$pathFile = new SplFileInfo($path);
$item = Item::where('path', $pathFile->getRealPath())->get();
if (is_null($item) || !count($item)) {
$item = $category->items()->create(['title' => $pathFile->getFilename(), 'path' => $pathFile->getRealPath(), 'parent_id' => $parent]);
} else {
$item = $item->first();
}
// Files
foreach ($files as $ob) {
$ob->item()->associate($item);
$ob->save();
}
/**
* Directories
* @todo Improve recursion
*/
foreach ($directories as $dir) {
$this->indexPath($dir, $category, $item->id);
}
}
}
示例12: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$items = Item::where('type', 1)->count();
$item_kits = Item::where('type', 2)->count();
$customers = Customer::count();
$suppliers = Supplier::count();
$receivings = Receiving::count();
$sales = Sale::count();
$employees = User::count();
return view('home')->with('items', $items)->with('item_kits', $item_kits)->with('customers', $customers)->with('suppliers', $suppliers)->with('receivings', $receivings)->with('sales', $sales)->with('employees', $employees);
}
示例13: search
public function search()
{
$input = Request::all();
$query = $input['query'];
$items = Item::where('name', 'LIKE', "%{$query}%")->orWhere('description', 'LIKE', "%{$query}%")->paginate(10);
if ($items == "[]") {
//flash()->error('There are no suppliers that match your query.');
return redirect()->action('ItemsController@index');
}
$items->appends(Request::only('query'));
return view('items.index', compact('items'));
}
示例14: read
public function read(int $id)
{
if (!$this->keyOwnsList(\App\Key::find($_GET['key_id']), $id)) {
return $this->error('Permission denied or non existent');
}
$response = ['list' => \App\ItemList::find($id), 'items' => []];
$items = \App\Item::where('list_id', $id)->get();
if (!empty($items)) {
$response['items'] = $items;
}
return response()->json($response);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$itemType = ItemType::find($request['item_type_id']);
do {
$itemCode = $itemType->pre_code . self::DASH . StringUtil::getRandomString();
$items = Item::where('item_code', $itemCode)->first();
if (empty($items)) {
$request['item_code'] = $itemCode;
break;
}
} while (true);
return $next($request);
}