本文整理汇总了PHP中Product::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::all方法的具体用法?PHP Product::all怎么用?PHP Product::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified dashboard.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$products = Product::all();
$records = Record::all();
$manufacturers = Manufacturer::all();
return View::make('Dashboard.index', compact('records', 'products', 'manufacturers'));
}
示例2: run
public function run()
{
$this->trancate();
$faker = Faker\Factory::create();
$languages = Language::all();
$products = Product::all();
$attributes = Attribute::all();
$attributes_options = array();
foreach ($languages as $language) {
$options = DB::table('attributes_options')->whereLanguageId($language->id)->get();
$options = new Illuminate\Database\Eloquent\Collection($options);
$options = $options->lists("options", 'attribute_id');
$attributes_options[$language->id] = $options;
}
$attributes_key = $attributes->modelKeys();
$products->each(function ($product) use($attributes_key, $languages, $faker, $attributes_options) {
$count_to_insert = rand(0, rand(0, count($attributes_key) - 1));
for ($i = 1; $i <= $count_to_insert; $i++) {
foreach ($languages as $language) {
$attribute_id = $attributes_key[rand(0, count($attributes_key) - 1)];
$options = $attributes_options[$language->id][$attribute_id];
$tokens = explode("|", $options);
try {
DB::table('products_to_attributes')->insert(array('product_id' => $product->id, 'language_id' => $language->id, 'attribute_id' => $attribute_id, 'value' => $tokens[rand(0, count($tokens) - 1)]));
} catch (Exception $x) {
var_dump($x);
}
}
}
});
}
示例3: 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);
}
示例4: dataTables
public function dataTables()
{
return Datatable::collection(Product::all())->showColumns("id", "name", "identifier", "category", "import", "source_area", "brand", "price", "desc", "created_at")->addColumn('products_category', function ($model) {
return Category::where('parent_code', 'PRODUCT_CATEGORY')->where('code', $model->category)->select('name as label', 'code as value')->first();
})->addSelect('products_category', function () {
return Category::where('parent_code', 'PRODUCT_CATEGORY')->select('name as label', 'code as value')->get();
})->searchColumns(array('name'))->orderColumns('created_at')->setAliasMapping()->make();
}
示例5: products
public function products()
{
$ids2 = DB::table('tblProducts')->select('strProdID')->orderBy('updated_at', 'desc')->orderBy('strProdID', 'desc')->take(1)->get();
$ID2 = $ids2["0"]->strProdID;
$newID2 = $this->smart($ID2);
// Get all products from the database
$products = Product::all();
return View::make('products')->with('products', $products)->with('newID2', $newID2);
}
示例6: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$all = Product::all();
$op = array();
foreach ($all as $data) {
$op[] = array("{$data->id}", $data->product_name, "{$data->bike_cc}", $data->model, "action");
}
return json_encode(array("data" => $op));
}
示例7: display
public function display()
{
$products = Product::all();
$products = Product::orderBy('p_id', 'desc')->paginate(3);
$users = User::all();
$users = User::orderBy('id', 'desc')->paginate(3);
$suppliers = Product::lists('supplier', 'supplier');
$metals = Product::lists('metal', 'metal');
return View::make('products.list')->with('products', $products)->with('suppliers', $suppliers)->with('metals', $metals)->with('users', $users);
}
示例8: getView
public function getView($id)
{
$product = Product::find($id);
if ($product) {
$random = Product::all()->random(4);
return View::make('store.view')->with('product', $product)->with('random', $random);
} else {
return View::make('404');
}
}
示例9: getHome
public function getHome()
{
$products = Product::all();
if (Auth::check()) {
$user = Auth::user();
} else {
$user = new User();
$user->first_name = 'stranger';
}
return View::make('home', array('products' => $products, 'user' => $user));
}
示例10: getProducts
function getProducts()
{
$ProductID = $this->f3->get('PARAMS.ProductID');
$p = new Product($this->db);
//$products = $product->all();
if (isset($ProductID)) {
$products = $p->getById($ProductID);
} else {
$products = $p->all();
}
echo $this->utils->successResponse($p, $products);
}
示例11: run
public function run()
{
$this->trancate();
$languages = Language::all();
$products = Product::all();
$categories = Category::all();
$categories_array = $categories->toArray();
$products->each(function ($product) use($categories_array) {
// product to categories
DB::table('products_to_categories')->insert(array('product_id' => $product->id, 'category_id' => $categories_array[rand(0, count($categories_array) - 1)]['id']));
});
}
示例12: index
public function index()
{
// Check if user has sent a search query
if ($query = Input::get('query', false)) {
// Use the Elasticquent search method to search ElasticSearch
$products = Product::search($query);
} else {
// Show all posts if no query is set
$products = Product::all();
}
return View::make('products', compact('products'));
}
示例13: run
public function run()
{
$this->trancate();
$faker = Faker\Factory::create();
$products = Product::all();
$products->each(function ($product) use($faker) {
//product reviews
$reviews_count = rand(0, 30);
for ($i = 0; $i < $reviews_count - 1; $i++) {
DB::table('products_review')->insert(array('product_id' => $product->id, 'author' => $faker->firstName, 'title' => $faker->sentence, 'text' => $faker->text(), 'rating' => rand(1, 5), 'approved' => 1, 'created_at' => \Carbon\Carbon::createFromDate(rand(2012, 2014), rand(1, 12), rand(1, 29))->toDateTimeString(), 'updated_at' => \Carbon\Carbon::createFromDate(rand(2012, 2014), rand(1, 12), rand(1, 29))->toDateTimeString()));
}
});
}
示例14: get
public function get($id = null)
{
$search = Input::get('search');
if (!is_null($search)) {
$adjustments = Adjustment::select('adjustments.*')->join('products', 'products.id', '=', 'adjustments.products_id')->where('products.name', 'like', '%' . $search . '%')->orwhere('products.code', 'like', '%' . $search . '%')->orderBy('adjustments.created_at')->paginate(15);
} else {
$adjustments = Adjustment::latest()->paginate(15);
}
$selectedAdjustment = self::__checkExistence($id);
if (!$selectedAdjustment) {
$selectedAdjustment = new Adjustment();
}
$products = Product::all()->lists('name', 'id');
return View::make('adjustments.main')->with('id', $id)->with('products', $products)->with('search', $search)->with('selectedAdjustment', $selectedAdjustment)->with('adjustments', $adjustments);
}
示例15: dashboard
public function dashboard()
{
if (!Auth::user()->is_admin) {
return Redirect::to('/');
}
//produits de la boutique
$products = Product::all();
// récupérer les dates ou il y a eu des commandes donc achats
$cmds = DB::select(DB::raw('SELECT DATE(orders.date) AS date FROM orders GROUP BY DATE(orders.date) ORDER BY orders.date DESC'));
//récupérer les achats par date
$cmdsByDate = array();
foreach ($cmds as $key => $cmd) {
$cmdsByDate[$cmd->date] = Orderitem::whereRaw('DATE(orders.date) = \'' . $cmd->date . '\'')->leftJoin('orders', 'order_items.order_id', '=', 'orders.id')->leftJoin('users', 'orders.user_id', '=', 'users.id')->leftJoin('products', 'order_items.item_id', '=', 'products.id')->select('order_items.*', 'orders.date AS date', 'users.email AS user_email', 'users.first_name AS user_first', 'users.last_name AS user_last', 'products.name AS item_name')->orderBy('orders.date', 'DESC')->get();
}
//list des commandes par mois
return View::make('admin/show', array('products' => $products, 'cmdsbydate' => $cmdsByDate));
}