简体   繁体   English

在MySQL和Laravel中预订

[英]Booking in MySQL and Laravel

I have problem with listing reservation who has more than one reservation and I don't what to this apartment be listed. 我有一个以上预订的清单预订有问题,我没有列出这间公寓的设施。

$show_apartments = DB::table('apartments')
  ->join('reservation', 'unos_id', '=', 'reservation.id_nekretnina')
  ->select('unos_id as link', 'title', 'description', 'picture', 'slug',               'max_person','reservation.dolazak','reservation.odlazak')
  ->whereNotBetween('dolazak', [$in_sql, $out_sql]) 
  // this is date check in and check out in search field
  ->whereNotBetween('odlazak', [$in_sql, $out_sql]) 
  // this is date check in and check out in search field
  ->get();

All apartments list very well but problem is when some apartment is more than one different date reservation then apartment is listed but I want only if apartment is in this range is free. 所有公寓的清单都很好,但是问题是当某些公寓超过一个不同日期的预订时,则列出了公寓,但是我只希望在此范围内的公寓是免费的。 I tray 50h and didn't look the solution. 我托盘50小时,没有找到解决方案。

When someone help me I will put this in stored procedure. 当有人帮助我时,我会将其放入存储过程中。

I know what is problem but I don't know to write code for this. 我知道什么是问题,但我不知道为此编写代码。 (if in some ID_APARTMENT has this date range then don't show me this Apartment, rest yes) (如果在某些ID_APARTMENT中有此日期范围,则不要向我显示此公寓,请休息)

I found answer. 我找到答案了。 Need to use ->whereBetween - then in other query use ->whereNotIn result from first query. 需要使用-> whereBetween-然后在其他查询中使用-> whereNotIn来自第一个查询的结果。

It's easy now but i lost one week for this. 现在很容易,但是我为此失去了一个星期。 ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM