func (p *postgres) SearchAvailabilityForAllLaptops(start, end time.Time) ([]models.Laptop, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	defer cancel()

	var laptops []models.Laptop

	query := `SELECT l.id, l.laptop_name
			  FROM laptops l
			  WHERE l.id not in (
				  SELECT lr.laptop_id FROM laptop_restrictions lr
				  WHERE $1 < lr.end_date AND $2 > lr.start_date)`
	rows, err := p.DB.QueryContext(ctx, query, start, end)
	if err != nil {
		return laptops, err
	}

	for rows.Next() {
		var laptop models.Laptop
		err = rows.Scan(
			&laptop.ID,
			&laptop.LaptopName,
		)
		if err != nil {
			return laptops, err
		}

		laptops = append(laptops, laptop)
	}

	if err = rows.Err(); err != nil {
		return laptops, err
	}

	return laptops, nil
}
// SearchAvailabilityForAllLaptops returns a slice of available laptops if any, for given date range
SearchAvailabilityForAllLaptops returns a slice of available laptops if any, for given date range
// SearchAvailabilityForAllLaptops returns a slice of available laptops if any for given date range
func (p *postgres) SearchAvailabilityForAllLaptops(start, end time.Time) ([]models.Laptop, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	defer cancel()
	var laptops []models.Laptop
	query := `SELECT l.id, l.laptop_name
			  FROM laptops l
			  WHERE l.id not in (
				  SELECT lr.laptop_id FROM laptop_restrictions lr
				  WHERE $1 < lr.end_date AND $2 > lr.start_date)`
	rows, err := p.DB.QueryContext(ctx, query, start, end)
	if err != nil {
		return laptops, err
	}
	for rows.Next() {
		var laptop models.Laptop
		err = rows.Scan(
			&laptop.ID,
			&laptop.LaptopName,
		)
		if err != nil {
			return laptops, err
		}
		laptops = append(laptops, laptop)
	}
	if err = rows.Err(); err != nil {
		return laptops, err
	}
	return laptops, nil
}
func ( p * postgres ) SearchAvailabilityForAllLaptops ( start , end time . Time ) ( [ ] models . Laptop , error ) { ctx , cancel := context . WithTimeout ( context . Background ( ) , 3 * time . Second ) defer cancel ( ) var laptops [ ] models . Laptop query := `SELECT l.id, l.laptop_name
			  FROM laptops l
			  WHERE l.id not in (
				  SELECT lr.laptop_id FROM laptop_restrictions lr
				  WHERE $1 < lr.end_date AND $2 > lr.start_date)` rows , err := p . DB . QueryContext ( ctx , query , start , end ) if err != nil { return laptops , err } for rows . Next ( ) { var laptop models . Laptop err = rows . Scan ( & laptop . ID , & laptop . LaptopName , ) if err != nil { return laptops , err } laptops = append ( laptops , laptop ) } if err = rows . Err ( ) ; err != nil { return laptops , err } return laptops , nil }
SearchAvailabilityForAllLaptops returns a slice of available laptops if any, for given date range
SearchAvailabilityForAllLaptops returns a slice of available laptops if any for given date range