Ejemplo n.º 1
0
 public function store(Request $request)
 {
     $website = new Website();
     $webRecords[] = ['name' => null, 'description' => null, 'url' => null];
     //all website records
     $website_model[] = null;
     //loop on website
     $length = count($request->get('website'));
     //lets create a record
     foreach ($request->get('website') as $url) {
         $webRecords[] = $this->collectWebsiteData('website', '', $url);
         // every key has an arr except merchant_id
     }
     //loop on social
     $length = count($request->get('social'));
     //
     foreach ($request->get('social') as $url) {
         $webRecords[] = $this->collectWebsiteData('social', '', $url);
         // every key has an arr except merchant_id
     }
     //loop on ecommerce
     $length = count($request->get('ecom_site'));
     //
     foreach ($request->get('ecom_site') as $url) {
         $webRecords[] = $this->collectWebsiteData('ecom_site', '', $url);
         // every key has an arr except merchant_id
     }
     unset($webRecords[0]);
     foreach ($webRecords as $websiteSingleRecord) {
         $website_model[] = $website->create($websiteSingleRecord);
     }
     unset($website_model[0]);
     return $website_model;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public function actionIndex()
 {
     $coupons = new Coupon();
     $resultType = $coupons->couponType();
     $websites = new Website();
     $resultStores = $websites->websiteName();
     $coupons = new CouponCategories();
     $resultCategory = $coupons->storesName();
     $coupons = new Coupon();
     $resultDetail = $coupons->couponDetail();
     return $this->render('index', ['resultType' => $resultType, 'resultStores' => $resultStores, 'resultCategory' => $resultCategory, 'resultDetail' => $resultDetail]);
 }
Ejemplo n.º 4
0
 /**
  * Show the search result to the user.
  *
  * @return Response
  */
 public function Search()
 {
     $links = null;
     $query = Input::get('q');
     $lucky = Input::get('lucky');
     $pageNum = Input::get('p') != "" ? Input::get('p') : 1;
     $stats = new SearchStats();
     if (!empty($query) && $query != "") {
         //performing the search and calculating elapsed time
         $starttime = microtime(true);
         $links = Website::getByQueryString($query);
         $endtime = microtime(true);
         $timediff = $endtime - $starttime;
         //wrapping info into a class
         $stats->elapsed = $timediff;
         $stats->total = count($links);
         $stats->currentPage = $pageNum;
         $stats->pages = ceil(count($links) / 10);
         $stats->max = $stats->pages < 11 ? $stats->pages + 1 : 11;
         //pagination of results
         $links = Paginator::page($links, $pageNum);
     } else {
         return Redirect::to("/");
     }
     //If there are results, if lucky is set to true you will be redirect to the first link
     if (!empty($links) && !empty($lucky) && $lucky == true) {
         return Redirect::to($links[0]->url);
     } else {
         return view('search')->with('links', $links)->with('query', $query)->with('stats', $stats);
     }
 }
Ejemplo n.º 5
0
 /**
  * @establish a relationship with client or website model
  */
 public function getCow()
 {
     if ($this->belong_to == 1) {
         return $this->hasOne(Client::className(), ['id' => 'clients_or_webs_id']);
     } elseif ($this->belong_to == 2) {
         return $this->hasOne(Website::className(), ['id' => 'clients_or_webs_id']);
     }
 }
Ejemplo n.º 6
0
 /**
  * Finds the Website model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Website the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Website::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 7
0
 public function getCreate(Model $data)
 {
     parent::getCreate($data);
     // ------------------------------------------------------------------------------------
     // GET WEBSITE LIST
     // ------------------------------------------------------------------------------------
     $this->layout->main->website_list = Website::orderBy('name')->get()->lists('name', '_id');
     return $this->layout;
 }
Ejemplo n.º 8
0
 function websiteName()
 {
     $result = Website::find()->orderBy('WebsiteTitle')->distinct(true)->select('WebsiteTitle')->all();
     $type = array();
     $ind = 0;
     foreach ($result as $value) {
         $type[$ind++] = $value->WebsiteTitle;
     }
     return $type;
 }
Ejemplo n.º 9
0
 public function actionIndex()
 {
     $keywords = Yii::$app->request->get('k');
     if ($keywords) {
         $sql_c = 'SELECT * FROM clients WHERE company LIKE "%' . $keywords . '%" OR firstname LIKE "%' . $keywords . '%" OR lastname LIKE "%' . $keywords . '%"';
         $clients = new ActiveDataProvider(['query' => Client::findBySql($sql_c, [':key' => $keywords]), 'pagination' => ['pageSize' => 10]]);
         $sql_w = 'SELECT * FROM websites WHERE domain LIKE "%' . $keywords . '%"';
         $websites = new ActiveDataProvider(['query' => Website::findBySql($sql_w, [':key' => $keywords]), 'pagination' => ['pageSize' => 10]]);
         return $this->render('index', ['clients' => $clients, 'websites' => $websites]);
     }
 }
Ejemplo n.º 10
0
 public function actionIndex()
 {
     $model = new Coupon();
     $pageSize = 60;
     $couponData = $model->getAllCoupons($pageSize);
     $result = $couponData['coupons'];
     $pagination = $couponData['pagination'];
     $websites = Website::getAllWebsites();
     $categories = CouponCategories::getAllCouponCategories();
     //Coupon::$lastresult = $result;
     return $this->render('index', ['coupons' => $result, 'pagination' => $pagination, 'websites' => $websites, 'categories' => $categories]);
 }
Ejemplo n.º 11
0
 public function getIndex()
 {
     $view = parent::getIndex();
     // ------------------------------------------------------------------------------------
     // GET LIST
     // ------------------------------------------------------------------------------------
     $this->layout->main->data = Model::name('*' . $this->layout->main->filters['name'] . '*')->orderby('name')->paginate(25);
     // ------------------------------------------------------------------------------------
     // VIEW
     // ------------------------------------------------------------------------------------
     return $this->layout;
 }
Ejemplo n.º 12
0
 public function nav()
 {
     $website_to_project = array();
     $websites = Website::get();
     if ($websites) {
         foreach ($websites as $key => $val) {
             $websites_array[$val['websites_id']] = $val['websites_name'];
         }
     }
     $projects = Project::get();
     if ($projects) {
         foreach ($projects as $key => $val) {
             $projects_array[$val['projects_id']] = $val['projects_name'];
         }
     }
     $posts = Post::select('website', 'project')->orderby("website", "asc")->orderby("project", "asc")->get();
     if ($posts) {
         foreach ($posts as $key => $val) {
             $website_to_project[$val['website']]['websites_name'] = $websites_array[$val['website']];
             $website_to_project[$val['website']]['projects_name'][$val['project']] = $projects_array[$val['project']];
         }
     }
     return response()->json($website_to_project);
 }
Ejemplo n.º 13
0
 public function getWebsites()
 {
     return $this->hasMany(Website::classname(), ['clients_id' => 'id']);
 }
Ejemplo n.º 14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     Website::create(['name' => 'HaloMalang', 'url' => 'http://halomalang.com', 'launched_at' => \Carbon\Carbon::parse('2012-03-01 00:00:00')]);
 }
Ejemplo n.º 15
0
 public static function getAllWebsites()
 {
     $websites = Website::find()->limit(15)->all();
     return $websites;
 }
Ejemplo n.º 16
0
 public function website($slug)
 {
     $site = Website::where('slug', $slug)->firstOrFail();
     return view('home.website', ['site' => $site]);
 }
Ejemplo n.º 17
0
 protected function migrate_events()
 {
     $website = Website::first();
     $data_users = User::get();
     foreach ($data_users as $user) {
         $users[$user['username']] = $user;
     }
     // get old articles
     DB::connection('mongodb')->collection('posts')->where('category', 'regex', '/events/i')->chunk(1000, function ($data) use($new_collection, $users, $website) {
         foreach ($data as $x) {
             unset($tags);
             $tags[] = 'events';
             if (str_is('*car free day*', strtolower($x['title']))) {
                 $tags[] = 'cfd';
             }
             if (str_is('*seminar*', strtolower($x['title']))) {
                 $tags[] = 'seminar';
             }
             if (str_is('*opening*', strtolower($x['title']))) {
                 $tags[] = 'opening';
             }
             if (str_is('*ustad*', strtolower($x['title']))) {
                 $tags[] = 'religius';
             }
             if (str_is('*clothing*', strtolower($x['title']))) {
                 $tags[] = 'pameran';
             }
             if (str_is('*konser*', strtolower($x['title'])) || str_is('*concert*', strtolower($x['title'])) || str_is('*cherry bell*', strtolower($x['title']))) {
                 $tags[] = 'konser';
             }
             if (str_is('*brawijaya*', strtolower($x['title']))) {
                 $tags[] = 'brawijaya';
             }
             if (str_is('*stand up comedy*', strtolower($x['title']))) {
                 $tags[] = 'stand up comedy';
             }
             if (str_is('*job fair*', strtolower($x['title'])) || str_is('*career expo*', strtolower($x['title']))) {
                 $tags[] = 'job fair';
             }
             if (str_is('*film*', strtolower($x['title']))) {
                 $tags[] = 'film';
             }
             if (str_is('*film*', strtolower($x['title']))) {
                 $tags[] = 'film';
             }
             if (str_is('*lomba*', strtolower($x['title'])) || str_is('*kompetisi*', strtolower($x['title']))) {
                 $tags[] = 'kompetisi';
             }
             if ($x['tgl_published']) {
                 $news = new Event(['title' => $x['title'], 'slug' => str_replace('.', '', $x['url']), 'summary' => str_limit(strip_tags(str_replace("\n", "", $x['full'])), 125), 'content' => $x['full'], 'published_at' => date('Y-m-d H:i:s', $x['tgl_published']->sec), 'created_at' => $x['tgl'], 'updated_at' => $x['tgl'], 'user_id' => array_key_exists($x['author'], $users) ? $users[$x['author']]->id : $users['dita']->id, 'started_at' => $x['extra_field']['event_tgl_start']->sec, 'ended_at' => isset($x['extra_field']['event_tgl_end']) ? $x['extra_field']['event_tgl_end']->sec : $x['extra_field']['event_tgl_start']->sec, 'location' => isset($x['extra_field']['event_lokasi']) ? $x['extra_field']['event_lokasi'] : '', 'komunitas_id' => Directory::where('ori_id', '=', $x['extra_field']['event_komunitas'])->first()->id, 'views' => isset($x['views']) ? $x['views'] : 0]);
                 if (!$news->save()) {
                     print_r($news->toArray());
                     dd($news->getErrors());
                 }
                 // ----------------------------------------------------------------------------------------------------
                 // IMAGE
                 // ----------------------------------------------------------------------------------------------------
                 $s_image = new Image(['name' => 'sm', 'path' => $x['thumbmail'], 'title' => '', 'description' => '']);
                 $m_image = new Image(['name' => 'md', 'path' => $x['image'], 'title' => '', 'description' => '']);
                 $l_image = new Image(['name' => 'lg', 'path' => $x['image'], 'title' => '', 'description' => '']);
                 $news->images()->updateOrCreate(['name' => 'sm'], $s_image->toArray());
                 $news->images()->updateOrCreate(['name' => 'md'], $m_image->toArray());
                 $news->images()->updateOrCreate(['name' => 'lg'], $l_image->toArray());
                 // ----------------------------------------------------------------------------------------------------
                 // TAG
                 // ----------------------------------------------------------------------------------------------------
                 unset($tags_model);
                 $tags_model = new Collection();
                 foreach ($tags as $tag) {
                     $tags_model[] = Tag::firstOrCreate(['name' => $tag]);
                 }
                 foreach ($tags_model as $k => $v) {
                     if (!$tags_model[$k]->save()) {
                         dd($tags_model[$k]->getErrors());
                     }
                 }
                 if (count($tags_model)) {
                     $news->tags()->sync($tags_model->lists('id'));
                 }
                 // ----------------------------------------------------------------------------------------------------
                 // WEBSITE
                 // ----------------------------------------------------------------------------------------------------
                 $news->websites()->sync([$website->id]);
                 // ----------------------------------------------------------------------------------------------------
                 // LOG
                 // ----------------------------------------------------------------------------------------------------
                 // $news->authored()->attach(array_key_exists($x['author'], $users) ? $users[$x['author']]->id : $users['dita']->id, ['original_data' => json_encode([]), 'updated_data' => $news->toJson()]);
             }
             // $news->websites()->associate($website);
             // $news->save();
         }
     });
     // save to new tables
 }
Ejemplo n.º 18
0
 /**
  * send a email to client with checklist attached
  * @return void
  */
 public function actionSendmail()
 {
     $post = Yii::$app->request->post('SendmailForm');
     Yii::$app->response->format = 'json';
     $sm_form = new SendmailForm();
     if ($sm_form->load(Yii::$app->request->post()) && $sm_form->validate()) {
         $checklistCow = ChecklistsCow::findOne($post['checklists_cow_id']);
         if ($checklistCow->belong_to == 1) {
             $cow = Client::findOne($checklistCow->clients_or_webs_id);
             $email = $cow->email;
         } elseif ($checklistCow->belong_to == 2) {
             $cow = Website::findOne($checklistCow->clients_or_webs_id);
             $email = $cow->client->email;
         }
         // save time sending
         // checking if time sending is exist then only update else create new one
         $timeSent = ChecklistsTimeSent::find()->where(['checklists_cow_id' => $post['checklists_cow_id']])->one();
         if (!isset($timeSent)) {
             $timeSent = new ChecklistsTimeSent();
         }
         $timeSent->checklists_cow_id = $post['checklists_cow_id'];
         $timeSent->time_sent = date('Y-m-d H:i:s');
         $timeSent->save();
         // if everything is ok, then send mail. go ahead!!!
         Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($email)->setSubject($post['subject'])->setTextBody($post['content'])->attach(Yii::$app->basePath . '/web/upload/pdf/' . $checklistCow->file_name)->send();
         return ['errors' => ''];
     } else {
         return ['errors' => 'Something is wrong.'];
     }
 }
Ejemplo n.º 19
0
 private function check_repeat($websites_name)
 {
     $websites = Website::where('websites_name', $websites_name)->count();
     if ($websites) {
         return true;
     }
 }
Ejemplo n.º 20
0
 public function actionIndex()
 {
     $count = ['clients' => count(Client::find()->all()), 'websites' => count(Website::find()->all()), 'checklists' => count(Checklist::find()->all()), 'messages' => count(Message::find()->all())];
     return $this->render('index', ['count' => $count]);
 }
Ejemplo n.º 21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     /*
             $brand_name_array = $request->get('brand_name');
             Models used fo registering a merchant
             User, Bank, Buyer, Address, Merchant, Brand, Website and Director
     */
     $user = new User();
     $user_model = $user->store($request);
     //return new user record in db
     $bank = new Bank();
     $bank_model = $bank->store($request);
     if ($request['indication'] == 'buyer') {
         return "no functionality implemented";
         $buyer = new Buyer();
         $buyer_model = $buyer->store($request, $user_model);
     }
     if ($request['indication'] == 'merchant') {
         //TODO: for adding address first create address then add address id to merchant table
         //country_id   => working
         $address = new Address();
         $address_model = $address->store($request);
         // user_id, country_id, address_id, bank_id => working
         $user_as_merchant = new Merchant();
         $user_as_merchant_model = $user_as_merchant->store($request, $user_model, $bank_model, $address_model);
         /*
          * Document table
          */
         $documents = new Document();
         $documents_model = $documents->store($request, $user_as_merchant_model);
         //todo: add brand
         //1)create merchant and get model
         //2)create all brand and get all models
         //3)sync merchant model with brand models in merchantbrand table
         $brand = new Brand();
         $brand_models = $brand->store($request, $user_as_merchant_model, $address_model);
         //now syncing
         $user_as_merchant_model->attachBrands($user_as_merchant_model, $brand_models);
         //http://laravel.com/docs/5.1/eloquent-relationships#inserting-many-to-many-relationships
         //for storing web sites in "merchantwebsite" table
         //first create merchant and get id
         //then create websites and get website model array like director
         //then attach merchant with each website id
         $website = new Website();
         $website_models = $website->store($request);
         //attachment with merchant in "merchantwebsite" table
         $user_as_merchant->attachWebsites($website_models, $user_as_merchant_model);
         $director = new Director();
         $director_model = $director->store($request, $user_as_merchant_model);
         /*save all FKs of directors & merchants to merchantdirectos tables */
         $user_as_merchant_model->attachDirectors($director_model, $user_as_merchant_model);
         \Session::flash(Config::get('messages.key.name'), $this->messageHandler->success('merchantRegistered', null, null, true, true, true));
     }
     return redirect()->back();
 }
Ejemplo n.º 22
0
 public function addshow()
 {
     //网站列表
     $data['websites'] = Website::orderby('websites_id', 'desc')->get();
     $data['projects'] = Project::orderby('projects_id', 'desc')->get();
     $data['posts_content'] = file_get_contents("http://www.doc.com/app/admin/tpl/posts/default.html");
     return response()->json(['status' => true, 'message' => '数据查询成功', 'data' => $data]);
 }
Ejemplo n.º 23
0
 function saving($model)
 {
     if (\App\Models\Website::validate($model) === false) {
         return false;
     }
 }
Ejemplo n.º 24
0
 public function getWebsite()
 {
     return $this->hasOne(Website::className(), ['WebsiteID' => 'WebsiteID']);
 }