示例#1
0
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('shipments')->delete();
     for ($i = 0; $i < 10; $i++) {
         App\Shipment::create(['order_id' => rand(1, 100), 'shipper_id' => rand(1, 5), 'distance' => rand(5, 2000), 'status' => rand(1, 2)]);
     }
 }
 public function run()
 {
     // Uncomment the below to wipe the table clean before populating
     DB::table('transactions')->delete();
     $delivered = App\Shipment::delivered()->get();
     foreach ($delivered as $delivery) {
         $order = $delivery->order;
         App\Transaction::create(['order_id' => $order->id, 'amount' => $order->orderItems->sum('price')]);
     }
 }