コード例 #1
0
ファイル: ProductController.php プロジェクト: dhduc/shopui
 public function product($id)
 {
     // Product Detail
     $product = Product::find($id);
     $producer = Producer::find($product->producer);
     $producerItem = "<a href='" . URL::to('/') . "/producer/" . $producer->id . "/" . strtolower($producer->producer) . ".html'>" . $producer->producer . "</a>";
     // Category
     $productCategoryID = Product::find($id)->category_id;
     // breadcrumb
     $breadcrumb = $this->breadcrumb($productCategoryID, $id);
     // Best Seller
     $bestSeller = $this->bestSeller();
     $image = Images::where('productID', $product['id'])->first();
     $thumbnail = $image['imageSrc'];
     $thumbnailImage = '<a class="preView" rel="' . URL::to('/') . '/' . $thumbnail . '"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt="" class="img-responsive"></a>';
     $images = Images::where('productID', $id)->get();
     $listImages = "";
     foreach ($images as $image) {
         $img = $image['imageSrc'];
         $listImages .= '<a href="' . URL::to('/') . '/' . $img . '" class="fancybox-button" rel="photos-lib"><img alt="Berry Lace Dress" src="' . URL::to('/') . '/' . $img . '"></a>';
     }
     $review = '<div class="fb-comments" data-href="' . URL::to('/') . '/product/' . $id . '"
             data-num-posts="10" data-width="700px"></div>';
     return view('home.product.detail')->with(['breadcrumb' => $breadcrumb, 'product' => $product, 'producer' => $producerItem, 'bestSeller' => $bestSeller, 'thumbnailImage' => $thumbnailImage, 'listImages' => $listImages, 'review' => $review]);
 }
コード例 #2
0
ファイル: SliderController.php プロジェクト: dhduc/shopui
 public function destroy($id)
 {
     $Src = Images::find($id)->imageSrc;
     $imageSrc = URL::to('/') . '/' . $Src;
     File::delete($imageSrc);
     Images::find($id)->delete();
     return redirect(URL::previous())->withSuccess(Lang::get('messages.delete_success'));
 }
コード例 #3
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function dashboard()
 {
     //
     $usercount = User::all()->count();
     $activecount = User::where('status', '=', 1)->count();
     $imagescount = Images::all()->count();
     $albumcount = Album::all()->count();
     return view('admin.dashboard')->with(['imagescount' => $imagescount, 'albumcount' => $albumcount, 'usercount' => $usercount, 'activeuser' => $activecount, 'fname' => 'Muhammad Adeel ']);
 }
コード例 #4
0
ファイル: ImagesController.php プロジェクト: dhduc/shopui
 public function destroy($id)
 {
     DB::transaction(function () use($id) {
     });
     $imageSrc = Images::find($id)->imageSrc;
     unlink($imageSrc);
     Images::find($id)->delete();
     DB::commit();
     return redirect(URL::previous())->withSuccess(Lang::get('messages.delete_success'));
 }
コード例 #5
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     view()->composer('_recent', function ($view) {
         $data = Images::leftJoin('albums', 'images.album_id', '=', 'albums.id')->leftJoin('users', 'images.user_id', '=', 'users.id')->select('images.*', 'albums.name as albumname', 'users.name as username')->limit(4)->where("images.status", "=", 'Public')->orderBy('images.id', 'desc')->get();
         $view->with("recent", $data);
     });
     view()->composer('_album', function ($view) {
         $data = Album::leftJoin('album_types', 'albums.albumtype_id', '=', 'album_types.id')->select('albums.*', 'album_types.name as typename')->orderBy('albums.id', 'desc')->get();
         $view->with("albums", $data);
     });
 }
コード例 #6
0
 public function postMove()
 {
     $rules = array('new_album' => 'required|numeric|exists:albums,id', 'photo' => 'required|numeric|exists:images,id');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('index');
     }
     $image = Images::find(Input::get('photo'));
     $image->album_id = Input::get('new_album');
     $image->save();
     return Redirect::route('show_album', array('id' => Input::get('new_album')));
 }
コード例 #7
0
 public function getViewProduct($id)
 {
     $product = Products::findOrFail($id);
     $brands = Brands::all();
     $models = Models::all();
     $productImages = DB::table('product_images')->where('in_product', $id)->get();
     $randProducts = Products::orderBy(DB::raw('RAND()'))->take(3)->get();
     $randImages = Images::all();
     $price_text = '';
     if ($product->price_count == 'yes') {
         $price_text = 'за брой';
     }
     return view('pages.view-product')->with('product', $product)->with('brands', $brands)->with('models', $models)->with('productImages', $productImages)->with('randProducts', $randProducts)->with('randImages', $randImages)->with('price_text', $price_text);
 }
