Пример #1
0
 protected function _add()
 {
     if (!($id = $this->input->post('id'))) {
         Json::error('Invalid influencer id');
     }
     $id = new \MongoId($id);
     $brand = new Brand(UserSession::get('user._id'));
     $binfo = $brand->get();
     $lists = MongoDoc::get($binfo, 'lists', array());
     $list_idx = $this->input->post('list');
     $new_list = $this->input->post('new_list');
     if ($list_idx !== null && isset($lists[$list_idx])) {
         if (in_array($id, $lists[$list_idx]['influencers'])) {
             Json::success('Influencer is already preset in the list');
         }
         $lists[$list_idx]['influencers'][] = $id;
     } else {
         if (!empty($new_list)) {
             foreach ($lists as $l) {
                 if ($l['name'] === $new_list) {
                     Json::error(sprintf('List with name "%s" already exists', $new_list));
                 }
             }
             $lists[] = array('name' => $new_list, 'influencers' => array($id));
         } else {
             Json::error('Invalid list');
         }
     }
     $brand->update(array('lists' => $lists));
     Json::success('Success');
 }
Пример #2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pro = new Product();
     $adSlotObj = new Adslot();
     $catObj = new Category();
     $brandObj = new Brand();
     /*getting all products for all slots(currently we have 7 slots)*/
     $adSlot_data = $adSlotObj->with(['products'])->get();
     /*t1-t7*/
     // dd($adSlot_data[4]['products'][0]);
     $category_temp_data = $catObj->orderBy('created_at')->take(10)->get();
     /*f1-f10*/
     $brand_data = $brandObj->with(['products'])->get();
     $category_data = [];
     foreach ($category_temp_data as $cat_id) {
         $cat_latest_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('photo_1');
         $cat_latest_product_id = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('id');
         $cat_random_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy(DB::raw('RAND()'))->take(6)->get();
         $cat_brands = $pro->with(['brand'])->where('category_id', '=', $cat_id['id'])->take(5)->get();
         $cat_products_random_photos = [];
         foreach ($cat_random_product as $photo) {
             $cat_products_random_photos[] = $photo;
         }
         $category_data[] = ['color' => $cat_id['color'], 'floor' => $cat_id['floor'], 'name' => $cat_id['name'], 'desc' => $cat_id['description'], 'logo' => $cat_id['logo'], 'latest_photo_id' => $cat_latest_product_id, 'latest_photo' => $cat_latest_product, 'random_photos' => $cat_products_random_photos, 'brands' => $cat_brands];
     }
     return view('landing_page', compact(['adSlot_data', 'category_data']));
 }
Пример #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Category $categoryModel, Brand $brandModel, Provider $providerModel)
 {
     $categoryList = $categoryModel->getCategoriesList();
     $brandList = $brandModel->getFullBrandsList();
     $providerList = $providerModel->getProvedrsList();
     return view('filter.index')->with('title', 'Фильтр')->with('categoryList', $categoryList)->with('brandList', $brandList)->with('providerList', $providerList);
 }
Пример #4
0
 protected function _list_remove()
 {
     if (UserSession::get('user.type') !== 'brand') {
         $this->_403();
     }
     try {
         $brand = new Brand(UserSession::get('user._id'));
         $binfo = $brand->get();
         $list_idx = $this->input->post('list');
         if (!($list = MongoDoc::get($binfo, 'lists.' . $list_idx))) {
             Json::error('Invalid list');
         }
         $list['influencers'] = array_values(array_diff($list['influencers'], array(new \MongoId($this->input->post('id')))));
         $redirect = null;
         if (count($list['influencers'])) {
             $binfo['lists'][$list_idx] = $list;
         } else {
             // Redirect if list is empty, cause we've removed it
             $redirect = Url::base(Url::current());
             unset($binfo['lists'][$list_idx]);
             $binfo['lists'] = array_values($binfo['lists']);
         }
         $brand->update(array('lists' => $binfo['lists']));
         $influencers = (new Influencer(null))->filter(array('_id' => array('$in' => $list['influencers'])), array('_id' => true, 'name' => true, 'username' => true));
         $body = $this->_display->view(array('main/app/brand/influencer.list.php'), array('influencers' => $influencers), true, false);
         Json::success('Success', $redirect, array('body' => $body));
     } catch (\Exception $e) {
         Json::error($e->getMessage());
     }
 }
