当前位置: 首页>>代码示例>>PHP>>正文


PHP app\Product类代码示例

本文整理汇总了PHP中app\Product的典型用法代码示例。如果您正苦于以下问题:PHP Product类的具体用法?PHP Product怎么用?PHP Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Product类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveProduct

 public function saveProduct(Request $request)
 {
     $result = array('success' => 0);
     $image = $request->session()->get('image');
     if (!empty($image)) {
         $a = explode('-', basename($image));
         $id = array_shift($a);
         if (intval($id) > 0) {
             $prods_dir = 'uploads/product';
             $image_noid = implode('-', $a);
             $prod = new Product();
             $prod->image = $image_noid;
             $prod->left = floatval($request->input('left'));
             $prod->top = floatval($request->input('top'));
             $prod->width = floatval($request->input('width'));
             if ($prod->save()) {
                 if (rename($image, $prods_dir . '/' . $prod->id . '-' . $image_noid) && rename(dirname($image) . '/thumbs/' . basename($image), $prods_dir . '/thumbs/' . $prod->id . '-' . $image_noid)) {
                     $request->session()->forget('image');
                     $result['success'] = 1;
                 }
             }
         }
     }
     return response()->json($result);
 }
开发者ID:raivof,项目名称:test1,代码行数:25,代码来源:DesignController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request, $id)
 {
     //总销售金额
     $order = new Order();
     $_data['sell_total_money'] = $order->newQuery()->whereRaw('`status`>?', array(1))->sum('total_money');
     //总订单数
     $_data['order_total_cnt'] = $order->newQuery()->count();
     //总商品数
     $product = new Product();
     $_data['product_total_cnt'] = $product->newQuery()->count();
     //总用户数
     $user = new User();
     $_data['user_total_cnt'] = $user->newQuery()->count();
     $this->_week_start = $week_start = date("Y-m-d 00:00:00", strtotime("-" . (date("w") - 1) . " days"));
     //本周销售
     $_data['sell_week_money'] = $order->newQuery()->whereRaw('created_at>= ? and `status`>?', array($week_start, 1))->sum('total_money');
     //本周订单
     $_data['order_week_cnt'] = $order->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     //本周商品
     $_data['product_week_cnt'] = $product->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     //本周用户
     $_data['user_week_cnt'] = $user->newQuery()->whereRaw('created_at>= ?', array($week_start))->count();
     $this->_data = $_data;
     return $this->view('admin.dashboard');
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:30,代码来源:HomeController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $ratatouille = new App\Product();
     $ratatouille->week_no = date('W');
     $ratatouille->year = date('Y');
     $ratatouille->name = 'Ratatouille';
     $ratatouille->description = 'Ratatouille is een Frans gerecht van gestoofde groenten, dat vooral in de Provence veel wordt bereid.';
     $ratatouille->city_id = 1;
     $ratatouille->save();
     $spaghetti = new App\Product();
     $spaghetti->week_no = date('W');
     $spaghetti->year = date('Y');
     $spaghetti->name = 'Spaghetti';
     $spaghetti->description = 'Lorem ipsum.';
     $spaghetti->city_id = 1;
     $spaghetti->save();
     $visgerecht = new App\Product();
     $visgerecht->week_no = date('W');
     $visgerecht->year = date('Y');
     $visgerecht->name = 'Visgerecht';
     $visgerecht->description = 'Lorem ipsum.';
     $visgerecht->city_id = 2;
     $visgerecht->save();
     $testgerecht = new App\Product();
     $testgerecht->week_no = date('W');
     $testgerecht->year = date('Y');
     $testgerecht->name = 'Test gerecht';
     $testgerecht->description = 'Lorem ipsum.';
     $testgerecht->city_id = 2;
     $testgerecht->save();
 }
开发者ID:sanderdekroon,项目名称:yourfoodbox,代码行数:36,代码来源:ProductsTableSeeder.php

示例4: loadFeed

 /**
  *
  */
 public function loadFeed()
 {
     $xml = $this->reader->load($this->feedUrl);
     $content = $xml->getContent();
     $this->content = $xml->getContent();
     foreach ($content as $product) {
         $item = Product::where('externalUrl', '=', $product->productUrl)->first();
         if (!$item) {
             $item = new Product();
         }
         if (strlen($product->brand) > 1) {
             $brand = Brand::where('name', '=', $product->brand)->first();
             if (!$brand) {
                 $brand = new Brand();
                 $brand->name = $product->brand;
                 $brand->save();
             }
             if ($brand->id) {
                 $item->brand = $brand->id;
             }
         }
         $item->name = $product->name;
         $item->description = $product->description;
         $item->price = $product->price;
         $item->regularPrice = $product->regularPrice;
         $item->shippingPrice = $product->shippingPrice;
         $item->externalUrl = $product->productUrl;
         $item->imageUrl = $product->graphicUrl;
         $item->save();
     }
 }
