[eluser]kre8ivdesigns[/eluser]
Im an idiot just went through line by line and saw I called my has_many the plural of the table. Thanks for the help...... IF you ever need any help with designs let me know.
finished function
Code:
function check_dates($checkin,$checkout)
{
global $available;
$available = 0;
//convert times to right format
$begindate = date('Y-m-d',(strtotime($checkin)));
$enddate = date('Y-m-d',(strtotime($checkout)));
//how many days are in between
$date= round((strtotime($enddate) - strtotime($begindate)) / (60 * 60 * 24));
//gather all the dates from the client and check database
for ($i = 0; $i<$date; $i++) {
$newdates = strtotime('+'.$i.' day', strtotime($begindate));
$booking[$i] = date('Y-m-d', $newdates);
//compare dates to database to
$d = new Day();
$d->where('day',$booking[$i])->get();
if ($d->reservation->count()) {
$available = 1;
}
}