i have a table called Reservation
id | property_id | name | checkin_date | checkout_date | guests
1 | 1 | Tim | 2016-01-10 | 2016-01-15 | 3
2 | 2 | Alex | 2016-01-16 | 2016-01-26 | 5
3 | 1 | Kevin | 2016-01-28 | 2016-02-10 | 3
and so on.
i need to display checkin date and checkout date based on month wise and if date is between two months result should display on both the months ...my expected output in view page is
January
2016-01-10 To 2016-01-15 Tim Booked
2016-01-16 To 2016-01-26 Alex Booked
2016-01-28 To 2016-01-31 Kevin Booked
February
2016-02-01 To 2016-02-10 Kevin Booked
March, April,June...etc
i already done some partial coding.
in my controller
public function index{
for($i=1; $i<=12; i++){
$("reservation".$i)=Reservation::whereMonth('checkin_date','=',$i)
->get();
}
return view('abc',compact(reservation1,reservation2));
}
and in my view file
<h3>January</h3>
<?php foreach($reservation1 as $january){ ?>
<?php echo $january->checkin_date; ?> To <?php echo $january->checkout_date; ?> <?php echo $january->name; ?> Booked
please someone help me to get output...thanks in advance
You need this library FullCalendar
Controller
public function test(){
$events = [];
//creating events
$events[] = \Calendar::event(
'Angel', //event title
true, //full day event?
'2016-01-01', //start time (you can also use Carbon instead of DateTime)
'2016-01-03', //end time (you can also use Carbon instead of DateTime)
1, //optionally, you can specify an event ID
[
'backgroundColor' => '#ff5722'
]
);
$events[] = \Calendar::event(
'Jesus', //event title
true, //full day event?
'2016-01-04', //start time (you can also use Carbon instead of DateTime)
'2016-01-08', //end time (you can also use Carbon instead of DateTime)
1, //optionally, you can specify an event ID
[
'backgroundColor' => '#e97118'
]
);
//adding events
$calendar = \Calendar::addEvents($events)->setOptions(['lang' => 'es']);
return view('pages.calendar')->with('calendar',$calendar);
}
View (it's better to use blade)
<div class="row">
<div class="col-md-12">
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}
</div>
</div>