コード例 #1
2
 /**
  * @param Request $request
  * @param $comment_id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(Request $request)
 {
     $comment_id = $request->input('comment_id');
     $comment = Comments::where('id', $comment_id)->first();
     $user = $request->user();
     if ($user->is_admin() or $user->is_moderator() or $user->id == $comment->user_id) {
         $content = $request->input('content');
         $comment->content = $content;
         $comment->save();
         $product = Products::where('id', $comment->on_product)->first();
         return redirect('/product/' . $product->slug);
     } else {
         redirect('/')->withErrors('You have not sufficient permissions');
     }
 }
コード例 #2
1
 public function digitalCatalogs()
 {
     $page = 'produtos';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     $productsCategories = ProductsCategories::orderBy('sortorder', 'asc')->get();
     $activePrinciples = Products::addSelect(DB::raw('DISTINCT(activePrinciple)'))->where('activePrinciple', '!=', '')->orderBy('activePrinciple', 'asc')->get();
     foreach ($activePrinciples as $activePrinciple) {
         array_add($activePrinciple, 'activePrincipleSlug', str_slug($activePrinciple->activePrinciple, '-'));
     }
     $digitalCatalogs = DigitalCatalogs::orderBy('sortorder', 'asc')->paginate(3);
     $categoryChosen = "Catálogos Digitais";
     $categoryChosenSlug = "catalogos-digitais";
     return view('website.products.digitalCatalogs')->with(compact('page', 'pages', 'websiteSettings', 'productsCategories', 'digitalCatalogs', 'categoryChosen', 'categoryChosenSlug', 'activePrinciples', 'activePrincipleChosenSlug'));
 }
コード例 #3
0
 public function getBasked(Products $products, Slider $slider, Delivery $delivery)
 {
     if (Session::get('product')) {
         $this->data['delivery'] = $delivery->getDeliveryActive();
         $productsBasked = Session::get('product');
         $this->data['countProducts'] = collect($productsBasked);
         $productsId = '';
         $k = 0;
         foreach ($productsBasked as $id) {
             if ($k == 0) {
                 $productsId = $id['id'];
                 $k++;
             } else {
                 $productsId = $productsId . ' ,' . $id['id'];
             }
         }
         $this->data['bascedProducts'] = collect($products->getBascedProducts($productsId));
     } else {
         $this->data['bascedErrr'] = 'Корзина пуста';
     }
     $this->data['slides'] = $slider->getActive();
     $this->data['products'] = $products->getActive();
     if (\Auth::user()) {
         $this->data['name'] = \Auth::user()->name;
         $this->data['address'] = \Auth::user()->address;
         $this->data['email'] = \Auth::user()->email;
         $this->data['number'] = \Auth::user()->number;
     }
     return view('pages.cart', $this->data);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('products', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('colors');
         $table->string('sizes');
         $table->text('content');
         $table->integer('price')->unsigned;
         $table->string('picture');
         $table->string('size_picture');
         $table->timestamps();
         $table->string('seller_id');
     });
     $prosJson = File::get(storage_path() . '/data/seed.json');
     $pros = json_decode($prosJson);
     foreach ($pros as $proData) {
         $pro = new Products();
         $pro->name = $proData->name;
         $pro->colors = '["black", "white"]';
         $pro->sizes = '["S", "M", "L"]';
         $pro->content = 'This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.This is a the content of the clothes.';
         $proData->price = str_replace('$', '', $proData->price);
         $pro->price = str_replace(',', '', $proData->price);
         $pro->picture = $proData->picture;
         if (isset($proData->{'size-picture'})) {
             $pro->size_picture = $proData->{'size-picture'};
         }
         $pro->seller_id = 'A1234';
         $pro->save();
     }
 }
コード例 #5
0
 public function show_product($id)
 {
     $products = new Products();
     $result_category = $products->get_category_by_id($id);
     $subProducts = new SubProducts();
     $result_sub_category = $subProducts->get_sub_category_by_category_id($id);
     return view('auth/show_products')->with(array('result_category' => $result_category, 'result_sub_category' => $result_sub_category));
 }
コード例 #6
0
 public function search(Slider $slider, Products $products)
 {
     $search = Input::all();
     $search = $this->parsing($search['search']);
     $this->data['products'] = $products->searchProduct($search);
     $this->data['slides'] = $slider->getActive();
     return view('pages.index', $this->data);
 }
コード例 #7
0
 public function index()
 {
     $products = new Products();
     $sub_products = new SubProducts();
     $result_category = $products->get_category();
     foreach ($result_category as $results_category) {
         $menu_result[$results_category->category_name] = $sub_products->get_sub_category_by_category_id($results_category->id);
     }
     return view('index', compact('result_category', 'menu_result'));
 }
コード例 #8
0
ファイル: AboutController.php プロジェクト: GrigorAtaryan/vdc
 public function get()
 {
     $about = new About();
     $data_about = $about->get_about();
     $products = new Products();
     $sub_products = new SubProducts();
     $result_category = $products->get_category();
     foreach ($result_category as $results_category) {
         $menu_result[$results_category->category_name] = $sub_products->get_sub_category_by_category_id($results_category->id);
     }
     return view('about', compact('result_category', 'menu_result', 'data_about'));
 }
コード例 #9
0
 public function get()
 {
     $partners = new Partners();
     $data_partners = $partners->get_partners();
     $products = new Products();
     $sub_products = new SubProducts();
     $result_category = $products->get_category();
     foreach ($result_category as $results_category) {
         $menu_result[$results_category->category_name] = $sub_products->get_sub_category_by_category_id($results_category->id);
     }
     return view('partners', compact('result_category', 'menu_result', 'data_partners'));
 }
コード例 #10
0
 public function show($id)
 {
     $design_collection = Designs::all();
     $art_collection = Products::all();
     $displayed_design = Designs::findorfail($id);
     return view('backend.admin.design.edit', compact('design_collection', 'art_collection', 'displayed_design', 'displayed_art'));
 }
コード例 #11
0
 public static function LovedProduct($get = "all")
 {
     $arrayListId = [];
     $arrayProductId = [];
     $detailProducts = [];
     /*get user id*/
     $customer_id = Auth::user()->id;
     /*get list id*/
     $loveListId = LoveList::select(["id"])->where("customer_id", $customer_id)->get();
     foreach ($loveListId as $id) {
         $arrayListId[] = $id->id;
     }
     /*get product id of list*/
     if (isset($arrayListId)) {
         $lovedProducts = LoveListDetail::select(["product_id"])->whereIn("list_id", $arrayListId)->get();
         foreach ($lovedProducts as $id) {
             $arrayProductId[] = $id->product_id;
         }
     }
     /*get product detail*/
     if ($get == "all") {
         if (isset($arrayProductId)) {
             $detailProducts = Products::getProductById($arrayProductId, "array");
         }
         return $detailProducts;
     } else {
         if ($get == "id") {
             return $arrayProductId;
         }
     }
 }