Пример #5
0
 public function getMerchantRelationsFullMeta()
 {
     $user = new User();
     $website = new Website();
     $director = new Director();
     $address = new \App\Models\Address();
     $bank = new Bank();
     $brand = new Brand();
     $merchantFullMeta = ['user' => $user->getMeta(), 'merchant' => [$this->getMeta()], 'bank' => [$bank->getMeta()], 'address' => [$address->getMeta()], 'brand' => [$brand->getMeta()], 'websites' => [$website->getMeta()], 'directors' => [$director->getMeta()]];
     return $merchantFullMeta;
 }
 /**
  * @param Brand $model
  *
  * @return bool
  */
 public function saving(Brand $model)
 {
     // process the image, only if it is there or if it's modified
     if ($model->isDirty('logo')) {
         $path = $this->image->init($model, 'logo')->getImage();
         if (empty($path)) {
             return false;
         }
         $model->logo = $path;
         return true;
     }
     return true;
 }
Пример #7
0
 protected function _walk_social($u)
 {
     $user = new Brand(null);
     $update = array();
     printf("%-15s %-30s\n", 'BEGIN', $u['_id']);
     $this->_compute_social($u, $update);
     if ($update) {
         $this->_compute_status_latest($u, $update);
         printf("%-15s %-30s\n", 'UPDATE', $u['_id']);
         $user->modify(array('_id' => $u['_id']), array('$set' => $update));
     }
     printf("%-15s %-30s\n", 'END', $u['_id']);
 }
Пример #8
0
 public function post()
 {
     try {
         $brand = new Brand(UserSession::get('user._id'));
         $binfo = $brand->get();
         $data = $this->_get_data($binfo);
         $campaign = new Campaign(null);
         $id = $campaign->create($data);
         (new NotifyBrandCampaign())->create($id);
         Alert::once('success', 'Campaign queued for admin approval', Url::current());
     } catch (\Exception $e) {
         Alert::once('error', $e->getMessage(), Url::current());
     }
 }
Пример #9
0
 protected function _remove()
 {
     try {
         $brand = new Brand(UserSession::get('user._id'));
         $iinfo = $brand->get();
         if ($social = MongoDoc::get($iinfo, 'social')) {
             unset($social['twitter']);
             $brand->update(array('social' => $social));
         }
     } catch (\Exception $e) {
         Alert::once('error', 'Failed to remove account: ' . $e->getMessage(), Url::base('brand/social'));
     }
     Alert::once('success', 'Account remove successfully', Url::base('brand/social'));
 }
Пример #10
0
 protected function _activation()
 {
     $brand = new BrandModel($this->input->post('id'));
     if (!($binfo = $brand->get())) {
         Json::error('Invalid brand!');
     }
     try {
         $active = $this->input->post('active') ? true : false;
         $brand->update(array('active' => $active));
         (new NotifyBrandAccount())->activation($binfo['_id'], UserSession::get('user._id'));
         Json::success('Brand status updated!', null);
     } catch (\Exception $e) {
         Json::error($e->getMessage());
     }
 }
Пример #11
0
 public function actionIndex($mid = '', $f = 0)
 {
     $user = User::findIdentity(Yii::$app->user->id);
     $regFrm = new RegisterForm();
     $rstFrm = new RestorePswForm();
     $spOffs = new SpecialOffer();
     $spOffs = $spOffs->getAllSpecialOffers();
     if ($f) {
         $logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN_CAPTCHA]);
     } else {
         $logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN]);
     }
     $city = City::find()->all();
     $address = new Address();
     $distr = $address->getDistrict();
     $category = Category::find()->all();
     $brand = Brand::find()->all();
     $msg = '';
     switch ($mid) {
         case 1:
             $msg = Common::M_EMAIL_SEND;
             break;
         case 2:
             $msg = Common::M_PSW_EMAIL_SEND;
             break;
         case 3:
             $msg = Common::M_PSW_RESTORE_SUCCESS;
             break;
     }
     return $this->render('index', ['msg' => $msg, 'user' => $user, 'spOffs' => $spOffs, 'regFrm' => $regFrm, 'logFrm' => $logFrm, 'rstFrm' => $rstFrm, 'city' => $city, 'distr' => $distr, 'category' => $category, 'brand' => $brand]);
 }
Пример #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $brand = Brand::all();
     $category = Category::all();
     $user = User::all();
     return view('product.create_new_product', compact('brand', 'category', 'subcat_level1', 'user'));
 }