开发者ID:jimmitjoo,项目名称:feedparser,代码行数:34,代码来源:FeedParser.php

示例5: store

 public function store(Request $request)
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('name' => 'required', 'brand' => 'required', 'price' => 'required|numeric');
     $messages = ['required' => 'The :attribute field is required.', 'numeric' => 'The :attribute field must be numeric.'];
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return response()->json(['error' => ['status' => ['code' => 400, 'statusText' => 'Bad Request'], 'errors' => $validator->errors()->all(), 'message' => 'Invalid request body. Ensure all fields are specified and in JSON format.']]);
     } else {
         $product = new Product();
         $product->name = Input::get('name');
         $product->brand = Input::get('brand');
         $product->price = Input::get('price');
         $product->created_at = new DateTime();
         $product->updated_at = new DateTime();
         if (Input::get('description') != null) {
             $product->description = Input::get('description');
         } else {
             $product->description = '<small>No Descriptions</small>';
         }
         if (Input::get('imageUrl') == null) {
             $product->imageUrl = 'https://cdn.filestackcontent.com/CwyooxXdTcWtwufoKgOf';
         } else {
             $product->imageUrl = Input::get('imageUrl');
         }
         if ($product->save()) {
             return response()->json(['success' => true, 'product' => $product]);
         } else {
             return response()->json(['error' => ['status' => ['code' => 500, 'statusText' => 'Internal Server Error'], 'message' => 'Failed to create new product.']]);
         }
     }
 }
开发者ID:ChagasCo,项目名称:enw-angular,代码行数:33,代码来源:ProductController.php