コード例 #12
0
 public function add_sub_category($id)
 {
     $data_sub_category = Input::all();
     $validator_sub_category = Validator::make(array('sub_category_name' => $data_sub_category['sub_category_name']), array('sub_category_name' => 'required|min:2|max:25'));
     $message = $validator_sub_category->errors();
     if ($validator_sub_category->fails()) {
         return redirect()->back()->with('errors', $message);
     } else {
         $Products = new Products();
         $result_category = $Products->get_category_by_id($id);
         $subProducts = new SubProducts();
         $subProducts->insert_sub_category($id, $data_sub_category);
         $result_sub_category = $subProducts->get_sub_category_by_category_id($id);
         return view('auth/show_products')->with(array('result_category' => $result_category, 'result_sub_category' => $result_sub_category));
     }
 }
コード例 #13
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('products', function ($value) {
         return Products::findOrFail($value);
     });
 }
コード例 #14
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $product = Products::find($id);
     if (is_null($product)) {
         abort(404);
     }
     return view('pages.single', compact('product'));
 }
コード例 #15
0
ファイル: OrderController.php プロジェクト: jbatalla/lpexam
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $allcustomers = \App\Customers::orderBy('first_name')->get();
     $customers = $allcustomers->lists('CustomerFullName', 'id');
     $allproducts = \App\Products::orderBy('product_name')->get();
     $products = $allproducts->lists('ProductShowInfo', 'id');
     //\App\Products::lists('product_name','id');
     return view('orders.create', compact('customers', 'products'));
 }
