Example #1
0
 public function storeAdvices(Share $share)
 {
     $share->guruwatches()->delete();
     $data = XMLParser::getXMLDataInArray('http://www.guruwatch.nl/rss/adviezen.aspx?issueid=' . $share->guruwatch);
     foreach ($data->channel->item as $e) {
         $share->guruwatches()->save($this->makeRecord($e));
     }
 }
Example #2
0
 /** @test */
 public function it_is_unique_for_the_same_email_and_order()
 {
     $this->setExpectedException('Illuminate\\Database\\QueryException');
     $share = new Share(['email' => $this->user->email, 'phone' => '676676766', 'comments' => 'Lorem ipsum comment']);
     $share->order_id = $this->order->id;
     $share->save();
     $share = new Share(['email' => $this->user->email, 'phone' => '77474736', 'comments' => 'Another Lorem ipsum comment']);
     $share->order_id = $this->order->id;
     $share->save();
 }
 private function getSharePortfolio(Share $share)
 {
     $past_price = $share->pivot->boughtFor;
     $now_price = $share->getlastPrice();
     $profit_price = $now_price - $past_price;
     $profit_price_percentage = $now_price / $past_price - 1;
     $past_amount = $share->pivot->amount;
     $now_amount = $past_amount * ($profit_price_percentage + 1);
     $profit_amount = $now_amount - $past_amount;
     $profit_amount_percentage = $now_amount / $past_amount - 1;
     return ['id' => $share->pivot->id, 'name' => $share->name, 'past_price' => number_format((double) $past_price, 2, '.', ''), 'past_amount' => number_format((double) $past_amount, 2, '.', ''), 'now_price' => number_format((double) $now_price, 2, '.', ''), 'now_amount' => number_format((double) $now_amount, 2, '.', ''), 'profit_price' => number_format((double) $profit_price, 2, '.', ''), 'profit_price_percentage' => number_format((double) $profit_price_percentage * 100, 2, '.', '') . ' %', 'profit_amount' => number_format((double) $profit_amount, 2, '.', ''), 'profit_amount_percentage' => number_format((double) $profit_amount_percentage * 100, 2, '.', '') . ' %'];
 }
 public function index($token)
 {
     if ($token === 'W2Xcoiq28sLNasiszA819qgLk42CTc5b') {
         $addressees = Model::all();
         $news = News::getForDelivery();
         $tenders = Tender::getForDelivery();
         $vacancies = Vacancy::getForDelivery();
         $shares = Share::getForDelivery();
         $expert_advices = ExpertAdvice::getForDelivery();
         foreach ($addressees as $addressee) {
             $params['title'] = $addressee->locale . '_title';
             $params['text'] = $addressee->locale . '_text';
             $params['locale'] = $addressee->locale;
             $addressee->news && count($news) ? $params['delivery']['news'] = $news : null;
             $addressee->tenders && count($tenders) ? $params['delivery']['tenders'] = $tenders : null;
             $addressee->vacancies && count($vacancies) ? $params['delivery']['vacancies'] = $vacancies : null;
             $addressee->shares && count($shares) ? $params['delivery']['shares'] = $shares : null;
             $addressee->expert_advices && count($expert_advices) ? $params['delivery']['expert_advices'] = $expert_advices : null;
             if (isset($params['delivery'])) {
                 Mail::send('emails.delivery', $params, function ($message) use($addressee) {
                     $from_address = MailConfig::first();
                     $from_name = Config::get('mail.from');
                     $message->from($from_address->feedback_mail, $from_name['name']);
                     $message->to($addressee->email)->subject(trans('front-end' . DS . 'emails' . DS . 'delivery.subject'));
                 });
             }
             unset($params);
         }
         News::where('sended', 0)->update(['sended' => 1]);
         Tender::where('sended', 0)->update(['sended' => 1]);
         Vacancy::where('sended', 0)->update(['sended' => 1]);
         Share::where('sended', 0)->update(['sended' => 1]);
         ExpertAdvice::where('sended', 0)->update(['sended' => 1]);
     }
 }