示例6: scan

 /**
  * Register a product via barcode and uid (user id)
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function scan()
 {
     header("Access-Control-Allow-Origin: *");
     $response = new YYResponse(FALSE, 'Something went wrong.');
     $validator = Validator::make(Request::all(), ['barcode' => 'required|integer', 'uid' => 'required|integer']);
     if ($validator->fails()) {
         $response->errors = $validator->errors();
         return response()->json($response);
     }
     $product = Product::where(['barcode' => Request::get('barcode')])->get();
     $product = empty($product[0]) ? NULL : $product[0];
     if (empty($product)) {
         $product = new Product();
         $product->barcode = Request::get('barcode');
         $product->uid = Request::get('uid');
         $product->save();
     }
     if (!empty($product)) {
         $response->state = TRUE;
         $response->message = NULL;
         $response->data = $product;
         $response->data->reviews = Product::getReviewsById($product->id);
         $response->data->rating = Product::getRatingById($product->id);
         $response->data->rating->average = $response->data->rating->count > 0 ? $response->data->rating->total / $response->data->rating->count : 0;
         $response->data->review = Product::getReviewsById($product->id, $product->uid);
     }
     return response()->json($response);
 }
开发者ID:peterdoescode,项目名称:yumyam,代码行数:33,代码来源:AppController.php

示例7: import

 public function import(Request $request)
 {
     $file = $request->file('arquivo');
     $extension = $file->getClientOriginalExtension();
     $import = new Import();
     $import->user_id = 1;
     $import->save();
     Storage::disk('local')->put($import->id . '.' . $extension, File::get($file));
     $handle = fopen($file, "r");
     $firstTime = true;
     while (($line = fgetcsv($handle, 1000, "\t")) !== false) {
         if ($firstTime) {
             $firstTime = false;
         } else {
             $produto = new Product();
             $produto->import_id = $import->id;
             $produto->purchaser_name = $line[0];
             $produto->item_description = $line[1];
             $produto->item_price = floatval($line[2]);
             $produto->purchase_count = intval($line[3]);
             $produto->merchant_address = $line[4];
             $produto->merchant_name = $line[5];
             $produto->save();
         }
     }
     return view('index', ['imports' => Import::all()]);
 }
开发者ID:fabio-santos,项目名称:desafio-programacao-1,代码行数:27,代码来源:FileController.php

示例8: special

 public function special(Request $request, $activity_id = 0)
 {
     $stores_ids = $this->user->stores->pluck('id');
     $this->_brands = Brand::join('store_brand as s', 's.bid', '=', 'brands.id')->whereIn('s.sid', $stores_ids)->get(['brands.*']);
     $pagesize = $request->input('pagesize') ?: $this->site['pagesize']['m'];
     $this->_input = $request->all();
     $product = new Product();
     //查找猴子捞月所有在线,有效活动id
     $now = date("Y-m-d H:i:s");
     if (!empty($activity_id)) {
         $activity = Activity::find($activity_id);
     } elseif (!empty($request->get('type_id'))) {
         $fids = $product->newQuery()->whereIn('bid', $this->_brands->pluck('id'))->pluck('fid');
         if (!empty($fids)) {
             $fids = array_unique((array) $fids);
         }
         $builder = Activity::whereIn('fid', $fids)->where('type_id', $request->get('type_id'));
         $activity = $builder->first();
         $activity_id = $builder->pluck('id');
     } else {
         return $this->failure(NULL);
     }
     if (empty($activity)) {
         return $this->failure('activity::activity.no_activity');
     } elseif ($activity->start_date > $now || $activity->end_date < $now || $activity->status != 1) {
         return $this->failure('activity::activity.failure_activity');
     }
     //查看当前以以和店铺 猴子捞月 活动所有商品
     $builder = $product->newQuery()->with(['sizes', 'covers']);
     $this->_activity = $activity;
     $this->_table_data = $builder->whereIn('activity_type', (array) $activity_id)->whereIn('bid', $this->_brands->pluck('id'))->paginate($pagesize);
     return $this->view('activity::m.special');
 }
开发者ID:unionbt,项目名称:hanpaimall,代码行数:33,代码来源:ActivityController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $product = new Product();
     $product->name = Input::get('name');
     $product->description = Input::get('description');
     $product->save();
     return view('products.index', ['products' => Product::all()]);
 }
开发者ID:FabyGata,项目名称:ProyectoPapi,代码行数:14,代码来源:ProductsController.php

示例10: store

 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'category' => 'required', 'price' => 'required|numeric', 'image' => 'required|image', 'detail' => 'required']);
     $imageName = $this->saveImage($request);
     $product = new Product(['name' => $request->input('name'), 'image' => 'images/products/' . $imageName, 'price' => $request->input('price'), 'detail' => $request->input('detail')]);
     $product->addCategory($request->input('category'));
     return redirect()->back();
 }
开发者ID:fransiskusbenny,项目名称:larashop,代码行数:8,代码来源:ProductControler.php

示例11: product

 public function product(Shop $shop, Product $product, Request $request)
 {
     $user = Auth::user();
     $product->comments()->create(['user_id' => $user->id, 'body' => $request->input('body')]);
     $product->update(['num_comment' => $product->comments()->count()]);
     Flash::success('comment Added');
     return redirect()->back();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:8,代码来源:CommentController.php

示例12: saveAttributes

 /**
  * Creates, updates or deletes the attributes.
  *
  * @param Product $product
  */
 protected function saveAttributes(Product $product)
 {
     $ids = [];
     foreach (array_filter($this->attributes) as $attribute_id => $value) {
         $ids[$attribute_id] = compact('value');
     }
     $product->attributes()->sync($ids);
 }
开发者ID:manishkiozen,项目名称:Cms,代码行数:13,代码来源:UpdateProductCommand.php

示例13: transfer

 protected function transfer(\App\Product $product)
 {
     $pData = unserialize($product->data);
     $pData->setCategory(5);
     $product->data = serialize($pData);
     $product->cat_id = 5;
     $product->save();
 }
开发者ID:Qeenslet,项目名称:wireworks,代码行数:8,代码来源:categoryDeleter.php

示例14: clear

 public function clear()
 {
     $product = new Product();
     $cart = Session::get("cart");
     foreach ($cart as $id => $quantity) {
         $product->restIncrement($id, $quantity);
     }
     Session::forget("cart");
 }
开发者ID:DimaPikash,项目名称:eshop,代码行数:9,代码来源:Cart.php

示例15: addNotExistentProduct

 /**
  * Add not existent product to bill.
  *
  * @param int $billId
  * @param AddNotExistentProductRequest $request
  * @return mixed
  */
 public function addNotExistentProduct($billId, AddNotExistentProductRequest $request)
 {
     $product = new Product();
     $product->user_id = Auth::user()->id;
     $product->code = $request->get('product_code');
     $product->name = $request->get('product_name');
     $product->save();
     return Products::insertProduct($billId, $request->all());
 }
开发者ID:bitller,项目名称:nova,代码行数:16,代码来源:BillController.php


注:本文中的app\Product类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。