Пример #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('brands')->truncate();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Brand::create(['name' => "Brand " . $index, 'brand_owner_id' => BrandOwner::find($faker->numberBetween(1, 20))->id, 'industry_id' => Industry::find($faker->numberBetween(1, 20))->id]);
     }
 }
 public function edit($id)
 {
     $brands = Brand::orderBy('sort_order')->get();
     $categories = $this->get_categories();
     $types = Type::with('attributes')->get();
     $good = Good::with('good_attrs', 'good_galleries')->find($id);
     return view('admin.good.edit', ['good' => $good, 'brands' => $brands, 'categories' => $categories, 'types' => $types]);
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher $events
  *
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     // register custom model observers
     Product::observe(new ProductObserver(new ImageProcessor()));
     Brand::observe(new ProductBrandObserver(new ImageProcessor()));
     User::observe(new UserObserver(new ImageProcessor()));
 }
Пример #16
0
 /**
  * Finds the Brand model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Brand the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Brand::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #17
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(BrandRequest $request)
 {
     try {
         $brand = Brand::create($request->all());
         return $request->request->get('continue') ? $this->redirectBackWithMessage('操作成功') : redirect('brand');
     } catch (BaseException $e) {
     }
 }
 public function getBrands()
 {
     $ret = [];
     foreach (Brand::find()->all() as $o) {
         $ret[$o->key] = $o->id;
     }
     return (object) $ret;
 }
Пример #19
0
 public function get($brand_id = null)
 {
     $user = new Influencer(UserSession::get('user._id'));
     $uinfo = $user->get();
     $brands = array();
     $bmodel = new Brand(null);
     foreach (MongoDoc::get($uinfo, 'favorites', array()) as $b) {
         $brands[] = $bmodel->filter_one(array('_id' => $b), array('_id' => true, 'name' => true, 'username' => true));
     }
     $river = array();
     if ($brands && !$brand_id) {
         $brand_id = $brands[0]['_id'];
     }
     if ($brand_id) {
         $river = MongoDoc::get((new Brand($brand_id))->get(), 'social_river', array());
     }
     $this->_display->view(array('main/app/influencer/river.php'), array('brands' => $brands, 'brand_id' => $brand_id, 'river' => $river));
 }
Пример #20
0
 public function get($state = null)
 {
     if (!$state) {
         Url::redirect('admin/campaign/pending');
     }
     $filter = array();
     if ($state != 'all') {
         $filter = array('state' => $state);
     }
     $campaigns = $this->_get_campaigns($filter)->sort(array('_id' => 1));
     $r = array();
     foreach ($campaigns as $c) {
         $brand = new Brand($c['brand']);
         $c['brand'] = $brand->filter_one(array('_id' => $c['brand']), array('_id' => true, 'username' => true));
         $r[] = $c;
     }
     $this->_display->view(array('main/app/admin/campaign/index.php'), array('campaigns' => $r));
 }
Пример #21
0
 public function post()
 {
     if (UserSession::get('user.type') !== 'brand') {
         $this->_403();
     }
     if (!($id = $this->input->post('id'))) {
         Json::error('Invalid influencer id');
     }
     $id = new \MongoId($id);
     $brand = new Brand(UserSession::get('user._id'));
     $binfo = $brand->get();
     $favorites = MongoDoc::get($binfo, 'favorites', array());
     if ($reset = in_array($id, $favorites)) {
         $favorites = array_values(array_diff($favorites, array($id)));
     } else {
         $favorites[] = $id;
     }
     $brand->update(array('favorites' => $favorites));
     Json::success('Success', null, array('set' => !$reset));
 }
Пример #22
0
 public function store(Request $request, $merchant_model, $address_model)
 {
     //may be we get more that brands so loop through brand_name[] in request
     //create record for each brand
     //then save one by one and save in model array brand_models_array
     $brand_name_array = $request->get('brand_name');
     $brandRecords[] = ['name' => null, 'description' => null, 'logo' => null, 'deleted' => null];
     //all website records
     $brand_models[] = null;
     foreach ($brand_name_array as $brand_name) {
         $brandRecords[] = $this->collectBrandFormData($request, $brand_name);
     }
     unset($brandRecords[0]);
     $brand = new Brand();
     foreach ($brandRecords as $brandRecord) {
         $brand_models[] = $brand->create($brandRecord);
     }
     unset($brand_models[0]);
     return $brand_models;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('trackings')->truncate();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'facing_id' => Facing::find($faker->numberBetween(1, 20))->id]);
     }
     foreach (range(21, 30) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'state' => 'Inserted', 'inserted_at' => Carbon::now(), 'facing_id' => Facing::all()->get($faker->numberBetween(1, 20))->id, 'product_id' => Product::all()->get($faker->numberBetween(1, 20))->id, 'brand_id' => Brand::all()->get($faker->numberBetween(1, 20))->id, 'user_id' => User::all()->get($faker->numberBetween(1, 10))->id]);
     }
 }
Пример #24
0
 protected function _save_river($key)
 {
     try {
         $user = new Brand(UserSession::get('user._id'));
         $uinfo = $user->get();
         $auto = !!$this->input->post('auto');
         if ($auto) {
             if (($r = MongoDoc::get($uinfo, 'social_river.data_custom')) && isset($r[$key])) {
                 unset($r[$key]);
                 $user->update(array('social_river.data_custom' => (object) $r));
             }
         } else {
             if (($u = $this->input->post('url')) && !empty($u)) {
                 $user->update(array('social_river.data_custom.' . $key => trim($u)));
             }
         }
         Alert::once('success', 'URL updated successfully', Url::current());
     } catch (\Exception $e) {
         Alert::once('error', $e->getMessage(), Url::current());
     }
 }
Пример #25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Brand::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 15]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'show_type_name' => $this->show_type_name, 'is_show' => $this->is_show, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'is_deleted' => 0]);
     $query->andFilterWhere(['like', 'cn_name', $this->cn_name])->andFilterWhere(['like', 'en_name', $this->en_name])->andFilterWhere(['like', 'py_name', $this->py_name])->andFilterWhere(['like', 'initial', $this->initial])->andFilterWhere(['like', 'logo', $this->logo])->andFilterWhere(['like', 'sn', $this->sn]);
     return $dataProvider;
 }
Пример #26
0
 public function search($input)
 {
     $query = Brand::query();
     $columns = Schema::getColumnListing('brands');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Пример #27
0
 public function search()
 {
     $brands = $this->brands;
     $socho = $this->sochoxe;
     //dd($brands); die();
     $tintucs = $this->tintucs;
     $q = Input::get('q');
     $cars = Cars::where('ten_xe', 'LIKE', '%' . $q . '%')->orWhere('socho_xe', 'LIKE', '%' . $q . '%')->orWhere(function ($query) use($q) {
         $brands = Brand::where('hang_name', 'LIKE', '%' . $q . '%')->get()->toArray();
         //dd($brand);
         $hang_id = array();
         foreach ($brands as $key => $value) {
             array_push($hang_id, $value['hang_id']);
         }
         $query->whereIn('hang_id', $hang_id);
     })->get();
     return view('frontend.pages.searchresult', compact('cars', 'q', 'brands', 'socho', 'tintucs'));
 }
Пример #28
0
 /**
  * Remove the specified product brand from storage.
  *
  * @param DeleteInventoryRequest $request
  *
  * @param Brand $brand
  * @return Response
  */
 public function destroy(DeleteInventoryRequest $request, Brand $brand)
 {
     $this->data = $brand->delete();
     return $this->handleRedirect($request, route('backend.brands.index'));
 }
