/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('customers')->truncate();
     DB::table('areas')->truncate();
     DB::table('premises')->truncate();
     DB::table('stores')->truncate();
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $filePath = 'database/seeds/seed_files/Store Mapping.xlsx';
     $reader->open($filePath);
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Sheet1') {
             $rowcnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($rowcnt > 1) {
                     if (!is_null($row[0])) {
                         $customer = Customer::firstOrCreate(['customer_code' => $row[8], 'customer' => strtoupper($row[9])]);
                         $area = Area::firstOrCreate(['area_code' => $row[2], 'area' => strtoupper($row[3])]);
                         $premise = Premise::firstOrCreate(['premise_code' => $row[4], 'premise' => strtoupper($row[5])]);
                         Store::firstOrCreate(['customer_id' => $customer->id, 'area_id' => $area->id, 'premise_id' => $premise->id, 'store_code' => strtoupper($row[0]), 'store' => strtoupper($row[1])]);
                     }
                 }
                 $rowcnt++;
             }
         }
     }
     $reader->close();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
 public function run()
 {
     $folderpath = 'database/seeds/seed_files';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", $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;
         }
     }
     $file_path = $folderpath . "/" . $latest . "/Secondary Display.xlsx";
     echo (string) $file_path, "\n";
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('secondary_display_lookups')->truncate();
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $filePath = $file_path;
     $reader->open($filePath);
     // Accessing the sheet name when reading
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Sheet1') {
             $cnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($cnt > 0) {
                     // dd($row);
                     $store = Store::where('store_code', trim($row[1]))->first();
                     $brands = array();
                     if (!empty($store)) {
                         $x = 1;
                         for ($i = 3; $i < 29; $i++) {
                             if ($row[$i] == "1.0") {
                                 $brands[] = $x;
                             }
                             $x++;
                         }
                         foreach ($brands as $value) {
                             SecondaryDisplayLookup::create(['store_id' => $store->id, 'secondary_display_id' => $value]);
                         }
                     }
                 }
                 $cnt++;
             }
         } else {
         }
     }
     $reader->close();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
 public function run()
 {
     $folderpath = 'database/seeds/seed_files';
     $folders = File::directories($folderpath);
     $latest = '11232015';
     foreach ($folders as $value) {
         $_dir = explode("/", $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;
         }
     }
     $file_path = $folderpath . "/" . $latest . "/Store SOS.xlsx";
     echo (string) $file_path, "\n";
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('store_sos_tags')->truncate();
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $filePath = $file_path;
     $reader->open($filePath);
     // Accessing the sheet name when reading
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Sheet1') {
             $cnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if (!empty($row[0])) {
                     // dd($row);
                     if ($cnt > 0) {
                         // dd($row);
                         $store = Store::where('store_code', $row[0])->first();
                         // dd($store);
                         $category = FormCategory::where('category', strtoupper($row[2]))->first();
                         // dd($category);
                         $sos = SosTagging::where('sos_tag', strtoupper($row[3]))->first();
                         // dd($sos);
                         StoreSosTag::insert(array('store_id' => $store->id, 'form_category_id' => $category->id, 'sos_tag_id' => $sos->id));
                         // echo (string)$row[0], "\n";
                     }
                     $cnt++;
                 }
             }
         } else {
         }
     }
     $reader->close();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
