本文整理汇总了PHP中app\Product::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::all方法的具体用法?PHP Product::all怎么用?PHP Product::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: products
public function products()
{
if (!\Session::get('user')->can('产品查看')) {
abort(401);
}
return view('products/index', ['products' => Product::all()]);
}
示例2: index
public function index()
{
$products = Product::all();
$users = User::all();
return view('admin.admin')->with(['users' => $users, 'products' => $products]);
//return view('admin.test');
}
示例3: dashboard
/**
* Dashboard Details
*
*
*/
public function dashboard()
{
$products = Product::all()->count();
$orders = Order::all()->count();
$users = User::all()->count();
return view('admin.dashboard', compact('products', 'orders', 'users'));
}
示例4: index
/**
* Index page
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$productsCount = Product::all()->count();
$categoriesCount = Category::all()->count();
$usersCount = User::all()->count();
return view('manage.index', compact('productsCount', 'categoriesCount', 'usersCount'));
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$employee_ids = Employee::all()->lists('id')->toArray();
$order_states = OrderState::lists('id')->toArray();
$products = Product::all();
$municipalities = Municipality::all();
factory(App\Customer::class, 50)->create()->each(function ($customer) use($employee_ids, $products, $municipalities, $order_states) {
shuffle($employee_ids);
shuffle($order_states);
$customer->user()->save(factory(User::class, 'customer')->create());
$customer->city_id = $municipalities->shuffle()->first()->id;
$customer->save();
$customer->products()->attach($products->shuffle()->first(), ['vote' => rand(1, 5), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
$customer->orders()->save(factory(App\Order::class)->create(['acquired_by' => $employee_ids[0], 'state_id' => $order_states[0]]));
});
$user = new User();
$user->name = 'Vid';
$user->surname = 'Mahovic';
$user->email = 'vid.mahovic@gmail.com';
$user->password = 'vid123';
$user->verified = true;
$user->save();
$customer = new Customer();
$customer->street = 'Celovška 21';
$customer->city_id = $municipalities->shuffle()->first()->id;
$customer->phone = '+38640850993';
$customer->save();
$customer->user()->save($user);
}
示例6: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$products = Product::all();
/*return view('products.index')
->with('products', $products);*/
return $products;
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Suppression préalable des fichiers de upload par l'utilisation de la variable storage définie à l'aide de l'instruction public_path('upload') du fichier de configuration config\filesystem.php)
$files = Storage::allFiles();
//retroune un tableau des images de storage
foreach ($files as $file) {
Storage::delete($file);
}
//Supprimer toutes les lignes de la talble Pictures
// DB::table('pictures')->
// Récupération d'un faker opétationnel
// $faker = Faker\Factory::create();
$products = Product::all();
foreach ($products as $product) {
// Stokage de l'image et récupération de l'uri
$uri = str_random(15) . '_370x235.jpg';
Storage::put($uri, file_get_contents('http://lorempixel.com/people/370/325/'));
Picture::create(['product_id' => $product->id, 'uri' => $uri, 'title' => $this->faker->name]);
}
// DB::table('pictures')->insert(
// [
// [
// 'product_id' => '2' ,
// 'uri' => $uri
// ],
// ]
// );
}
示例8: productList
public function productList()
{
$message = \Session::get('message');
$list = \App\Product::all();
$dimensions = Arrays::dimensionNames();
return view('admin.list', compact('list', 'dimensions', 'message'));
}
示例9: home
public function home()
{
$products = Product::all();
$categories = Categorie::all();
//dump($products);
return view('accueil', ["produit" => $products, "category" => $categories]);
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$products = Product::all();
$countInactive = 0;
$countDeleted = 0;
$arrProductsIna = [];
$arrProductsDel = [];
foreach ($products as $product) {
$differenceDays = $product->created_at->diffInDays(Carbon::now());
if ($differenceDays >= 30 && $product->published != 0) {
$product->published = 0;
$product->save();
$countInactive++;
$arrProductsIna[] = $product->name;
}
/*if($differenceDays >= 60 && $product->published == 0)
{
$arrProductsDel[]= $product->name;
$this->productRepository->destroy($product->id);
$countDeleted++;
}*/
}
$this->info('Done, ' . $countInactive . ' Inactive Products - ' . $countDeleted . ' Delete Products');
try {
$this->mailer->infoProductsInnactive(['productsIna' => $arrProductsIna, 'productsDel' => $arrProductsDel, 'innactives' => $countInactive, 'deleted' => $countDeleted]);
} catch (Swift_RfcComplianceException $e) {
Log::error($e->getMessage());
}
}
示例11: index
public function index()
{
$products = \App\Product::all();
// $products = \App\Product::where('price','<','10.00')->get();
$mostPopularProducts = [];
return view('products', compact('products', 'mostPopularProducts'));
}
示例12: index
public function index()
{
$products = Product::all();
$productCode = Product::limit(1)->orderBy('product_code', 'decs')->first();
if (isset($productCode->product_code)) {
$crop = substr($productCode->product_code, 4);
if ($crop < 9) {
$plus = $crop + 1;
$urutan = "JOR000" . $plus;
} elseif ($crop < 99) {
$plus = $crop + 1;
$urutan = "JOR00" . $plus;
} elseif ($crop < 999) {
$plus = $crop + 1;
$urutan = "JOR0" . $plus;
} elseif ($crop < 9999) {
$plus = $crop + 1;
$urutan = "JOR" . $plus;
} elseif ($crop >= 9999) {
$urutan = "ERROR";
}
} else {
$urutan = "JOR0001";
}
// return response()->json(array('data' => $products, 'urutan' => $urutan));
return view('admin.product')->withProducts($products)->withUrutans($urutan);
}
示例13: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$statuses = Status::all();
$products = Product::all();
$productionschedule = Batch::find($id);
return view('production.edit', ['productionschedule' => $productionschedule, 'products' => $products, 'statuses' => $statuses]);
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$products = Product::all();
foreach ($products as $p) {
$p->slug = Str::slug($p->name);
$p->save();
}
}
示例15: getIndex
public function getIndex()
{
$categories = array();
foreach (Category::all() as $category) {
$categories[$category->id] = $category->name;
}
return View::make('products.index')->with('products', Product::all())->with('categories', $categories);
}