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


PHP Address::get方法代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     $users = Address::get();
     $status_list = array_keys(trans('globals.order_status'));
     for ($i = 0; $i < 20; $i++) {
         $user = $users->random(1);
         $products = Product::get();
         $type = $faker->randomElement(['cart', 'wishlist', 'order']);
         $status = 'open';
         switch ($type) {
             case 'order':
                 $status = $faker->randomElement($status_list);
                 break;
         }
         $stock = $faker->numberBetween(1, 20);
         $order = Order::create(['user_id' => $user->user_id, 'seller_id' => '3', 'address_id' => $user->id, 'status' => $status, 'type' => $type, 'description' => $type == 'wishlist' ? $faker->companySuffix : '', 'end_date' => $status == 'closed' || $status == 'cancelled' ? $faker->dateTime() : null]);
         $num = $faker->numberBetween(2, 5);
         $list = [];
         if ($num > 1 && count($products) - 1 < $num) {
             $num = count($products) - 1;
         }
         for ($j = 0; $j < $num; $j++) {
             do {
                 $a = true;
                 $product = $products->random(1);
                 if (in_array($product->id, $list)) {
                     $a = false;
                 } else {
                     $list[] = $product->id;
                 }
             } while ($a == false);
             if ($status == 'closed') {
                 $delivery = $faker->dateTime();
             } else {
                 $delivery = $faker->numberBetween(0, 1) ? $faker->dateTime() : null;
             }
             OrderDetail::create(['order_id' => $order->id, 'product_id' => $product->id, 'price' => $product->price, 'quantity' => $stock, 'delivery_date' => $delivery]);
         }
         $order->sendNotice();
     }
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:42,代码来源:OrdersTableSeeder.php

示例2: edit

 public function edit($booking_id)
 {
     $booking = Booking::with('comment.comment_type', 'comment.role.user', 'comment.role.role_type', 'change.change_type', 'change.user', 'car_type', 'role.user', 'role.role_type', 'income.income_type', 'outcome.outcome_type', 'route_point.location', 'route_point.sub_location', 'route_point.address')->with(array('route_point' => function ($query) {
         $query->orderBy('order', 'ASC');
     }))->findOrFail($booking_id);
     $car_types = Car_type::get();
     $role_types = Role_type::get();
     $income_types = Income_type::get();
     $outcome_types = Outcome_type::get();
     $locations = Location::get();
     $sub_locations = Sub_location::get();
     $addresses = Address::get();
     JavaScript::put(['addresses' => $addresses, 'booking' => $booking, 'car_types' => $car_types, 'income_types' => $income_types, 'locations' => $locations, 'outcome_types' => $outcome_types, 'role_types' => $role_types, 'sub_locations' => $sub_locations, 'csrf_token' => csrf_token()]);
     return view('booking.edit');
 }
开发者ID:jedlicka82,项目名称:transferpraha,代码行数:15,代码来源:BookingController.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     $users = Address::get();
     $status_list = array_keys(trans('globals.order_status'));
     for ($i = 0; $i < 40; $i++) {
         $user = $users->random(1);
         $products = Product::where('id', '!=', $user->user_id)->where('type', '!=', 'freeproduct')->get();
         $type = 'freeproduct';
         $status = 'paid';
         $order = Order::create(['user_id' => $user->user_id, 'seller_id' => '3', 'address_id' => $user->address_id, 'status' => 'paid', 'type' => $type, 'description' => '', 'end_date' => null]);
         //Productos a insertar a la orden. Se haran copias de los productos que esten en las ordenes y se le asignara el tipo freeproduct
         $num = $faker->numberBetween(2, 5);
         $list = [];
         if ($num > 1 && count($products) - 1 < $num) {
             $num = count($products) - 1;
         }
         for ($j = 0; $j < $num; $j++) {
             do {
                 $a = true;
                 $product = $products->random(1);
                 $quantity = $faker->numberBetween(1, 5);
                 if (in_array($product->id, $list)) {
                     $a = false;
                 } else {
                     //duplico el producto
                     $productactual = $product->toArray();
                     unset($productactual['id']);
                     unset($productactual['num_of_reviews']);
                     $productactual['user_id'] = '3';
                     //$user->user_id;
                     $productactual['type'] = 'freeproduct';
                     $productactual['parent_id'] = $product->id;
                     $newproduct = Product::create($productactual);
                     $list[] = $product->id;
                 }
             } while ($a == false);
             //el nuevo producto lo asocio al detalle de la orden
             OrderDetail::create(['order_id' => $order->id, 'product_id' => $newproduct->id, 'price' => $product->price, 'quantity' => $quantity, 'delivery_date' => null]);
             //Actualizo el stock
             $product->stock = $product->stock - $quantity;
             $product->save();
         }
         $order->sendNotice();
     }
     $orders = Order::where('type', '=', 'freeproduct')->get();
     $users = User::where('type', 'trusted')->get();
     $list_orders = [];
     for ($i = 0; $i < 15; $i++) {
         //Se crea el free product y se asocia las ordenes
         $user = $users->random(1);
         $end_date = \Carbon\Carbon::now()->addDays($faker->numberBetween(5, 30));
         $freeproduct = FreeProduct::create(['user_id' => '3', 'description' => $faker->unique()->catchPhrase, 'start_date' => \Carbon\Carbon::now(), 'end_date' => $end_date, 'participation_cost' => $faker->numberBetween(10000, 50000), 'min_participants' => $min_participants = $faker->numberBetween(1, 15), 'max_participants' => $faker->numberBetween($min_participants, $min_participants * 2), 'max_participations_per_user' => $faker->numberBetween(1, 5), 'draw_number' => $faker->numberBetween(1, 3), 'draw_date' => $end_date->addDays($faker->numberBetween(1, 5)), 'status' => $faker->randomElement([0, 1])]);
         //asocio una o mas ordenes a un free product
         $num = $faker->numberBetween(1, 3);
         if ($num > 1 && count($orders) - 1 < $num) {
             $num = count($orders) - 1;
         }
         for ($j = 0; $j < $num; $j++) {
             do {
                 $a = true;
                 $order = $orders->random(1);
                 if (in_array($order->id, $list_orders)) {
                     $a = false;
                 } else {
                     $list_orders[] = $order->id;
                 }
             } while ($a == false);
             FreeProductOrder::create(['order_id' => $order->id, 'freeproduct_id' => $freeproduct->id]);
         }
     }
 }
开发者ID:ant-vel,项目名称:antVel,代码行数:72,代码来源:FreeProductsTableSeeder.php


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