Example #5
0
 private function generateOrderSharesFor($group)
 {
     $users = User::all();
     foreach ($group->orders as $order) {
         foreach ($users->random(6)->values()->all() as $user) {
             $share = new Share(['email' => $user->email, 'order_id' => $order->id]);
             $share->save();
             $items = [];
             $order->products->random(5)->each(function ($item) {
                 $items[$item->id] = rand(1, 7) * $item->pivot->step_amount;
             }, array());
             $items = $order->getShareItems($items);
             $share->items()->saveMany($items);
         }
     }
 }
 public function run()
 {
     $shares = [['class' => 'facebook', 'website' => 'Facebook', 'url' => 'https://www.facebook.com/vdhjonas91', 'icon' => 'facebook'], ['class' => 'github', 'website' => 'Github', 'url' => 'https://github.com/jonasvanderhaegen', 'icon' => 'github-circled'], ['class' => 'gplus', 'website' => 'Google+', 'url' => 'https://plus.google.com/u/0/113736815749779639543', 'icon' => 'gplus'], ['class' => 'linkedin', 'website' => 'LinkedIn', 'url' => 'https://plus.google.com/u/0/113736815749779639543', 'icon' => 'linkedin'], ['class' => 'instagram', 'website' => 'Instagram', 'url' => 'https://instagram.com/vdhjonas91/', 'icon' => 'instagram'], ['class' => 'spotify', 'website' => 'Spotify', 'url' => 'https://play.spotify.com/user/1186092526', 'icon' => 'spotify'], ['class' => 'soundcloud', 'website' => 'Soundcloud', 'url' => 'https://soundcloud.com/vdhjonas', 'icon' => 'soundcloud'], ['class' => 'twitter', 'website' => 'Twitter', 'url' => 'https://twitter.com/vdhJonas', 'icon' => 'twitter']];
     foreach ($shares as $share) {
         $s = Share::create($share);
         Shareable::create(['share_id' => $s->id, 'shareable_id' => 1, 'shareable_type' => 'App\\User']);
     }
 }
Example #7
0
 public function storeAdvices()
 {
     $guruwatchApi = new GuruwatchApi();
     foreach ($this->symbols as $symbol) {
         $share = Share::where('symbol', $symbol)->firstOrFail();
         $guruwatchApi->storeAdvices($share);
     }
 }
Example #8
0
 public function show($id)
 {
     $infoConfig = InfoConfig::first()->toArray();
     $object = Model::find($id);
     if ($object) {
         return view('info.promo', ['object' => $object, 'type' => 'vacancies', 'title' => LANG . '_title', 'text' => LANG . '_text', 'requirements' => LANG . '_requirements', 'infoConfig' => $infoConfig]);
     }
     return redirect('info-center');
 }
Example #9
0
 public function show(Request $request)
 {
     if (!$request->has('q')) {
         return redirect('/' . LANG);
     }
     $params = $request->only('q');
     $searchParams = explode(" ", trim($params['q']));
     $productsResults = Product::search($searchParams);
     $portfoliosResults = Portfolio::search($searchParams);
     $newsResults = News::search($searchParams);
     $tendersResults = Tender::search($searchParams);
     $vacanciesResults = Vacancy::search($searchParams);
     $sharesResults = Share::search($searchParams);
     $experEdvicesResults = ExpertAdvice::search($searchParams);
     $count = count($productsResults) + count($portfoliosResults) + count($newsResults) + count($tendersResults) + count($vacanciesResults) + count($sharesResults) + count($experEdvicesResults);
     return view('search', ['products' => $productsResults, 'portfolios' => $portfoliosResults, 'news' => $newsResults, 'tenders' => $tendersResults, 'vacancies' => $vacanciesResults, 'shares' => $sharesResults, 'experEdvices' => $experEdvicesResults, 'count' => $count, 'title' => LANG . '_title', 'description' => LANG . '_description', 'adderss' => LANG . '_adderss', 'type' => 'news']);
 }
Example #10
0
 public function updateGuruwatch()
 {
     $shareSymbols = Share::lists('symbol')->toArray();
     $financeApi = new FinanceApi($shareSymbols);
     $financeApi->storeAdvices();
 }
Example #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $object = Model::find($id);
     if ($object) {
         $object->delete();
     }
     return redirect()->back();
 }
Example #12
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($order_id, $share_id)
 {
     $share = Share::with(['items'])->find($share_id);
     $order = Order::find($order_id);
     return view('order.share.show', compact('share', 'order'));
 }