コード例 #16
0
ファイル: WelcomeController.php プロジェクト: razat91/oa
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     if (Cache::has('products:all')) {
         $products = Cache::get('products:all');
     } else {
         $products = Products::all();
         Cache::put('products:all', $products, 15);
     }
     return view('index', compact("products"));
 }
コード例 #17
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function showCart()
 {
     $carts = Cart::content();
     foreach ($carts as $cart) {
         $products = Products::findOrFail($cart->id);
         $quantityInStock = $products->quantityInStock - $cart->qty;
         DB::table('products')->where('id', '=', $cart->id)->update(['quantityInStock' => $quantityInStock]);
     }
     $total = Cart::total();
     return view('users.pages.cart', compact('carts', 'total'));
 }
コード例 #18
0
ファイル: DatabaseSeeder.php プロジェクト: razat91/oa
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     //DB::table('products')->delete();
     // $this->call('UserTableSeeder');
     for ($i = 1; $i <= 10; $i++) {
         \App\Products::create(['name' => 'Item ' . $i, 'slug' => 'item-' . $i, 'cat_id' => 3, 'amount' => 2 * $i, 'desc' => 'Test test test']);
     }
     \App\Category::create(['name' => 'Рубашки', 'slug' => 'rubashki']);
     $this->command->info('table seeded!');
 }
コード例 #19
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $user = \Auth::user();
     $stock = Stocks::where('branch_id', $user['branch_id'])->get()->toArray();
     $i = 0;
     foreach ($stock as $id) {
         $stock[$i]['product_name'] = Products::where('id', $id['product_id'])->value('p_name');
         $stock[$i]['id'] = $i + 1;
         $i = $i + 1;
     }
     return view('stock', compact('stock'));
 }
コード例 #20
0
 public function index()
 {
     $page = 'produtos';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $pages = Pages::where('slug', '=', $page)->first();
     $advertising = Advertising::orderByRaw("RAND()")->get();
     foreach ($advertising as $ad) {
         array_add($ad, "image", Advertising::imageVideo($ad->url));
         array_set($ad, "url", Advertising::embedVideo($ad->url, 1));
     }
     $calls = Calls::orderByRaw("RAND()")->limit(2)->get();
     $products = Products::orderBy('sortorder', 'ASC')->get();
     return view('website.products')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'products'));
 }
コード例 #21
0
 public function index()
 {
     $title = 'Thinner | Colder';
     $featuredProducts = Products::where('featured', true)->get();
     $featuredDesigns = Designs::where('featured', true)->get();
     for ($index = 0; $index < $featuredProducts->count(); $index++) {
         //$prices = Pricing::where('product_id', $featuredProducts[$index]->id)->get();
         //$ordered = $prices->sortBy('pricing');
         //$lowest = $ordered->first();
         $id = $featuredProducts[$index]->id;
         $featuredProducts[$index]->lowestPrice = Pricing::LowestPrice($id);
     }
     return view('frontend.home', compact('title', 'featuredDesigns', 'featuredProducts'));
 }
コード例 #22
0
 public function show()
 {
     if (\Auth::user()) {
         $carts = Cart::where('cust_id', \Auth::User()->id)->get()->toArray();
         $ids = null;
         if ($carts) {
             $carts = Cart::where('cust_id', \Auth::User()->id)->get();
             $i = 0;
             foreach ($carts as $cart) {
                 $cart['p_name'] = Products::where('id', $cart->product_id)->value('p_name');
                 $cart['price'] = Products::where('id', $cart->product_id)->value('price');
                 $ids[$cart['product_id']] = $cart['product_id'];
             }
         }
         return view('pages.cart', compact('carts'), compact('ids'));
     } else {
         return redirect('auth/login');
     }
 }
コード例 #23
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (\Auth::user()) {
         $order = \Auth::User()->orders();
         $ids = null;
         if ($order) {
             $orders = Orders::where('cust_id', \Auth::User()->id)->get();
         }
         $orders = Orders::where('cust_id', \Auth::User()->id)->where('order_id', $id)->get();
         $i = 0;
         foreach ($orders as $order) {
             $order['p_name'] = Products::where('id', $order->product_id)->value('p_name');
             $order['price'] = Products::where('id', $order->product_id)->value('price');
             $ids[$order['product_id']] = $order['product_id'];
         }
         return view('pages.order', compact('orders'), compact('ids'));
     } else {
         return redirect('auth/login');
     }
 }
