Пример #1
0
 public function show_for_other_user($user_id)
 {
     $list = Lists::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-130x90.' . $initial[sizeof($initial) - 1];
             //thumb size changed
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return response()->json(['list' => $user_list]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     // Show campaign edit for selected campaign
     $campaign = \App\Campaigns::findorFail($id);
     $lists = \App\Lists::get();
     $templates = \App\Templates::take(10)->get();
     return view('campaigns.edit', compact('campaign'))->with('lists', $lists)->with('templates', $templates);
 }
Пример #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $topic = Lists::findOrFail($id);
     $input = array_except($request->input(), '_method');
     if ($topic->update($input)) {
         return $topic;
     } else {
         return $errors;
     }
 }
Пример #4
0
 public static function add_created_by_and_category($products)
 {
     if (get_class($products) == 'App\\Product') {
         $product = $products;
         $created_by = $product['created_by'];
         $user = User::find($created_by);
         $category = Category::find($product['category_id']);
         $category = $category['category'];
         array_add($product, 'category', $category);
         array_add($product, 'created_by_name', $user['name']);
         array_add($product, 'temp', '');
         //return $product->image_url;
         $initial = explode(".", $product['image_url']);
         $thumbFirst = "";
         for ($i = 0; $i < sizeof($initial) - 1; $i++) {
             $thumbFirst = $thumbFirst . $initial[$i];
         }
         $thumbnail = $thumbFirst . '-200x200.' . $initial[sizeof($initial) - 1];
         $bigPic = $thumbFirst . '-400x400.' . $initial[sizeof($initial) - 1];
         array_add($product, 'thumbnail', $thumbnail);
         array_add($product, 'bigPic', $bigPic);
         //Complete this shit
         if (Auth::check()) {
             $user_id = Auth::user();
             $user_id = $user_id->id;
             $vote = Vote::where('user_id', '=', $user_id)->where('product_id', '=', $product['id'])->get();
             $list = Lists::where('user_id', '=', $user_id)->where('product_id', '=', $product['id'])->get();
             if ($vote->isEmpty() == False) {
                 array_add($product, 'can_vote', False);
             } else {
                 array_add($product, 'can_vote', True);
             }
             if ($list->isEmpty() == False) {
                 array_add($product, 'can_list', False);
             } else {
                 array_add($product, 'can_list', True);
             }
         } else {
             array_add($product, 'can_vote', False);
             array_add($product, 'can_list', False);
         }
         return $products;
     } else {
         $temp = '';
         foreach ($products as $product) {
             if ($product->created_at_date == $temp) {
                 array_add($product, 'date2', '');
             } else {
                 $monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                 $date = explode('-', $product->created_at_date);
                 $tempDate = $product->created_at_date;
                 $day = date('l', strtotime($tempDate));
                 $dateM = ltrim($date[2], '0');
                 array_add($product, 'date2', $day . ',  ' . $dateM . 'th ' . $monthNames[intval($date[1]) - 1]);
                 $temp = $product->created_at_date;
             }
             //     $created_by = $product->created_by;
             //     $user = User::find($created_by);
             //     $category = Category::find($product->category_id);
             //     $category = $category['category'];
             //     array_add($product, 'category', $category);
             //     array_add($product, 'created_by_name', $user['name']);
             //     array_add($product, 'temp', '');
             //     $initial = explode(".", $product->image_url);
             //     $thumbFirst = "";
             //     for( $i=0; $i<sizeof($initial)-1; $i++ ){
             //         $thumbFirst = $thumbFirst.$initial[$i];
             //     }
             //      $thumbnail = $thumbFirst.'-200x200.'.$initial[sizeof($initial)-1];
             //  $bigPic = $thumbFirst.'-400x400.'.$initial[sizeof($initial)-1];
             // array_add($product, 'thumbnail', $thumbnail);
             // array_add($product, 'bigPic', $bigPic);
             //     if (Auth::check()) {
             //         $user_id = Auth::user();
             //         $user_id = $user_id->id;
             //         $vote = Vote::where('user_id', '=', $user_id)
             //             ->where('product_id', '=', $product->id)
             //             ->get();
             //         $list = Lists::where('user_id', '=', $user_id)
             //             ->where('product_id', '=', $product->id)
             //             ->get();
             //         if ($vote->isEmpty()==False){
             //             array_add($product, 'can_vote', False);
             //         }
             //         else{
             //             array_add($product, 'can_vote', True);
             //         }
             //         if ($list->isEmpty()==False){
             //             array_add($product, 'can_list', False);
             //         }
             //         else{
             //             array_add($product, 'can_list', True);
             //         }
             //     }
             //       else{
             //     array_add($product, 'can_vote', False);
             //     array_add($product, 'can_list', False);
             // }
         }
         return $products;
     }
 }
Пример #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $list = Lists::findOrFail($id);
     $list->delete();
     Session::flash('flash_message', 'List successfully deleted!');
     return redirect()->route('lists.index');
 }
Пример #6
0
 public function destroy($id)
 {
     Lists::find($id)->delete();
     return Redirect::route('modules.lists.index');
 }
Пример #7
0
 public function update($id, CreateListsRequest $request)
 {
     $response = Lists::findorfail($id)->update($request->all());
     return Response(var_export($response), 201);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $list = \App\Lists::findOrFail($id);
     $new = \App\Lists::delete($input);
     session()->flash('flash_message', '' . $new->name . ' Removed from Lists!');
 }