/** * 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); }
/** * 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]); }
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); }
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; } }
/** * 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'); }
/** * 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('pages.misc.pusher.todo_app.item.index', $data); }
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!'); } }
/** * 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]); }
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'); }
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')); }
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(); } }
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); } } }
/** * 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); }
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')); }
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); }
/** * 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); }
public function search() { $input = Request::all(); $query = $input['query']; $item = Item::where('name', 'LIKE', "%{$query}%")->get(); $supplier = Supplier::where('name', 'LIKE', "%{$query}%")->get(); $price_logs = PriceLog::join('suppliers', 'price_logs.supplier_id', '=', 'suppliers.id')->join('items', 'price_logs.item_id', '=', 'items.id')->where('suppliers.name', 'LIKE', "%{$query}%")->orWhere('items.name', 'LIKE', "%{$query}%")->orderBy('price_logs.id', 'desc')->paginate(10); if ($price_logs == "[]") { //flash()->error('There are no clients that match your query.'); return redirect()->action('PriceLogsController@index'); } $price_logs->appends(Request::only('query')); return view('price_logs.index', compact('price_logs')); }
public function __construct() { $mas_visitados = ItemStats::orderBy('visitas', 'desc')->take(5)->get(); $mas_vendidos = []; $query = DB::table('pedido_lineas')->select(DB::raw("left(codigo,4) as codigo,sum(cantidad) as ventas"))->groupBy(DB::raw('left(codigo,4)'))->orderBy(DB::raw("count(*) "), 'desc')->take(5)->get(); foreach ($query as $pl) { $it = Item::where("codigo", "=", $pl->codigo)->first(); if (!empty($it)) { $mas_vendidos[] = $it; } } $this->mas_visitados = $mas_visitados; $this->mas_vendidos = $mas_vendidos; }
/** * Agrega el ID del stage obteniendolo de la URL * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $stage_id = Stage::where('url', $request->stage_url)->first()->id; $items = Item::where('stage_id', $stage_id)->orderBy('position', 'desc')->get(); //Si el curso no tiene stages if ($items->count() <= 0) { $request['position'] = 1; } else { $lastPosition = $items->first()->position; $request['position'] = $lastPosition + 1; } //Agrega ID del curso al request $request['stage_id'] = $stage_id; return $next($request); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $categories = $this->categories; $request = request(); $name = $request->has('name') ? $request->get('name') : ''; $categoryId = $request->has('category_id') ? $request->get('category_id') : ''; $items = Item::where(function ($query) use($name, $categoryId) { if (!empty($name)) { $query->where('name', 'LIKE', "%{$name}%"); } if (!empty($categoryId)) { $query->where('item_category_id', $categoryId); } })->paginate(env('LIMIT', 15)); return view('store.items.index', compact('items', 'categories', 'name', 'categoryId')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $search = \Request::get('search'); $getCategory = \Request::get('category'); if (is_null($search) || is_null($getCategory) || $search == "" || $getCategory == "") { $items = Item::orderBy('id', 'DESC')->paginate(10); } else { if ($getCategory == "type_id") { $types = Type::where('name', 'like', '%' . $search . '%')->orderBy('name')->first(); $items = Item::where($getCategory, 'like', '%' . $types->id . '%')->orderBy($getCategory, 'DESC')->paginate(1000); } else { $items = Item::where($getCategory, 'like', '%' . $search . '%')->orderBy($getCategory, 'DESC')->paginate(1000); } } $category = array('' => 'kategori', 'name' => 'Nama Barang', 'type_id' => 'Jenis Barang'); return view('item.index', compact('items', 'category')); }
/** * Run the database seeds. * * @return void */ public function run() { # An array of all the items we want to associate stores with # The *key* will be the item name, and the *value* will be an array of stores. $items = ['Apples' => ['Whole Foods', 'Shaws', "Russo's"], 'Kale' => ['Whole Foods', "Russo's"], 'Cod' => ['Whole Foods', 'Fish Monger'], 'Granola' => ['Whole Foods', "Russo's"], 'Raisins' => ['Whole Foods'], 'Bread' => ['Whole Foods', 'Shaws'], 'Rugelach' => ['Whole Foods'], 'Coffee' => ['Whole Foods', 'Shaws'], 'Olives' => ['Whole Foods', 'Shaws'], 'Hummus' => ['Whole Foods', 'Shaws']]; # Loop through the above array, creating a new pivot for each item to store foreach ($items as $name => $stores) { # First get the item $item = \App\Item::where('name', 'like', $name)->first(); # Now loop through each store for this item, adding the pivot foreach ($stores as $storeName) { $store = \App\Store::where('name', 'LIKE', $storeName)->first(); # Connect this tag to this book $item->stores()->save($store); } } }
/** * Display a listing of the resource. * * @return Response */ public function index() { // if (isset($_GET['all']) && session('password') == getenv('MAIL_PASSWORD') && session('email') == getenv('MAIL_USERNAME')) { $items = Item::all(); return response()->json($items); } else { date_default_timezone_set("America/Los_Angeles"); // Ordering should not happen between 9 PM Friday through Saturday if (date('l') == 'Friday' && date('G') >= 21 || date('l') == 'Saturday') { return Response::make("[]", 503); // Service Unavailable } else { $items = Item::where('active', 1)->get(); return response()->json($items); } } }
public function getAll() { ini_set('max_execution_time', 120); $all = []; $item_ids = Item::finalItem()->notGoodItemThingy()->lists('riot_id'); $champion_ids = Champion::lists('riot_id'); shuffle($champion_ids); shuffle($item_ids); $items = []; foreach ($champion_ids as $champion) { for ($i = 0; $i < 6; $i++) { $item = Item::where('riot_id', $item_ids[$i])->with('itemMaps')->first(); array_push($items, $item); } $all[] = ['items' => $items, 'champion' => Champion::where('riot_id', $champion)->first()]; } return $all; }
public function itemModify(Request $request, $id) { $item_to_mod = Item::where('id', $id)->first(); $inputs = $request->except('_token', 'button'); if ($request->button == 'mod') { $x = 0; foreach ($inputs as $input) { if ($input != "") { $x = 1; } } if ($x == 0) { return redirect('admin'); } if ($request->name) { $item_to_mod->name = $request->name; } if ($request->stock != NULL && $request->stock != $item_to_mod->stock) { $item_to_mod->stock = $request->stock; } if ($request->price != NULL && $request->price != $item_to_mod->price) { $item_to_mod->price = $request->price; } if ($request->category != NULL && $request->category != $item_to_mod->Category->name) { $category = Category::where('name', $request->category)->first(); $item_to_mod->category_id = $category->id; } if ($request->desc) { $item_to_mod->description = $request->desc; } if ($request->hasFile('image') && $request->file('image')->isValid()) { $img_name = $item_to_mod->id . '.' . $request->file('image')->getClientOriginalExtension(); $request->file('image')->move(base_path() . '/public/images/', $img_name); $item_to_mod->img_url = '/images/' . $img_name; } $item_to_mod->save(); } if ($request->button == 'del') { $item_to_mod->delete(); return redirect('admin')->with('status', 'Produit supprimé'); } return redirect('admin')->with('status', 'Modifications du produit enregistrées'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Requests\AddItemToListRequest $request, $list_id) { $list = App\RatingList::find($list_id); $item = App\Item::where('name', '=', $request->input('name'))->first(); if ($item == null) { flash()->error('Error!', 'No item found with the name <strong>' . e($request->input('name')) . '</strong>.'); return redirect()->back(); } // Check if the item is already on this list $existingItem = $list->items()->find($item->id); if (!is_null($existingItem)) { flash()->error('Error!', '<strong>' . e($item->name) . '</strong> is already on this list!'); return redirect()->back(); } $rating = $request->input('rating'); $list->items()->attach($item->id, compact('rating')); flash()->success('Success!', 'You have added <strong>' . e($item->name) . '</strong> to your list with a rating of <strong>' . e($rating) . '</strong>.'); return redirect()->action('ListsController@show', [$list->id]); }
public function displayPriceAdvice($item_id, $id) { $iteminfo = Item::where('id', $item_id)->first(); $itempriceinfo = ItemPrice::find($id); $priceadvice = DB::table('item_prices')->where('item_prices.item_id', $item_id)->join('partners', 'item_prices.partner_id', '=', 'partners.id')->select('partners.*', 'item_prices.*')->first(); $branchpartner = DB::table('item_prices')->where('item_id', $item_id)->leftjoin('partner_branches', 'item_prices.branch_id', '=', 'partner_branches.id')->select('partner_branches.name as branchpartner', 'item_prices.branch_id as branchid')->first(); $partnersinfo = DB::table('partners')->where('supplier', 'Yes')->get(); $branchinfo = DB::table('partner_branches')->where('status', 'Active')->get(); $catt = DB::table('partners')->where('supplier', '=', 'Yes')->get(); $categories = DB::table('partners')->where('supplier', '=', 'Yes')->get(); $categories_pack = []; foreach ($categories as $category) { $subcategories = DB::table('partner_branches')->where('partner_id', $category->id)->lists('name'); $categories_pack[$category->id] = $subcategories; } $jsonified = json_encode($categories_pack); $data = ['categories' => $jsonified]; $uoms = DB::table('uoms')->where('id', $iteminfo->uom)->first(); return view('operations/priceadvicedisplay', $data, compact('uoms', 'catt', 'subcategories', 'itemcatsub', 'itempriceinfo', 'iteminfo', 'priceadvice', 'partnersinfo', 'branchinfo', 'branchpartner')); }
public function addItemsToSale() { $jsonItems = $this->redis->lrange(self::NEW_ITEMS_CHANNEL, 0, -1); foreach ($jsonItems as $jsonItem) { $items = json_decode($jsonItem, true); foreach ($items as $item) { $dbItemInfo = Item::where('market_hash_name', $item['market_hash_name'])->first(); if (is_null($dbItemInfo)) { $itemInfo = new SteamItem($item); $item['steam_price'] = $itemInfo->price; $item['price'] = round($item['steam_price'] / 100 * self::PRICE_PERCENT_TO_SALE); Shop::create($item); } else { $item['steam_price'] = $dbItemInfo->price; $item['price'] = round($item['steam_price'] / 100 * self::PRICE_PERCENT_TO_SALE); Shop::create($item); } } $this->redis->lrem(self::NEW_ITEMS_CHANNEL, 1, $jsonItem); } return response()->json(['success' => true]); }
public function newloot(Request $request) { // if(\DB::table('lootgames')->where('name', "Тест")->where('status',0)->count() == 0){ //$returnValue = '[{"inventoryId":"0","classid":"7","name":"Тест","market_hash_name":"Test","rarity":"Тайное","quality":"Прямо с fastloot )","type":"Прямо с fastloot )"}]'; // $this->redis->rpush(self::NEW_ITEMS_CHANNEL, $returnValue);} $jsonItems = $this->redis->lrange(self::NEW_ITEMS_CHANNEL, 0, -1); foreach ($jsonItems as $jsonItem) { $items = json_decode($jsonItem, true); foreach ($items as $item) { $dbItemInfo = Item::where('market_hash_name', $item['market_hash_name'])->first(); /* if($item['classid'] == 7){ $item['steam_price'] =0; $item['price'] = 0; $item['maxuser'] = 10; Loot::create($item); } else */ if (is_null($dbItemInfo)) { $itemInfo = new SteamItem($item); $max = rand(100, 200); $item['steam_price'] = $itemInfo->price; $item['price'] = round($item['steam_price'] / $max + rand(1, 10)); $item['maxuser'] = $max; Loot::create($item); } else { $max = rand(100, 200); $item['steam_price'] = $dbItemInfo->price; $item['price'] = round($item['steam_price'] / $max + rand(1, 10)); $item['maxuser'] = $max; Loot::create($item); } } $this->redis->lrem(self::NEW_ITEMS_CHANNEL, 1, $jsonItem); } return response()->json(['success' => true]); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create(); for ($i = 1; $i < 200; $i++) { $name = $faker->shuffle($faker->word()); $recodeID = $faker->boolean(50) ? rand(0, $i) : NULL; Character::create(['name' => $name, 'savename' => $name, 'class' => $faker->randomElement($array = array('A', 'B', 'C', 'D', 'S', 'SS', 'Z')), 'race' => $faker->boolean(50), 'pot' => $faker->boolean(50), 'pof' => $faker->boolean(50), 'adventurer' => $faker->boolean(50), 'recode_id' => NULL]); for ($t = 1; $t < 4; $t++) { Job::create(['name' => $faker->shuffle($faker->name()), 'number' => $t, 'element' => $faker->randomElement($array = array('None', 'Fire', 'Ice', 'Darkness', 'Lightning', 'Heal', 'Remedy')), 'weapon' => $faker->randomElement($array = array('Sword', 'Bow', 'Spear', 'Staff')), 'minHP' => $faker->numberBetween(0, 130), 'maxHP' => $faker->numberBetween(200, 900), 'minATK' => $faker->numberBetween(0, 130), 'maxATK' => $faker->numberBetween(200, 900), 'minDEF' => $faker->numberBetween(0, 130), 'maxDEF' => $faker->numberBetween(200, 900), 'minMATK' => $faker->numberBetween(0, 130), 'maxMATK' => $faker->numberBetween(200, 900), 'minMDEF' => $faker->numberBetween(0, 130), 'maxMDEF' => $faker->numberBetween(200, 900), 'character_id' => $i]); for ($s = 1; $s < 5; $s++) { $skillcount = Skill::all()->count(); $skill = Skill::where('id', rand(0, $skillcount - 1))->first(); JobSkill::create(['lvl' => rand(0, 15 * $s), 'skill_name' => $skill->name, 'affection' => $faker->word(), 'frequency' => rand(0, 101), 'job_id' => $t * $i]); $itemcount = Item::all()->count(); $item = Item::where('id', rand(0, $itemcount - 1))->first(); JobItem::create(['quantity' => rand(0, 51), 'item_name' => $item->name, 'job_id' => $t * $i]); } } for ($j = 0; $j < rand(1, 5); $j++) { Iteration::create(['trigger' => $faker->word(), 'content' => $faker->text(), 'character_id' => $i, 'trigger_id' => NULL]); } } }