Exemplo n.º 4
1
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('users')->truncate();
     DB::table('store_user')->truncate();
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $filePath = 'database/seeds/seed_files/User.xlsx';
     $reader->open($filePath);
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'File') {
             $rowcnt = 0;
             $errorCnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($rowcnt > 0) {
                     if (!is_null($row[0])) {
                         $user = User::where('email', strtolower($row[19]) . '@unilever.com')->first();
                         if (count($user) == 0) {
                             $user = User::firstOrCreate(['name' => strtoupper($row[18]), 'email' => strtolower($row[19]) . '@unilever.com', 'username' => $row[19], 'password' => Hash::make('password')]);
                         }
                         $store = Store::where('store_code', $row[5])->first();
                         if (!empty($store)) {
                             $store->users()->attach($user->id);
                         } else {
                             $errorCnt++;
                         }
                     }
                 }
                 $rowcnt++;
             }
         }
     }
     $reader->close();
     echo $errorCnt;
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
Exemplo n.º 5
1
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('store_sku')->truncate();
     $reader = ReaderFactory::create(Type::XLSX);
     // for XLSX files
     $filePath = 'database/seeds/seed_files/SKU Mapping.xlsx';
     $reader->open($filePath);
     foreach ($reader->getSheetIterator() as $sheet) {
         if ($sheet->getName() == 'Sheet1') {
             $rowcnt = 0;
             $errorCnt = 0;
             foreach ($sheet->getRowIterator() as $row) {
                 if ($rowcnt > 0) {
                     if (!is_null($row[0])) {
                         $premise = Premise::where('premise_code', $row[0])->first();
                         if (!empty($premise)) {
                             $stores = Store::where('premise_id', $premise->id)->get();
                             $sku = Sku::where('sku_code', $row[3])->first();
                             if (!empty($stores) && !empty($sku)) {
                                 foreach ($stores as $store) {
                                     $store->skus()->attach($sku, array('ig' => $sku->conversion + 20));
                                 }
                             }
                         }
                     }
                 }
                 $rowcnt++;
             }
         }
     }
     $reader->close();
     echo $errorCnt;
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     Model::reguard();
 }
