Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- class Apartment extends Model
- {
- public function booking(){
- return $this->hasMany(Booking::class);
- }
- public function reserved(){
- $booked = $this->booking;
- $date=[];
- foreach ($booked as $reserved){
- $startDate = $reserved->startDate;
- $endDate = $reserved->endDate;
- $begin = new \DateTime($startDate);
- $end = new \DateTime($endDate);
- $interval = \DateInterval::createFromDateString('1 day');
- /*$period = array_merge($period, new \DatePeriod($begin, $interval, $end));*/
- $period = new \DatePeriod($begin, $interval, $end);
- foreach ($period as $dt) {
- $date [] = $dt-> format("Y-m-d");
- }
- }return $date;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement