function naming convention for models if using left joins and multiple data in the where clause.
class InventoryRepository implements InventoryRepositoryInterface
{
public function getDetailByEventIdAndEventDate(int $eventId, string $date)
{
$query = Inventory::select(
‘inventory.*’,
‘seat_bifurcation.id as seat_bifurcation_id’,
‘seat_bifurcation.price as eventprice’,
‘seat_bifurcation.quantity’,
‘seat_bifurcation.booked_quantity’,
DB::raw(‘(seat_bifurcation.quantity – IFNULL(seat_bifurcation.booked_quantity, 0)) as available_quantity’),
DB::raw(‘IF(NOW() > CONCAT(inventory.event_date, ” “, inventory.start_time), ” TIME IS OVER “, ” EVENT available “) as time_status’),
DB::raw(‘IF(NOW() > CONCAT(inventory.event_date, ” “, inventory.end_time), ” TIME IS OVER “, ” EVENT available “) as end_time_status’),
‘event.enable_booking_during_bookingtime’
)
->leftJoin(‘seat_bifurcation’, ‘inventory.id’, ‘=’, ‘seat_bifurcation.inventory_id’)
->leftJoin(‘event’, ‘event.event_id’, ‘=’, ‘inventory.event_id’)
->where(‘inventory.event_id’, $eventId)
->where(‘inventory.event_date’, ‘>=’, $startDate)
->groupBy(
‘inventory.start_date’,
‘inventory.end_date’,
‘inventory.start_time’,
‘inventory.end_time’
)
->orderBy(‘inventory.id’, ‘ASC’)
->get();
return $query;
}
}
public function getDetailByEventIdOrDate(int $eventId, string $date)
{}
0.1k_shashank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.