Exemplo n.º 6
0
 /**
  * Update the view paths.
  *
  * @return void
  */
 private function registerStoreConfig(Store $store)
 {
     // merge store config into global config
     foreach ($store->getConfig() as $item) {
         $this->app['config']->set('store.' . $item->key, $item->value);
     }
 }
 /**
  * @param Store $store
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function getImage(Store $store)
 {
     if ($store->toArray() == []) {
         \App::abort(404, 'The API doesn\'t exist');
     }
     $imageUrl = "";
     $imageIndex = $store->img_url;
     if ($imageIndex != NULL) {
         $filePath = storage_path() . "/store_images/" . $imageIndex;
         return \Response::download($filePath, $store->title . ".jpg", ['Content-Type' => 'text/jpeg']);
     }
     \App::abort(404, 'The user doesn\'t have a valid image');
     return [];
 }
Exemplo n.º 8
0
 public function redeemCoupon(request $request)
 {
     $rules = array('client_id' => 'required', 'client_secret' => 'required', 'code' => 'required', 'mobile' => 'required|size:10', 'email' => 'required|email|max:255');
     $validator = $this->customValidator($request->all(), $rules, array());
     if ($validator->fails()) {
         return response()->json(['response_code' => 'ERR_RULES', 'message' => $validator->errors()->all()], 400);
     }
     $auth = $request->only('client_id', 'client_secret');
     $server = ['client_id' => Config::get('custom.client_id'), 'client_secret' => Config::get('custom.client_secret')];
     if ($server['client_id'] != $auth['client_id'] || $server['client_secret'] != $auth['client_secret']) {
         return response()->json(['response_code' => 'ERR_IAC', 'messages' => 'Invalid Api credentials'], 403);
     }
     $code = $request->only('code');
     $matchThese = ['code' => $code['code'], 'is_active' => true];
     $store = Store::where($matchThese)->first();
     if ($store == '' || empty($store)) {
         return response()->json(['response_code' => 'ERR_CCNV', 'message' => 'Coupon Code Not valid'], 409);
     }
     if ($this->userExists($request->only('email'))) {
         return response()->json(['response_code' => 'ERR_UAUC', 'message' => 'User Already Used Coupon'], 409);
     }
     $input = $request->only('name', 'email', 'mobile');
     $input['store_id'] = $store->id;
     $customer = Customer::create($input);
     $data['timer'] = $store->timer;
     $data['offer_image'] = URL::to('/assets/img/stores/') . $store->offer_image;
     return response()->json(['response_code' => 'RES_CRS', 'message' => 'Coupon Redeemed successfully', 'data' => $data]);
 }
Exemplo n.º 9
0
 public function bothStores()
 {
     $stores = $this->stores()->with('storeType')->get();
     $nonStores = Store::with('storeType')->get();
     $tmp = $nonStores->diff($stores);
     return array($stores, $tmp);
 }
Exemplo n.º 10
0
 public function stores()
 {
     $accounts = Account::all();
     $data = array();
     foreach ($accounts as $account) {
         $customers = Customer::where('account_id', $account->id)->get();
         $account_children = array();
         foreach ($customers as $customer) {
             $areas = Area::where('customer_id', $customer->id)->get();
             $customer_children = array();
             foreach ($areas as $area) {
                 $regions = Region::where('area_id', $area->id)->get();
                 $area_children = array();
                 foreach ($regions as $region) {
                     $distributors = Distributor::where('region_id', $region->id)->get();
                     $region_children = array();
                     foreach ($distributors as $distributor) {
                         $stores = Store::where('distributor_id', $distributor->id)->get();
                         $distributor_children = array();
                         foreach ($stores as $store) {
                             $distributor_children[] = array('title' => $store->store, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id . "." . $store->id);
                         }
                         $region_children[] = array('select' => true, 'title' => $distributor->distributor, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id, 'children' => $distributor_children);
                     }
                     $area_children[] = array('select' => true, 'title' => $region->region, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id, 'children' => $region_children);
                 }
                 $customer_children[] = array('select' => true, 'title' => $area->area, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id, 'children' => $area_children);
             }
             $account_children[] = array('select' => true, 'title' => $customer->customer, 'isFolder' => true, 'key' => $account->id . "." . $customer->id, 'children' => $customer_children);
         }
         $data[] = array('title' => $account->account, 'isFolder' => true, 'key' => $account->id, 'children' => $account_children);
     }
     return response()->json($data);
 }
Exemplo n.º 11
0
 /**
  * @param $domain
  * @param $type
  *
  * @return Store|Validator
  */
 public function create($domain, $type)
 {
     $domain = $this->fixDomain($domain);
     $identifier = $this->convertDomainToIdentifier($domain);
     $type = $this->storeTypeRepo->getByName($type);
     return Store::create(['identifier' => $identifier, 'domain' => $domain, 'type_id' => $type->getId(), 'account_id' => \Auth::user()->getAccountId(), 'auth_state' => Store::STATE_PENDING]);
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //$all_store = new \App\();
     $store_id = \App\Store::where('store_name', '=', 'Walmart')->pluck('id');
     DB::table('items')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'item_name' => 'Milk 2%', 'quantity' => '2 Gallon', 'store_aisle_num' => '14a', 'store_id' => $store_id, 'checked' => false]);
     $store_id = \App\Store::where('store_name', '=', 'Walmart')->pluck('id');
     DB::table('items')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'item_name' => 'Banana', 'quantity' => '3 lb', 'store_aisle_num' => '4', 'store_id' => $store_id, 'checked' => true]);
     $store_id = \App\Store::where('store_name', '=', 'Walmart')->pluck('id');
     DB::table('items')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'item_name' => 'Sugar', 'quantity' => '2 lb', 'store_aisle_num' => '2', 'store_id' => $store_id, 'checked' => false]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('stores')->truncate();
     $page_token = null;
     while (true) {
         $api_id = "AIzaSyCWhdA9YqfE9lIbFlFLLPbyZvEwR8hdyQ4";
         if (is_null($page_token)) {
             $get_data = http_build_query(['query' => 'Drugstores in the Philippines', 'key' => $api_id]);
             $results = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?' . $get_data, false);
             $results = json_decode($results);
             foreach ($results->results as $result) {
                 $store = new Store();
                 $store->name = $result->name;
                 $store->address = $result->formatted_address;
                 $store->url = $result->icon;
                 $store->lat = $result->geometry->location->lat;
                 $store->long = $result->geometry->location->lng;
                 $store->save();
             }
             $page_token = $results->next_page_token;
         } else {
             $api_id = "AIzaSyBlrchX9elMViPeAvmcqaN74sftBGKNMNs";
             $get_data = http_build_query(['query' => 'Drugstores in Philippines', 'key' => $api_id, 'pagetoken' => $page_token]);
             $results = file_get_contents('https://maps.googleapis.com/maps/api/place/textsearch/json?' . $get_data, false);
             $results = json_decode($results);
             foreach ($results->results as $result) {
                 $store = new Store();
                 $store->name = $result->name;
                 $store->address = $result->formatted_address;
                 $store->url = $result->icon;
                 $store->lat = $result->geometry->location->lat;
                 $store->long = $result->geometry->location->lng;
                 $store->save();
             }
             if (is_null($results->next_page_token)) {
                 break;
             } else {
                 $page_token = $results->next_page_token;
             }
         }
     }
 }
