public function __construct() { parent::__construct(); $this->store = Store::find($this->user->getKey()); if (empty($this->store)) { return $this->error('store.failure_noexists'); } $this->viewData['_store'] = $this->store; }
public function destroy($id) { $store = Store::find($id); if ($store->file_entries_id !== 0) { $entry = FileEntry::find($store->file_entries_id); Storage::delete($entry->filename); $entry->delete(); } $store->delete(); return response()->json(['id' => $id]); }
public function getCategory() { $cat = ''; $store = Store::where('user_id', Auth::user()->id)->get(); $i = 1; for ($i = 1; $i <= count($store); $i++) { $x = Store::find($i); $y[$i] = $x; } return view('pages.erp.category', compact('store', 'i', 'cat', 'group', 'y')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // Find the Store $store = Store::find($id); // Update data $store->label = $request->label; $store->notes = $request->notes; // Save it $store->save(); session()->flash('message', 'Store has been saved'); session()->flash('message-type', 'success'); return redirect()->action('StoreController@index'); }
/** * 扫描 * * @param Addons\Models\WechatUser $wechatUser 发送者 * @param Addons\Models\WechatAccount $account 接收者 * @param string $scene_id 二维码的参数值 * @param string $ticket 二维码的ticket,可用来换取二维码图片 * @return string|response */ public function scan(API $api, WechatUser $wechatUser, WechatAccount $account, $scene_id, $ticket) { if (($index = strpos($scene_id, 'store-')) !== FALSE) { $id = intval(substr($scene_id, $index + 6)); $store = Store::find($id); if (!empty($store) && !empty($wechatUser->uid)) { $user = User::find($wechatUser->uid); !empty($user) && $user->stores()->sync([$store->getKey()], false); return $api->news([['Title' => '欢迎光临“汉派商城”,在这里,挑选您的美丽服饰,开始您的魅力之旅吧!', 'Description' => '', 'PicUrl' => url('attachment') . '?id=' . $store->user->avatar_aid, 'Url' => url('m?sid=' . $store->getKey())]])->reply([], true); } } //$result = (new WechatQrcode)->reply($scene_id, $ticket); return null; }
public function store(Request $request, $id, $size = NULL) { $store = Store::find($id); if (empty($store)) { return $this->failure_noexists(); } $account = WechatAccount::findOrFail(1); $qrcode = new Qrcode($account->toArray(), $account->getKey()); $qr = $qrcode->getSceneStr('store-' . $id); // if (empty($qr)) { return $this->failure('store.failure_qrcode'); } //empty($qr->wdid) && $qr->update(['wdid' => 1]); //设置一个callback的素材 return redirect(!empty($qr->aid) && empty($size) ? 'attachment?id=' . $qr->aid : 'qr?text=' . urlencode($qr->url) . '&size=' . (empty($size) ? 25 : $size) . '&watermark=' . urlencode('static/img/wechat.png')); }
public function analytics(Request $request) { $model = $request->get('model'); $id = $request->get('id'); if ($model == "product") { $product = Product::find($id); $views = $product->views; $product->views = $views + 1; $product->save(); } else { $store = Store::find($id); $views = $store->views; $store->views = $views + 1; $store->save(); } return 'ok'; }
public function doAudit() { if ($this->audited) { return false; } $agent = Agent::find($this->aid); if (empty($agent)) { return false; } $user = (new User())->get($this->username) ?: (new User())->add(['username' => $this->username, 'password' => substr($this->idcard, -6), 'realname' => $this->realname, 'idcard' => $this->idcard, 'phone' => $this->username], Role::STORE); $store = Store::find($user->getKey()) ?: Store::create(['id' => $user->getKey(), 'name' => $this->name, 'phone' => $this->phone, 'address' => $this->address]); $user->roles()->sync([Role::where('name', Role::STORE)->firstOrFail()->getKey()], false); $agent->stores()->sync([$store->getKey()], false); $store->brands()->sync($this->brand_ids, false); $this->audited = true; $this->save(); return true; }
public function update(Request $request) { $rules = ['name' => 'required', 'address' => 'required', 'lat' => 'required|numeric', 'long' => 'required|numeric']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $id = $request->get('id'); $store = Store::find($id); $store->name = $request->get('name'); $store->address = $request->get('address'); $store->lat = $request->get('lat'); $store->long = $request->get('long'); $store->url = "blaaah"; $store->save(); $request->session()->flash('message', 'Store successfuly updated'); return redirect('/stores'); }
public function index(Request $request, $sid = NULL, $redirect_url = NULL) { if (!empty($sid)) { $store = Store::find($sid); !empty($store) && $this->user->stores()->sync([$sid], FALSE); } if (empty($this->user->stores->count())) { return $this->failure('store.failure_follow'); } if (!empty($redirect_url)) { return redirect()->intended($redirect_url); } $stores_ids = $this->user->stores->pluck('id'); $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']); $pagesize = $request->input('pagesize') ?: config('site.pagesize.m', $this->site['pagesize']['common']); $this->_input = $request->all(); $product = new Product(); $builder = $product->newQuery()->with(['sizes', 'covers']); $this->_table_data = $builder->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize); return $this->view('m.index'); }
public function getCoursesByStoreId(Request $request, $id) { $dates = array(); $courseSchedules = array(); $today = Carbon::today(); $tomorrow = Carbon::tomorrow(); $day_after_tomorrow = Carbon::tomorrow()->addDay(); $dates['today'] = '今天' . $today->format('m-d'); $dates['tomorrow'] = '明天' . $tomorrow->format('m-d'); $dates['day_after_tomorrow'] = '后天' . $day_after_tomorrow->format('m-d'); $store = Store::find($id); $courseSchedules['today'] = CourseSchedule::whereHas('course', function ($query) use($store) { $query->where('store_id', $store->id); })->where('class_date', $today->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get(); $courseSchedules['tomorrow'] = CourseSchedule::whereHas('course', function ($query) use($store) { $query->where('store_id', $store->id); })->where('class_date', $tomorrow->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get(); $courseSchedules['day_after_tomorrow'] = CourseSchedule::whereHas('course', function ($query) use($store) { $query->where('store_id', $store->id); })->where('class_date', $day_after_tomorrow->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get(); return view('mobile.courses', compact('store', 'courseSchedules', 'dates')); }
public function postEdititem($id) { // dd() $validator = Validator::make(Input::all(), ['item_name' => 'required', 'item_type' => 'required', 'quantity' => 'required', 'units' => 'required', 'order_id' => 'required', 'vendor_id' => 'required']); if ($validator->fails()) { //dd($validator); return redirect('store/edititem/' . $id)->withErrors($validator)->withInput(); } else { //$date = date('Y-m-d H:i:s'); $new_item = Store::find($id); $new_item->item_name = Input::get('item_name'); $new_item->units = Input::get('units'); $new_item->item_type = Input::get('item_type'); $new_item->order_id = Input::get('order_id'); $new_item->vendor_id = Input::get('vendor_id'); $new_item->quantity = Input::get('quantity'); $new_item->item_description = Input::get('item_description'); $new_item->item_added_by = Auth::id(); $new_item->save(); return redirect('store/viewstore')->with('edit_item', 'Edit item succesfully'); } }
public function updateStore(request $request) { $validator = Validator::make($request->all(), ['store_id' => 'required', 'name' => 'required|max:255', 'address' => 'required|min:10', 'code' => 'required', 'cost' => 'required', 'timer' => 'required|max:200', 'is_active' => 'required']); $input = $request->only('store_id'); $inputVal = $request->only('name', 'code'); if ($validator->fails()) { return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator); } $store = Store::find($input['store_id']); if ($inputVal['name'] != $store->name) { $validator = Validator::make($request->all(), ['name' => 'unique:stores']); if ($validator->fails()) { return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator); } } if ($inputVal['code'] != $store->code) { $validator = Validator::make($request->all(), ['code' => 'unique:stores']); if ($validator->fails()) { return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator); } } foreach ($request->only('name', 'address', 'code', 'cost', 'timer', 'is_active') as $key => $value) { $store->{$key} = $value; } if ($request->hasFile('offer_image')) { $image = $request->file('offer_image'); $imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension(); $path = public_path('assets/img/stores/' . $imageName); Image::make($image->getRealPath())->resize(280, 240)->save($path); $store->offer_image = $imageName; } $store->save(); return redirect('admin/store/' . $input['store_id']); }
public function deliver($id) { $order = Order::with(['details', 'order_express'])->join('order_expresses', 'order_expresses.id', '=', 'orders.id', 'INNER')->whereIn('order_expresses.sid', $this->stores_ids)->find($id); $this->_data = $order; if ($order->order_express->uaid) { $this->_user_address = UserAddress::find($order->order_express->uaid)->getFullAddressAttribute(); } else { $this->_user_store = Store::find($order->order_express->sid); } if ($order->order_express->uaid) { $keys = 'express_name,no'; $this->_validates = $this->getScriptValidate('order.deliver', $keys); } return $this->view('agent-backend.order.deliver'); }
public function getCreateItem($id = null) { $store = \App\Store::find($id); if (is_null($id)) { \Session::flash('flash_message', 'Store not found.'); return redirect('\\store'); } return view('stores.createitem')->with('store', $store); }
public function RelStore(Request $request) { $check = $request->input('store_check'); $validation = Validator::make($request->all(), ['store_check' => 'required']); if ($validation->fails()) { Alert::error('Anda belum memilih toko, beri tanda checklist!')->persistent("Close"); return redirect()->back()->withInput(); } foreach ($check as $store_c) { $store = Store::find($store_c); $store->id_teams = $request->input('id_team'); $store->status = 1; $store->save(); } Alert::success('Berhasil memilih toko!')->persistent("Close"); return redirect('project/view/' . $request->input('id_project'))->with('message', 'Kamu baru saja memilih toko!'); }
public function RelStore(Request $request) { // Start Check Authorization /** * 1. FullAccess - 1 * 2. HRD - 3 * 3. Creator - 5 * 4. Handler - 7 */ $invalid_auth = 1; $authRole = Auth::user()->UserRoles->role; if ($authRole == 7 or $authRole == 1 or $authRole == 3) { $invalid_auth = 0; } if ($invalid_auth == 1) { Alert::error('Anda tidak memilik akses ini')->persistent('close'); return redirect('project/view/' . $request->input('id_project')); } // End Check Authorization $check = $request->input('store_check'); $validation = Validator::make($request->all(), ['store_check' => 'required']); if ($validation->fails()) { Alert::error('Anda belum memilih toko, beri tanda checklist!')->persistent("Close"); return redirect()->back()->withInput(); } foreach ($check as $store_c) { $store = Store::find($store_c); $store->id_teams = $request->input('id_team'); $store->status = 1; $store->save(); } Alert::success('Berhasil memilih toko!')->persistent("Close"); return redirect('project/view/' . $request->input('id_project'))->with('message', 'Kamu baru saja memilih toko!'); }
public function getFeaturedStore($user_id, $store_count) { $rtnArray = array(); $featured_store = $this->model->select(\DB::raw("stores.id as user_id"))->selectRaw('stores.id')->join('bookmark_groups', 'users.id', '=', 'bookmark_groups.user_id', 'inner')->join('bookmark_group_store', 'bookmark_groups.id', '=', 'bookmark_group_store.bookmark_group_id', 'inner')->join('stores', 'bookmark_group_store.store_id', '=', 'stores.id', 'inner')->where('users.id', '=', $user_id)->orderBy("bookmark_group_store.created_at", "DESC")->limit($store_count); foreach ($featured_store->get() as $item) { $store = \App\Store::find($item->id); array_push($rtnArray, $store); } return $rtnArray; }
<a href='/store/{{$store->id}}/delete-store' class="confirm" style="margin:3px" data-toggle="tooltip" data-placement="bottom" title="Delete"> <i class="glyphicon glyphicon-trash"></i> </a> </div> @endforeach </div> </ul> </div> @endif @if(isset($items)) {{-- MAIN CONTENT --}} <div class="col-sm-9 col-sm-offset-3 col-md-5 col-md-offset-1 main"> <?php $store_name = \App\Store::find($store_id)->store_name; ?> <h2 class="page-header">{{$store_name}}</h2> </div> <div class="col-sm-9 col-sm-offset-3 col-md-1 col-md-offset-0 main"> <a href='/store/{{$store_id}}/create-item' > <button type="button" class="btn btn-primary" style="margin-top:30px;">Add Item</button> </a> </div> <div class="col-sm-9 col-sm-offset-3 col-md-6 col-md-offset-1 main" style="box-sizing: border-box;"> <div class="row placeholders">
public function update(Request $request, $id) { $store = Store::find($id); if (empty($store)) { return $this->failure_noexists(); } $keys = 'name,address,phone,agent_ids,brand_ids'; $data = $this->autoValidate($request, 'store.store', $keys, $store); $agent_ids = array_pull($data, 'agent_ids'); $brand_ids = array_pull($data, 'brand_ids'); $store->update($data); $agent->agents()->sync($agent_ids); $agent->brands()->sync($brand_ids); return $this->success(); }
public function deliver($id) { $order = Order::with(['details', 'order_express'])->where('fid', $this->factory->getKey())->find($id); $this->_data = $order; if ($order->order_express->uaid) { $this->_user_address = UserAddress::find($order->order_express->uaid)->getFullAddressAttribute(); } else { $this->_user_store = Store::find($order->order_express->sid); } if ($order->order_express->uaid) { $keys = 'express_name,no'; $this->_validates = $this->getScriptValidate('order.deliver', $keys); } return $this->view('factory-backend.order.deliver'); }
public static function getOsaCategory($id) { $store = Store::find($id); // store level $template = self::where('store_id', $store->id)->first(); if (!empty($template)) { return $template; //0001 } $template = self::where('customer_id', $store->customer_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //1111 } else { return self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->where('template_id', 0)->first(); } } else { $template = self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->where('distributor_id', 0)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //1101 } else { return self::where('customer_id', $store->customer_id)->where('region_id', $store->region_id)->where('distributor_id', 0)->where('template_id', 0)->first(); } } } else { $template = self::where('customer_id', $store->customer_id)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', $store->customer_id)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //1011 } else { return self::where('customer_id', $store->customer_id)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->where('template_id', 0)->first(); } } else { $template = self::where('customer_id', $store->customer_id)->where('region_id', 0)->where('distributor_id', 0)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //1001 } else { return self::where('customer_id', $store->customer_id)->where('region_id', 0)->where('distributor_id', 0)->where('template_id', 0)->first(); } } } } else { $template = self::where('customer_id', 0)->where('region_id', $store->region_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', 0)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', 0)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //0111 } else { return self::where('customer_id', 0)->where('region_id', $store->region_id)->where('distributor_id', $store->distributor_id)->where('template_id', 0)->first(); } } else { $template = self::where('customer_id', 0)->where('region_id', $store->region_id)->where('distributor_id', 0)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; //0101 } else { return self::where('customer_id', 0)->where('region_id', $store->region_id)->where('distributor_id', 0)->where('template_id', 0)->first(); } } } else { $template = self::where('customer_id', 0)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->get(); if (count($template) > 0) { $template = self::where('customer_id', 0)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; // 0011 } else { return self::where('customer_id', 0)->where('region_id', 0)->where('distributor_id', $store->distributor_id)->where('template_id', 0)->first(); } } else { $template = self::where('customer_id', 0)->where('region_id', 0)->where('distributor_id', 0)->where('template_id', $store->audit_template_id)->first(); if (!empty($template)) { return $template; // 0001 } else { return self::where('customer_id', 0)->where('region_id', 0)->where('distributor_id', 0)->where('template_id', 0)->where('store_id', 0)->first(); } } } } }
public function show($id) { $store = Store::find($id); return response()->json($store); }
/** * get storage volume of specific store. * * @param int $id * @return Response */ public function storeStockItems($id) { $store = Store::find($id); return $store->stock_items; }
public function cancelDispatch($id, Request $request) { $dispatch = RecipientPackage::find($id); $recipient = Recipient::find(Auth::user()->recipient_id); foreach ($dispatch->items as $items) { $volume = $items->amount * PackagingInformation::find($items->packaging_id)->cm_per_dose * 0.001; $stock = Stock::where('recipient_id', $recipient->id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first(); $storeStock = StoreStock::where('store_id', $items->store_id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first(); $stock->amount = $stock->amount + $items->amount; $storeStock->amount = $storeStock->amount + $items->amount; $stock->save(); $storeStock->save(); //reduce volume in store $store = Store::find($items->store_id); $store->used_volume = $store->used_volume + $volume; $store->save(); //update line item status $items->status = 'canceled'; $items->save(); //delete stock item if amount has turned to zero if ($stock->amount == 0) { $stock->delete(); } if ($storeStock->amount == 0) { $storeStock->delete(); } } //update arrival status $dispatch->receiving_status = 'canceled'; $dispatch->comments = $request->has('notes') ? $request->input('notes') : ""; $dispatch->save(); Log::create(array("user_id" => Auth::user()->id, "action" => "Cancel Dispatch with reference Number " . $dispatch->voucher_number)); return $dispatch->voucher_number; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $store = Store::find($id); $store->brand_id = (int) $request->brand_id; $store->payment_type = (int) $request->payment_type; // $store->day = implode(',',$request->day); $store->store_name = $request->store_name; $store->address = $request->address; $store->latitude = $request->latitude; $store->longitude = $request->longitude; $store->opening_time = $request->opening_time; $store->closing_time = $request->closing_time; $store->highlights = $request->highlights; $store->price_range = $request->price_range; $store->update(); return redirect('admin/stores'); }
public function destroy(Request $request, $id) { empty($id) && !empty($request->input('id')) && ($id = $request->input('id')); $id = (array) $id; foreach ($id as $v) { $store = Store::find($v); //删除代理商关联 $store->agent()->detach($this->agent->getKey()); //删除品牌关联 $store->brands()->detach($this->agent->brand_ids()->toArray()); } return $this->success('', count($id) > 5, compact('id')); }