Пример #29
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Label $labelModel, History $historyModel, Purchase $purchaseModel, Provider $providerController, Brand $brandModel, Category $categoryModel, Product $productModel, $id)
 {
     $product = $productModel->getProduct($id);
     if (!$product) {
         abort(404);
     }
     $purchase = $purchaseModel->getPurchase($id);
     $historyProduct = $historyModel->getProductHistory($id);
     $historyPurchase = $historyModel->getPurchaseHistory($id);
     $historySite = $historyModel->getSiteHistory($id);
     $labels = $labelModel->getLabelsByProductsId([$id]);
     $arLabels = [];
     foreach ($labels as $label) {
         $arLabels[] = $label->label;
     }
     $strLabels = implode(',', $arLabels);
     if (!empty($product->childs)) {
         $product->childs = unserialize($product->childs);
     }
     $categories_list = $categoryModel->getFullCategoriesList();
     $brands_list = $brandModel->getFullBrandsList();
     $provider_list = $providerController->getProvedrsList();
     return view('products.show')->with('title', $product->category_name . ' ' . $product->name)->with('product', $product)->with('purchase', $purchase)->with('categories_list', $categories_list)->with('brands_list', $brands_list)->with('provider_list', $provider_list)->with('history_product', $historyProduct)->with('history_purchase', $historyPurchase)->with('history_site', $historySite)->with('labels', $strLabels);
 }
 public function search(Request $request)
 {
     $keyword = $request->keyword . "%";
     $brands = Brand::orderBy('sort_order')->where('name', 'like', $keyword)->paginate(config('wyshop.page_size'));
     return view('admin.brand.index', ['brands' => $brands]);
 }