コード例 #8
0
 function imageUpload()
 {
     if (Auth::check()) {
         if (Input::hasFile('img')) {
             $imageFile = Input::file('img');
             $filename = time() . '.' . $imageFile->getClientOriginalExtension();
             $imageModel = new Images();
             $imageModel->name = $filename;
             $imageModel->ext = $imageFile->getClientOriginalExtension();
             $imageModel->save();
             $imageFile->move('uploads', $filename);
         }
         return view('admin.ImageUpload');
     } else {
         return redirect('login');
     }
 }
コード例 #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $product = Product::find($id);
     $this->validate($request, ['title' => 'required|max:255', 'description' => 'required', 'price' => 'integer|between:0,30000']);
     $title = Input::get('title');
     $description = Input::get('description');
     $price = Input::get('price');
     $oldPhotos = Input::get('oldPhotos');
     $colors = Input::get('color');
     $categories = Input::get('categories');
     $product->update(['title' => $title, 'description' => $description, 'price' => $price]);
     $images = Input::file('photos');
     $colors = Input::get('color');
     $photos = [];
     $photos_ids = [];
     if ((is_array($images) || is_object($images)) && !($images[0] == null)) {
         for ($i = 0; $i < sizeof($images); $i++) {
             //dd($images);
             $image = $images[$i];
             $color = $colors[$i];
             srand(time());
             $filename = rand() . $i . '.' . $image->getClientOriginalExtension();
             //save image
             Images::create(['color' => $color, 'img' => $filename, 'alt' => '123']);
             $path = storage_path() . '/app/images/' . $filename;
             $im = Image::make($image->getRealPath());
             if ($im->width() > 900) {
                 $im->resize(900, null, function ($c) {
                     $c->aspectRatio();
                     $c->upsize();
                 });
             }
             $im->save($path);
             $p = Images::where('img', $filename)->first();
             array_push($photos, $p);
             array_push($photos_ids, $photos[$i]->id);
         }
     }
     if (isset($categories)) {
         $product->category()->sync($categories);
     }
     if (is_array($oldPhotos) && !is_array($photos_ids)) {
         $allPhotos = $oldPhotos;
         $product->images()->sync($allPhotos);
     }
     if (is_array($photos_ids) && !is_array($oldPhotos)) {
         $allPhotos = $photos_ids;
         $product->images()->sync($allPhotos);
     }
     if (is_array($photos_ids) && is_array($oldPhotos)) {
         $allPhotos = array_merge($photos_ids, $oldPhotos);
         $product->images()->sync($allPhotos);
     }
     return redirect()->back()->with('message', ' პროდუქტი განხლდა');
 }
コード例 #10
0
 public function getCart()
 {
     $content = Cart::content();
     $images = Images::all();
     return view('pages.cart')->with('content', $content)->with('images', $images);
 }
コード例 #11
0
 public function publicShow($id)
 {
     $trap = Traps::findOrFail($id);
     $images = Images::where('trap_id', $id)->get();
     return view('home.show_trap')->with('trap', $trap)->with('images', $images);
 }
コード例 #12
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $image = Images::find($id);
     $image->delete();
     //  return redirect()->back();
 }
コード例 #13
0
 public function GetCommentsOnDoctor()
 {
     $doc = json_decode($_COOKIE['doctor_user'], true);
     $doc_id = $doc[0]['doc_id'];
     // this should be replaced by $COOKIE reference
     try {
         $comments = Comments::whereDoctor_id($doc_id)->orderBy('id', 'DESC')->limit(20)->get();
         foreach ($comments as $com) {
             $pat = Patients::whereUser_id($com->user_id)->first();
             $img = Images::whereUser_id($pat->user_id)->first();
             $main_ob['com_data'] = $com;
             $main_ob['pat_first_name'] = $pat->first_name;
             $main_ob['pat_last_name'] = $pat->last_name;
             $main_ob['pat_img'] = $img->image_path;
             $res[] = $main_ob;
         }
     } catch (Exception $e) {
         $this->LogError('AjaxController Get Comments On Doctor Function', $e);
     }
     return response()->json($res);
 }
