本文整理汇总了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' => []]);
}
}
示例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);
}
示例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]);
}
示例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]);
}
}
示例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()]);
}
示例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);
}
示例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', 'Депо успешно добавлено! Внимание! Не забудьте проставить цену товарам для этого депо');
}
示例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);
}
示例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;
});
示例10: forCustomer
/**
* Get all of the products for the Customer
*
* @return Collection
*/
public function forCustomer()
{
return Product::all();
}
示例11: overview
public function overview()
{
$products = Product::all();
return view('cms/product/product/overview')->with('items', $products);
}
示例12: index
function index()
{
$products = Product::all();
return view('product.cart', ['products' => $products]);
}
示例13: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return Product::all();
}
示例14: products
function products()
{
return Product::all();
}
示例15: index
/**
* Display Generator Page
*
* @param Product $product
* @return $this
*/
public function index(Product $product)
{
return view('products.index')->with('products', $product->all());
}