コード例 #24
0
 public function infoProducts($products, $id)
 {
     $allPrice = 0;
     $convert = array();
     $infoProduct = array();
     foreach ($products as $item) {
         $infoItem = Products::getPriceItem($item['id']);
         $infoProduct[] = ['info' => $infoItem, 'count' => $item['count']];
         if ($infoItem[0]->newPrice != '0' || $infoItem[0]->newPrice != NULL) {
             $Price = $infoItem[0]->newPrice;
             $allPrice = $allPrice + $infoItem[0]->newPrice * $item['count'];
         } else {
             $Price = $infoItem[0]->price;
             $allPrice = $allPrice + $infoItem[0]->price * $item['count'];
         }
         $convert[] = ['products_id' => $item['id'], 'count' => $item['count'], 'price' => $Price, 'title' => $infoItem[0]->title, 'order_id' => $id];
         OrderItem::insertItemOrder($convert);
     }
     $info = ['infoProduct' => $infoProduct, 'allPrice' => $allPrice];
     return $info;
 }
コード例 #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $id = $request->input('id');
     if ($id == null) {
         return Response::json(array('result' => false, 'message' => 'Product code is valide'));
     }
     //GET PRODUCT
     $product_vol = Products_vol::where('code', $id)->get()->first();
     if ($product_vol == null) {
         return Response::json(array('result' => false, 'message' => 'Product can not defind'));
     }
     $product = Products::where('id', $product_vol->products_id)->first();
     $p_name = $product->name;
     //var_dump($p_name);
     $product_vol->name = $p_name . ' ' . $product_vol->name;
     //var_dump($product_vol->name);
     //ADD TO CART
     $cart = Cart::instance('cartoon');
     $cart->add(array('id' => $product_vol->code, 'name' => $product_vol->name, 'qty' => 1, 'price' => $product_vol->price));
     return Response::json(array('result' => true, 'product' => $product_vol->name, 'cart' => $cart->content(), 'total' => $cart->total(), 'count' => $cart->count()));
 }
コード例 #26
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $dateCusId = DB::select('select * from orders where cast(created_at as DATE) = ? and  CustomerId = ?', array($request['Date'], $request['CustomerId']));
     $customers = Customers::where('id', '=', $request->CustomerId)->get();
     foreach ($request['quantity'] as $key => $tee) {
         $products = Products::where('id', '=', $key)->get();
         $count = DB::select('select count(*) as a from orders where cast(created_at As Date) = ? and CustomerId = ? and ProductId = ?', array($request['Date'], $request['CustomerId'], $key));
         if ($count[0]->a == 0) {
             $InsertDb = DB::table('orders')->insert(array('ProductName' => $products[0]->Name, 'ProductId' => $key, 'CustomerId' => $request->CustomerId, 'CustomerName' => $customers[0]->name, 'quantity' => $tee, 'Alish' => $products[0]->Alish, 'AlishCem' => $tee * $products[0]->Alish, 'Satish' => $products[0]->Satish, 'SatishCem' => $tee * $products[0]->Satish, 'Income' => $products[0]->Income, 'IncomeCem' => $tee * ($products[0]->Satish - $products[0]->Alish), 'created_at' => $request['Date'], 'updated_at' => $request['Date']));
         } else {
             $selectOld = Orders::where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->get();
             DB::table('orders')->where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->update(array('quantity' => $tee, 'AlishCem' => $tee * $selectOld[0]->Alish, 'SatishCem' => $tee * $selectOld[0]->Satish, 'IncomeCem' => $tee * $selectOld[0]->Income));
         }
     }
     //////////////////////////buna bax asahi
     //        $datePurchase = DB::select('select * from purchases where cast(created_at as DATE) = ? and  CustomerId = ?', array($request['Date'], $request['CustomerId']));
     //        DB::table('purchases')
     //            ->where('id', $datePurchase[0]->id)
     //            ->update(array('Borc' => $borc));
     ////////////////////////////////////
     //        DB::table('users')
     //            ->where('id', 1)
     //            ->update(array('votes' => 1));
     //    $test = Products::where('CustomerId', '=', $request['CustomerId'])->get();
     //    foreach ($test as $key => $t2) {
     //        DB::table('orders')->insert(
     //            ['ProductName' => $t2->Name,
     //                'CustomerId' => $request['CustomerName'],
     //                'CustomerName' => $request['CustomerName'],
     //                'quantity' => Input::get("quantity.$key"),
     //                'Alish' => $t2->Alish,
     //                'Satish' => $t2->Satish,
     //                'Income' => Input::get("quantity.$key") * ($t2->Satish - $t2->Alish),
     //                'created_at' => Carbon::now(),
     //                'updated_at' => Carbon::now()]
     //        );
     //    }
     //        Orders::create($request->all());
     return redirect('orders/create');
 }
