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


PHP Product::all方法代码示例

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


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

示例1: stock

 /**
  * @return \Illuminate\Http\JsonResponse
  */
 public function stock()
 {
     $products = Product::all();
     $stock = Stock::orderBy('quality', 'DESC')->get();
     if ($products->count()) {
         $stock_count = 0;
         foreach ($stock as $stok) {
             $stock_product = Product::where('id', '=', $stok->product_id);
             if ($stock_product->count()) {
                 $stock_name = $stock_product->first()->name;
                 $stock_type = $stock_product->first()->type;
                 $stock[$stock_count]->stock_name = $stock_name;
                 $stock[$stock_count]->type = $stock_type;
             }
             $stock_count++;
         }
         $prod_count = 0;
         foreach ($products as $product) {
             $distributor = Distributor::where('id', '=', $product->distributor_id);
             if ($distributor->count()) {
                 $distributor = $distributor->first();
                 $distributor_name = $distributor->name;
                 $products[$prod_count]->distributor_name = $distributor_name;
             }
             $prod_count++;
         }
         return response()->json(['products' => $product, 'stock' => $stock]);
     } else {
         return response()->json(['products' => [], 'stock' => []]);
     }
 }
开发者ID:waleedahmad,项目名称:acme,代码行数:34,代码来源:StockController.php

示例2: create

 public function create()
 {
     $types = StockType::getType();
     $employees = Employee::all();
     $products = Product::all();
     $params = ['types' => $types, 'employees' => $employees, 'products' => $products];
     return view('pages.new_stock', $params);
 }
开发者ID:bsampaio,项目名称:LumenExperience,代码行数:8,代码来源:StockController.php

示例3: save

 public function save(Request $request)
 {
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
     $products = Product::all();
     return view('pages.products', ['products' => $products]);
 }
开发者ID:asleao,项目名称:LumenExperience,代码行数:10,代码来源:ProductController.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('trackings')->truncate();
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'facing_id' => Facing::find($faker->numberBetween(1, 20))->id]);
     }
     foreach (range(21, 30) as $index) {
         Tracking::create(['image_url' => $faker->imageUrl(640, 480, 'city'), 'state' => 'Inserted', 'inserted_at' => Carbon::now(), 'facing_id' => Facing::all()->get($faker->numberBetween(1, 20))->id, 'product_id' => Product::all()->get($faker->numberBetween(1, 20))->id, 'brand_id' => Brand::all()->get($faker->numberBetween(1, 20))->id, 'user_id' => User::all()->get($faker->numberBetween(1, 10))->id]);
     }
 }
开发者ID:sagaciresearch,项目名称:adtracking,代码行数:16,代码来源:TrackingTableSeeder.php

示例5: getIndex

 public function getIndex()
 {
     $products_list = [0 => 'Не выбрано'];
     foreach (Product::all() as $product) {
         $products_list[$product->id] = $product->name;
     }
     $blocks_list = [];
     foreach (BlocksContent::all() as $block) {
         $blocks_list[$block->id] = $block->title;
     }
     return view('admin.blocks_content.index', ['products_list' => $products_list, 'blocks_list' => $blocks_list, 'blocks' => BlocksContent::all()]);
 }
开发者ID:venomir,项目名称:tc,代码行数:12,代码来源:BlocksContentController.php

示例6: adminFunction

 /**
  * Overrides CODES relationship with one for each product available
  *
  * @param User $user
  */
 private function adminFunction(User $user)
 {
     /**
      * if its an admin, override relationship
      * UPDATE: allow everyone have all the codes
      */
     //        if ($user->is('admin') ) {
     $codes = Product::all()->transform(function ($product) use($user) {
         /** @var Code $temp */
         $temp = $product->codes()->with('product', 'product.extras', 'product.profile')->first();
         if ($temp) {
             return $temp->setAttribute('user_id', $user->id);
         }
     });
     $user->setRelation('codes', $codes);
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:21,代码来源:InjectProductTrait.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Stantion $depo, Product $product, StoreStation $request)
 {
     $products = $product->all();
     DB::transaction(function () use($depo, $request, $products) {
         $lastInsertedDepo = $depo->create($request->all());
         $pricesIdArr = [];
         foreach ($products as $prod) {
             $price = new Price();
             $price->price = 0;
             $price->save();
             $prod->price()->attach($price->id);
             $pricesIdArr[] = $price->id;
         }
         $lastInsertedDepo->price()->sync($pricesIdArr);
     });
     return redirect('stations')->with('alert-warning', 'Депо успешно добавлено! Внимание! Не забудьте проставить цену товарам для этого депо');
 }
