/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $contacts = Contact::orderBy('id', 'desc')->paginate(10);
     $option = Option::findOrFail(1);
     $featured_properties = Property::where('Heat_inc', '=', 'Yes')->get();
     return view('home', ['contacts' => $contacts, 'option' => $option, 'featured_properties' => $featured_properties]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $option = Option::findOrFail($id);
     $option->delete();
     Flash('Option Deleted');
     return Redirect()->route('options');
 }
 public function vote(VoteOnPoll $request)
 {
     $poll = Option::findOrFail($request->input('option.0'))->poll;
     foreach ($request->input('option') as $option) {
         Option::findOrFail($option)->increment('votes');
     }
     if ($poll->ip_checking == 1) {
         $voter = Voter::create(['poll_id' => $poll->id, 'ip_address' => $request->ip()]);
     }
     session()->flash('flash_message', ['title' => 'Success!', 'message' => 'Your vote has been counted.', 'type' => 'success']);
     return redirect('poll/' . $poll->slug . '/result');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //If user hasn't selected any options, carry on to form validation / rejection
     if (!$request->input('option.0')) {
         return $next($request);
     }
     $poll = Option::findOrFail($request->input('option.0'))->poll;
     //if we already have this user's IP stored and linked to the poll they are trying to vote on
     //flash an error and redirect to results.
     if ($poll->ip_checking == 1) {
         if (Voter::where('ip_address', '=', $request->ip())->where('poll_id', '=', $poll->id)->exists()) {
             session()->flash('flash_message_confirm', ['title' => 'Error!', 'message' => 'You have already vote on this poll. Your vote has not been counted.', 'type' => 'error']);
             return redirect('poll/' . $poll->slug . '/result');
         }
     }
     return $next($request);
 }
 private function prepareData($data)
 {
     $descriptionPayment = "";
     $total = 0;
     $product = Product::findOrFail($data['product_id']);
     if ($product->option_id) {
         $product->published = 1;
         $product->featured = $product->option_id != 1 ? $product->featured = 1 : 0;
         $product->save();
         $option = Option::findOrFail($product->option_id);
         $descriptionPayment .= $option->name . ' ' . $option->price;
         $total += $option->price;
     }
     if ($product->tags->count()) {
         $descriptionPayment .= ' - Etiqueta: ' . $product->tags->first()->name . ' ' . $product->tags->first()->price;
         $total += $product->tags->first()->price;
     }
     $data = array_add($data, 'user_id', auth()->user()->id);
     $data = array_add($data, 'description', $descriptionPayment);
     $data = array_add($data, 'amount', $total);
     $data = array_add($data, 'operationNumber', $data['purchaseOperationNumber']);
     return $data;
 }
Esempio n. 6
0
 public function tick(Questionnaire $questionnaire, Request $request)
 {
     $ticks = $request->input('tick');
     $user = Auth::user();
     foreach ($ticks as $key => $tick) {
         if (!empty($tick)) {
             Tick::create(['user_id' => $user->id, 'questionnaire_id' => $questionnaire->id, 'question_id' => $key, 'option_id' => $tick]);
             Option::findOrFail($tick)->addTick();
         }
     }
     Flash::success('questionnaire sent successfully');
     return redirect(route('home.questionnaire.preview', ['profile' => $user->id, 'questionnaire' => $questionnaire->id]));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $option = Option::findOrFail($id);
     $option->delete();
     return redirect()->route('options.index')->with('message', 'Item deleted successfully.');
 }
 /**
  * Update the specified resource in storage.
  * PUT /options/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($optionGroupId, $id, Request $request)
 {
     $option = Option::findOrFail($id);
     $this->validate($request, Option::$rules);
     $option->update($request->all());
     return redirect('optiongroups/' . $optionGroupId . '/options')->with('success', l('This record has been successfully updated &#58&#58 (:id) ', ['id' => $id], 'layouts') . $request->get('name'));
 }
 /**
  * @param $productId
  * @return array
  */
 private function getPurchasedOptions($productId)
 {
     $product = $this->productRepository->findById($productId);
     $option = $product->option_id ? Option::findOrFail($product->option_id) : null;
     $items = [];
     $total = 0;
     $totalDollar = 0;
     if ($option) {
         $optionItem = ['name' => $option->name, 'price' => $option->price, 'priceDollar' => number_format($option->price / 540, 2)];
         if ($product->option_id == 4) {
             $priceTag = $product->tags->count() ? $product->tags->first()->price : 0;
             $optionItem['price'] = $priceTag;
             $optionItem['priceDollar'] = number_format($option->price / 530, 2);
             $optionItem['name'] .= $product->tags->count() ? ' Etiqueta: ' . $product->tags->first()->name : 'No escogio etiqueta';
         }
         $items[] = $optionItem;
     }
     foreach ($items as $item) {
         $total += $item['price'];
         $totalDollar += $item['priceDollar'];
     }
     return array($product, $items, $total, $totalDollar);
 }