コード例 #14
0
 public function get_comments_by_user(Request $request)
 {
     $user = json_decode($_COOKIE['user'], true);
     try {
         $comments = Comments::whereUser_id($user[0]['id'])->orderBy('id', 'DESC')->limit(20)->get();
         foreach ($comments as $com) {
             $doc = Doctors::find($com->doctor_id);
             $img = Images::whereUser_id($doc->user_id)->first();
             $main_ob['com_data'] = $com;
             $main_ob['doc_first_name'] = $doc->first_name;
             $main_ob['doc_last_name'] = $doc->last_name;
             $main_ob['doc_img'] = $img->image_path;
             $res[] = $main_ob;
         }
     } catch (Exception $e) {
         $this->LogError('AjaxController Get_Comments_By_User Function', $e);
     }
     return response()->json($res);
 }
コード例 #15
0
ファイル: ImageController.php プロジェクト: timurAbl93/site
 public function deleteImages($id)
 {
     Images::deleteImagesByID($id);
     return redirect()->back();
 }
コード例 #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->only('name', 'modelNo', 'price', 'description', 'category_id', 'brand', 'quantityInStock', 'size', 'sale', 'timeSale');
     $validator = $this->validator($input);
     if ($validator->fails()) {
         return redirect('admin/product_add')->withErrors($validator);
     } else {
         $product = new Products();
         $product->name = $request->input('name');
         $product->modelNo = $request->input('modelNo');
         $product->price = $request->input('price');
         $product->sale = $request->input('sale');
         $product->timeSale = $request->input('timeSale');
         $product->description = $request->input('description');
         $product->category_id = $request->input('category_id');
         $product->brand = $request->input('brand');
         $product->quantityInStock = $request->input('quantityInStock');
         $product->save();
         $sizes = $request->input('size');
         foreach ($sizes as $size) {
             $productSize = new productSize();
             $productSize->name = $size;
             $productSize->product_id = $product->id;
             $productSize->save();
         }
         $imageName = '';
         $images = $request->file('image');
         foreach ($images as $image) {
             $rules = ['image' => 'required|image|mimes:jpg,jpeg,png,gif|image_size:<=30000'];
             $validator = Validator::make(array('image' => $image), $rules);
             if ($validator->passes()) {
                 global $imageName;
                 $rand = rand(1, 10000);
                 $imageName = $rand . '.' . $request->input('modelNo') . '.' . $image->getClientOriginalExtension();
                 $image->move(base_path() . '/public/images_product', $imageName);
                 $image = new Images();
                 $image->name = 'images_product/' . $imageName;
                 $image->product_id = $product->id;
                 $image->save();
             } else {
                 return redirect('admin/product_add')->withErrors($validator);
             }
         }
         return redirect('admin/product_list');
     }
 }
コード例 #17
0
ファイル: HomeController.php プロジェクト: dhduc/shopui
 public function allProducts($type = "", $id = 0, $search = "")
 {
     if ($type == "new") {
         $products = DB::table('product')->orderBy('id', 'desc')->paginate(4)->toArray();
     } else {
         if ($type == "best_seller") {
             $products = DB::table('product')->orderBy('purchase', 'desc')->paginate(4)->toArray();
         } else {
             if ($type == 'search') {
                 $products = DB::table('product')->where('name', 'LIKE', '%' . $search . '%')->paginate(8)->toArray();
             }
         }
     }
     $allProduct = array();
     foreach ($products['data'] as $product) {
         $allProduct[] = $product;
     }
     $allProductInView = "";
     foreach ($allProduct as $item) {
         $description = $item->description;
         $producerName = Producer::find($item->producer)->producer;
         $images = Images::where('productID', $item->id)->first();
         $thumbnail = $images['imageSrc'];
         $allProductInView .= '<div class="col-lg-3 col-sm-6">';
         $allProductInView .= '<div class="thumbnail">';
         $allProductInView .= '<a class="preview" rel="' . URL::to('/') . '/' . $thumbnail . '" href="' . URL::to('/product') . '/' . $item->id . '/' . $item->name . '.html" class="post-image-link">';
         $allProductInView .= '<p><img src="' . URL::to('/') . '/' . $thumbnail . '" class="img-responsive" alt="' . strtolower($item->name) . '"></p>';
         $allProductInView .= '</a>';
         $allProductInView .= '<div class="caption">';
         $allProductInView .= '<h3><a href="' . URL::to('/product') . '/' . $item->id . '/' . strtolower($item->name) . '.html">' . $item->name . '</a></h3>';
         $allProductInView .= substr($description, 0, 70) . '<br>';
         $allProductInView .= '<span class="btn btn-default"><i class="fa fa-cart"></i>' . $item->price . '$</span>';
         $allProductInView .= '<a href="' . URL::to('/') . '/producer/' . $item->producer . '/' . strtolower($producerName) . '.html" class="btn btn-primary">' . $producerName . '</a>';
         $allProductInView .= '</div>';
         $allProductInView .= ' </div></div>';
     }
     return $allProductInView;
 }