开发者ID:kostik34,项目名称:trains.shop,代码行数:22,代码来源:StationController.php

示例8: getProduct

 /**
  * get products
  *
  * @return Response
  */
 public function getProduct()
 {
     $products = Product::all();
     return Datatables::of($products)->edit_column('image', function ($row) {
         if (!empty($row->image)) {
             return showImage($row->image, PRODUCT_IMAGE . $row->id);
         }
     })->edit_column('status', function ($row) {
         return showSelectStatus($row->id, $row->status, 'Kacana.product.setStatus(' . $row->id . ', 1)', 'Kacana.product.setStatus(' . $row->id . ', 0)');
     })->edit_column('created', function ($row) {
         return showDate($row->created);
     })->edit_column('updated', function ($row) {
         return showDate($row->updated);
     })->add_column('action', function ($row) {
         return showActionButton("/product/editProduct/" . $row->id, 'Kacana.product.removeProduct(' . $row->id . ')', false, false);
     })->make(true);
 }
开发者ID:kacana,项目名称:admin,代码行数:22,代码来源:ProductController.php

示例9: elseif

<?php

Admin::model('App\\Models\\Order')->title('')->display(function () {
    $display = AdminDisplay::datatables();
    $display->with();
    $display->filters([]);
    $display->columns([Column::custom()->label('Команда')->callback(function ($instance) {
        $product = \App\Models\Product::all()->where('id', $instance->product_id)->first();
        return is_null($product) ? 'Неизвестный' : $product->title;
    }), Column::string('sum')->label('Сумма'), Column::custom()->label('Статус')->callback(function ($instance) {
        if ($instance->status == 0) {
            return '<p class="text-warning">Не оплачен</p>';
        } elseif ($instance->status == 1) {
            return '<p class="text-danger">Ошибка</p>';
        } else {
            return '<p class="text-success">Оплачен</p>';
        }
    })]);
    return $display;
})->createAndEdit(function () {
    return null;
});
开发者ID:proudly,项目名称:RefEng,代码行数:22,代码来源:Order.php

示例10: forCustomer

 /**
  * Get all of the products for the Customer
  *
  * @return Collection
  */
 public function forCustomer()
 {
     return Product::all();
 }
开发者ID:swinecommerceph,项目名称:swinecommerceph,代码行数:9,代码来源:DashboardRepository.php

示例11: overview

 public function overview()
 {
     $products = Product::all();
     return view('cms/product/product/overview')->with('items', $products);
 }
开发者ID:leonstel,项目名称:czborduur,代码行数:5,代码来源:ProductController.php

示例12: index

 function index()
 {
     $products = Product::all();
     return view('product.cart', ['products' => $products]);
 }
开发者ID:thapavishal,项目名称:leafrogstore2,代码行数:5,代码来源:HomeController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Product::all();
 }
开发者ID:oarGroupeCesi,项目名称:madera_api,代码行数:9,代码来源:ProductController.php

示例14: products

 function products()
 {
     return Product::all();
 }
开发者ID:thapavishal,项目名称:leafrogstore2,代码行数:4,代码来源:ApiController.php

示例15: index

 /**
  * Display Generator Page
  *
  * @param Product $product
  * @return $this
  */
 public function index(Product $product)
 {
     return view('products.index')->with('products', $product->all());
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:10,代码来源:ProductController.php


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