コード例 #27
0
ファイル: DatabaseSeeder.php プロジェクト: alcom93/WebShop
 public function run()
 {
     DB::table('Products')->delete();
     Products::create(['product_name' => 'Лампочка', 'price' => '100', 'qty' => '10', 'product_type' => 'Для дома', 'product_img' => 'images\\product\\lamp.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Рулетка', 'price' => '200', 'qty' => '10', 'product_type' => 'Для дома', 'product_img' => 'images\\product\\rulet.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Вентилятор', 'price' => '120', 'qty' => '10', 'product_type' => 'Для дома', 'product_img' => 'images\\product\\vent.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Ботинки', 'price' => '260', 'qty' => '10', 'product_type' => 'Развлечение', 'product_img' => 'images\\product\\bot.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Швейцарский нож', 'price' => '80', 'qty' => '10', 'product_type' => 'Развлечение', 'product_img' => 'images\\product\\knife.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Гитара', 'price' => '163', 'qty' => '10', 'product_type' => 'Развлечение', 'product_img' => 'images\\product\\gitar.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Попрыгунчик', 'price' => '30', 'qty' => '10', 'product_type' => 'Разное', 'product_img' => 'images\\product\\prig.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Стэплер', 'price' => '220', 'qty' => '10', 'product_type' => 'Разное', 'product_img' => 'images\\product\\step.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
     Products::create(['product_name' => 'Инструмент', 'price' => '65', 'qty' => '10', 'product_type' => 'Разное', 'product_img' => 'images\\product\\instrum.jpg', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.
         Curabitur semper quam sit amet turpis rhoncus id venenatis tellus sollicitudin.
         Fusce ullamcorper, dolor non mollis pulvinar, turpis tortor commodo nisl,
         et semper lectus augue blandit tellus. Quisque id bibendum libero.']);
 }
コード例 #28
0
 public function update(Request $request)
 {
     $validator = Validator::make($request->all(), ['id' => 'required', 'name' => 'required', 'name_th' => 'required', 'status' => 'required', 'publisher_id' => 'required', 'image' => 'required']);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => 'data is valid.'));
     }
     $now = Carbon::now('Asia/Bangkok');
     $pro = Products::where('id', $request->input('id'))->get()->first();
     $pro->name = $request->input('name');
     $pro->name_th = $request->input('name_th');
     $pro->status = $request->input('status');
     $pro->image = $request->input('image');
     $pro->author = $request->input('author');
     $pro->resume = $request->input('resume');
     $pro->updated_at = $now;
     $pro->publisher_id = $request->input('publisher_id');
     $result = $pro->save();
     if ($result) {
         return Response::json(array('result' => true, 'data' => $pro));
     }
     return Response::json(array('result' => false, 'data' => 'Update has been error.'));
 }
コード例 #29
-1
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if ($this->user_type == 1) {
         // Supplier
         $products = $this->productRepository->findBy('user_id', $this->userid);
         return view('products.supplier', ['products' => $products]);
     } else {
         if ($this->user_type == 2) {
             // Reseller
             $products = Product::all();
             return view('products.reseller-add', ['products' => $products]);
         }
     }
 }
コード例 #30
-1
 public static function deleteProductsByCategory($productsCategoriesId)
 {
     $folder = "assets/images/_upload/products/";
     $folderBull = "assets/bulas/";
     $products = Products::where('productsCategoriesId', $productsCategoriesId)->get();
     foreach ($products as $product) {
         if ($product->bull != "") {
             if (File::exists($folderBull . $product->bull)) {
                 File::delete($folderBull . $product->bull);
             }
         }
         if ($product->image != "") {
             if (File::exists($folder . $product->image)) {
                 File::delete($folder . $product->image);
             }
         }
     }
     return Products::where('productsCategoriesId', '=', $productsCategoriesId)->delete();
 }