database/seeds/SaleSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        $bookingService = new BookingService();
        $bookings = Booking::all();
        $bookings->each(function ($book) use ($bookingService) {
            if (!$book->sale) {
                $book->sale()->create([
                    'rate' => $book->ride->bus->busClass->rate,
                    'payment' => $bookingService->computeFare($book->ride, $book->pax, $book->start_terminal_id, $book->end_terminal_id),
                ]);
            }
        });
    }
public function run ( ) { $ bookingService = new BookingService ( ) ; $ bookings = Booking :: all ( ) ; $ bookings -> each ( function ( $ book ) use ( $ bookingService ) { if ( ! $ book -> sale ) { $ book -> sale ( ) -> create ( [ 'rate' => $ book -> ride -> bus -> busClass -> rate , 'payment' => $ bookingService -> computeFare ( $ book -> ride , $ book -> pax , $ book -> start_terminal_id , $ book -> end_terminal_id ) , ] ) ; } } ) ; }
Run the database seeds.
Run the database seeds .