コード例 #18
0
 public function deleteImage(Request $request)
 {
     if (Auth::user()->email == '*****@*****.**') {
         Images::where('id', $request->input('image_id'))->delete();
         return redirect()->back()->with($request->session()->flash('admin-success', 'Успешно изтрихте снимка.'));
     }
 }
コード例 #19
0
ファイル: ProductController.php プロジェクト: dhduc/shopui
 public function setThumbnail()
 {
     $products = Product::all()->toArray();
     foreach ($products as $item) {
         $images = Images::where('productID', $item['id'])->first();
         $thumbnail = $images['imageSrc'];
         $model = Product::find($item['id']);
         $model->thumbnail = $thumbnail;
         $model->save();
     }
     return redirect_success('Admin\\ProductController@index', "Set Thumbnail Success");
 }
コード例 #20
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $type = '')
 {
     //
     $data = Images::find($id);
     if (Gate::denies('delete', $data)) {
         abort(403, "You have no rights to do this ");
     } else {
         File::delete(public_path() . "\\uploads\\images\\" . $data->name);
         $isdelete = $data->delete();
         if ($type == '') {
             $response = Response::json(array("files" => "Success"));
             return $response;
         } else {
             return redirect('/images/list/' . $type)->with('status', "File Removed  Successfully");
         }
     }
 }
コード例 #21
0
ファイル: CategoryController.php プロジェクト: dhduc/shopui
 public function allProductInCategory($id = 0, $type = "", $order = "")
 {
     $this->allCategoryId($id);
     if ($type == "all" and $order == "") {
         $products = DB::table('product')->whereIn('category_id', $this->allID)->paginate(9)->toArray();
     } else {
         if ($type == "name" and $order == "asc") {
             $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("name", "asc")->paginate(9)->toArray();
         } else {
             if ($type == "name" and $order == "desc") {
                 $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("name", "desc")->paginate(9)->toArray();
             } else {
                 if ($type == "price" and $order == "asc") {
                     $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("price", "asc")->paginate(9)->toArray();
                 } else {
                     if ($type == "price" and $order == "desc") {
                         $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("price", "desc")->paginate(9)->toArray();
                     }
                 }
             }
         }
     }
     $allProduct = array();
     foreach ($products['data'] as $product) {
         $allProduct[] = $product;
     }
     $allProductInView = "";
     foreach ($allProduct as $item) {
         $description = $item->description;
         $producerName = Producer::find($item->producer)->producer;
         $images = Images::where('productID', $item->id)->first();
         $thumbnail = $images['imageSrc'];
         $allProductInView .= '<div class="col-md-4 col-sm-6 col-xs-12">';
         $allProductInView .= '<div class="thumbnail">';
         $allProductInView .= '<a class="preview" rel="' . URL::to('/') . '/' . $thumbnail . '" href="' . URL::to('/product') . '/' . $item->id . '/' . $item->name . '.html" class="post-image-link">';
         $allProductInView .= '<p><img src="' . URL::to('/') . '/' . $thumbnail . '" class="img-responsive" alt="' . strtolower($item->name) . '"></p>';
         $allProductInView .= '</a>';
         $allProductInView .= '<div class="caption">';
         $allProductInView .= '<h3><a href="' . URL::to('/product') . '/' . $item->id . '/' . strtolower($item->name) . '.html">' . $item->name . '</a></h3>';
         $allProductInView .= substr($description, 0, 70) . '<br>';
         $allProductInView .= '<span class="btn btn-default"><i class="fa fa-cart"></i>' . $item->price . '$</span>';
         $allProductInView .= '<a href="' . URL::to('/') . '/producer/' . $item->producer . '" class="btn btn-primary">' . $producerName . '</a>';
         $allProductInView .= '</div>';
         $allProductInView .= ' </div></div>';
     }
     return $allProductInView;
 }
コード例 #22
0
ファイル: Front.php プロジェクト: Bmax-Tech/SEP-Prototype_MVC
 public function get_community_suggestions()
 {
     try {
         $com_sug = Doctors::whereDoc_type('NON_FORMAL')->orderBy('id', 'DESC')->limit(5)->get();
         foreach ($com_sug as $doc) {
             $temp['doc_id'] = $doc->id;
             $temp['doc_first_name'] = $doc->first_name;
             $temp['doc_last_name'] = $doc->last_name;
             $temp['doc_address_2'] = $doc->address_2;
             $temp['doc_city'] = $doc->city;
             /* Get suggested User */
             $non_formal = Non_Formal_doctors::whereDoctor_id($doc->id)->first();
             $user = User::whereId($non_formal->suggested_user)->first();
             $temp['sug_user_name'] = $user->name;
             /* Get suggested User Image */
             $img = Images::whereUser_id($user->id)->first();
             $temp['image_path'] = $img->image_path;
             $featured_main[] = $temp;
         }
     } catch (Exception $e) {
         $this->LogError('Get Community Suggestion Doctors Function', $e);
     }
     return $featured_main;
 }