Exemplo n.º 15
0
 public function handle($request, Closure $next)
 {
     if (!isset($request->route()[2]['id'])) {
         return response()->json(array('status' => 'error', 'message' => 'Invalid store id'));
     }
     $id = $request->route()[2]['id'];
     if (is_null(\App\Store::findByPublicId($id))) {
         return response()->json(array('status' => 'error', 'message' => 'Invalid store id'));
     }
     return $next($request);
 }
Exemplo n.º 16
0
 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'));
 }
Exemplo n.º 17
0
 /**
  * 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');
 }
Exemplo n.º 18
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $store = Store::create(['name' => '锐思达健身会所(帝苑店)', 'mobile' => '86 591 87623888', 'address' => '福州市五四路9号宁德大厦7F', 'lat' => '26.23141231', 'lng' => '112.32141310', 'description' => '锐思达健身位于福州五四路宁德大厦7楼,是帝苑企业多元化发展的全新品牌。 锐思达是一个集健身、舒心为一体的都市精锐全新空间。以关注都市箐英身心健康为核心理念,致力于营造一个精致时尚的健身环境。福建首家拥有国际顶尖设备,贴心客户经理与私人教练的服务,为客户尽兴提供每一刻的专属服务;悉心定制的运动营养套餐,在保证品质的同时,更强调合理的营养搭配。

锐思达的空间设计极致,简约中不失调性,清晰的功能区域规划、灵动的空间布局,精巧中透露时尚气息。VIP私教套房,专属您的私密空间,尊享总统套房般的服务。

锐思达秉承帝苑集团“健康、欢乐、时尚”的经营理念,倡导做生活的减法,让生活更优质,为身心灵全面减压,回归最初的宁静。', 'startup_at' => '2015-10-10 00:00:00']);
        $store1 = Store::create(['name' => '锐思达动能馆(文化宫店)', 'mobile' => '86 591 87623999', 'address' => '福州市八一七路766号文化宫1F&B1F', 'lat' => '26.12645434', 'lng' => '112.12312410', 'description' => '坐落于台江区八一七中路766号文化宫的Restart锐思达动能馆,是锐思达健身会所面向大众化的全新支线品牌。

福州锐思达动能馆占地总面积达8500多平米,7300平方米健身房+1200平米国家标准恒温泳池,是一个让您在辛苦锻炼之余,能享受健身乐趣的空间。福州锐思达动能馆不仅仅向大众提供了现代化的健身环境和先进的健身方式,更是力求通过健身把真正核心的健康理念带给会员。希望会员在自身变化中,拥有对于健康生活的切身体会和理解,在日常的工作和生活中可以真正去实践健康的生活方式。

锐思达动能馆秉承Restart的宗旨,将一切美好愿望都渗透进了具体服务中。锐思达用心RESTART您在动能馆的每时每刻!', 'startup_at' => '2015-11-11 00:00:00']);
    }
Exemplo n.º 19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = ['Jill' => ['Walmart', 'Whole Foods', 'Trader Joes', 'Wegmans', 'Stop & Shop'], 'Jamal' => ['Whole Foods', 'Target', 'Star Market', 'RocheBros']];
     foreach ($users as $firstname => $stores) {
         # first get the user
         $user = \App\User::where('firstname', 'LIKE', $firstname)->first();
         #loop through all the store names for each user and add to the pivot table
         foreach ($stores as $storeName) {
             $store = \App\Store::where('store_name', 'LIKE', $storeName)->first();
             # Connect this store to this user
             $user->stores()->save($store);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * 扫描
  * 
  * @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;
 }
Exemplo n.º 21
0
 public function handle(Request $request, Closure $next)
 {
     if (!isset($request->route()[2]['id'])) {
         return response()->json(array('status' => 'error', 'message' => 'Invalid store id'));
     }
     $id = $request->route()[2]['id'];
     $secret = $request->input('secret');
     $store = \App\Store::findByPublicId($id);
     if (is_null($store)) {
         return response()->json(array('status' => 'error', 'message' => 'Invalid store id'));
     }
     if ($store->secret !== $secret) {
         return response()->json(array('status' => 'error', 'message' => 'Invalid store secret'));
     }
     return $next($request);
 }
Exemplo n.º 22
0
 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'));
 }
Exemplo n.º 23
0
 /**
  * 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);
         }
     }
 }
Exemplo n.º 24
0
 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';
 }
Exemplo n.º 25
0
 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;
 }
Exemplo n.º 26
0
 public function updateCover(Request $request, $id)
 {
     $store = Store::findOrFail($id);
     $file = $request->file('cover');
     $extension = $file->getClientOriginalExtension();
     $filename = 'stores/cover/' . $store->id . '/' . $file->getFilename() . '.' . $extension;
     Storage::disk('local')->put($filename, File::get($file));
     $entry = FileEntry::findOrNew($store->file_entries_id);
     if ($store->file_entries_id != 0) {
         Storage::disk('local')->delete($entry->filename);
     }
     $entry->mime = $file->getClientMimeType();
     $entry->original_filename = $file->getClientOriginalName();
     $entry->filename = $filename;
     $entry->save();
     $store->file_entries_id = $entry->id;
     $store->save();
     return response()->json(['id' => $entry->id]);
 }
Exemplo n.º 27
0
 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');
 }
Exemplo n.º 28
0
 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'));
 }
Exemplo n.º 29
0
 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');
     }
 }
Exemplo n.º 30
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $item1 = ItemInfo::create(['name' => 'lucky charms']);
     $item2 = ItemInfo::create(['name' => 'chicken']);
     $item3 = ItemInfo::create(['name' => 'coke']);
     $item4 = ItemInfo::create(['name' => 'frozen pizza']);
     $item5 = ItemInfo::create(['name' => 'sprite']);
     $item6 = ItemInfo::create(['name' => 'pepsi']);
     $item7 = ItemInfo::create(['name' => 'mtn dew']);
     $item8 = ItemInfo::create(['name' => 'crackers']);
     $item9 = ItemInfo::create(['name' => 'breakfast bar']);
     $item10 = ItemInfo::create(['name' => 'shrimp']);
     $item11 = ItemInfo::create(['name' => 'hot dogs']);
     $item12 = ItemInfo::create(['name' => 'hot dog buns']);
     $item13 = ItemInfo::create(['name' => 'mustard']);
     $item14 = ItemInfo::create(['name' => 'pickle']);
     $item15 = ItemInfo::create(['name' => 'banana']);
     $item16 = ItemInfo::create(['name' => 'apple']);
     $item17 = ItemInfo::create(['name' => 'bacon']);
     $item18 = ItemInfo::create(['name' => 'hot pocket']);
     $item19 = ItemInfo::create(['name' => 'orange juice']);
     $item20 = ItemInfo::create(['name' => 'candy']);
     $items = [$item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9, $item10, $item11, $item12, $item13, $item14, $item15, $item16, $item17, $item18, $item19, $item20];
     $stores = Store::all();
     /* Generate these 4 items for each store with random prices between
     	       $1.00 and $6.00 (100 - 600 in DB)
     		*/
     foreach ($stores as $store) {
         foreach ($items as $item) {
             $i = new Item();
             $i->price = rand(100, 600);
             $i->store()->associate($store);
             $i->itemInfo()->associate($item);
             $i->save();
         }
     }
 }