コード例 #23
0
ファイル: CartController.php プロジェクト: dhduc/shopui
    public function allItem($type)
    {
        $allItem = "";
        $total = 0;
        if (Session::has('product')) {
            $products = Session::get('product');
            if (count($products) > 0) {
                foreach ($products as $item) {
                    $images = Images::where('productID', $item["id"])->first();
                    $thumbnail = $images['imageSrc'];
                    if ($type == "view") {
                        $allItem .= '<td class="goods-page-image"><input type="hidden" name="id[]" value="' . $item["id"] . '" />
                            <a href="' . URL::to('/product/') . '/' . $item["id"] . '" target="_blank"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt=""></a>
                            </td>';
                        $allItem .= '<td class="goods-page-description">
                         <h3><a href="' . URL::to('/product/') . '/' . $item["id"] . '" target="_blank">' . $item['name'] . '</a></h3>
                            </td>';
                        $allItem .= '<td class="goods-page-quantity">
                            <div class="product-quantity">
                            <div class="input-group bootstrap-touchspin input-group-sm"><span class="input-group-btn">
                            <button class="btn quantity-down bootstrap-touchspin-down" type="button">
                            <i class="fa fa-angle-down"></i></button></span>
                            <span class="input-group-addon bootstrap-touchspin-prefix" style="display: none;"></span>
                            <input name="number[]" id="product-quantity" type="text" value="' . $item['number'] . '" readonly="" class="form-control input-sm" style="display: block;"><span class="input-group-addon bootstrap-touchspin-postfix" style="display: none;"></span><span class="input-group-btn"><button class="btn quantity-up bootstrap-touchspin-up" type="button"><i class="fa fa-angle-up"></i></button></span></div>
                            </div>
                          </td>';
                        $allItem .= '<td class="goods-page-price">
                            <strong><span>$</span>' . $item['price'] . '</strong>
                            </td>';
                        $allItem .= '<td class="goods-page-total">
                            <strong><span>$</span>' . $item['total'] . '</strong>
                            </td>';
                        $allItem .= '<td class="del-goods-col">
                            <a class="del-goods" href="' . URL::to('/cart/remove') . '/' . $item['id'] . '">&nbsp;</a>
                         </td></tr>';
                    } else {
                        if ($type == "checkout") {
                            $allItem .= '<tr><input type="hidden" name="productID[]" value="' . $item['id'] . '" />
                            <td class="goods-page-image">
                            <a href="' . URL::to('/product/') . '/' . $item['id'] . '" target="_blank"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt=""></a>
                            </td>';
                            $allItem .= '<td class="goods-page-description">
                         <h3><a href="' . URL::to('/product/') . '/' . $item['id'] . '" target="_blank">' . $item['name'] . '</a></h3>
                            </td>';
                            $allItem .= '<td class="goods-page-quantity">
                            <div class="">
                                <h3>' . $item['number'] . '</h3>
                                <input name="pQty[]" id="product-quantity" type="hidden" value="' . $item['number'] . '" readonly class="form-control input-sm" style="display: block;">

                            </div>
                          </td>';
                            $allItem .= '<td class="goods-page-price">
                            <strong><span>$</span>' . $item['price'] . '</strong>
                            </td>';
                            $allItem .= '<td class="goods-page-total">
                            <strong><span>$</span>' . $item['total'] . '</strong>
                            </td></tr>';
                        }
                    }
                    $total += $item['total'];
                }
                $this->total = $total;
            } else {
                return redirect(URL::to('/'))->withSuccess("Shopping cart empty");
            }
        } else {
            return redirect(URL::to('/'))->withSuccess("Shopping cart empty");
        }
        return $allItem;
    }
コード例 #24
0
ファイル: Images.php プロジェクト: timurAbl93/site
 public static function createImages($image)
 {
     Images::create(['image' => $image->getClientOriginalName()]);
     $image->move('images/slider', $image->getClientOriginalName());
 }
コード例 #25
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $image = Images::find($id);
     return view('gallery.show', compact('image'));
 }