public function erase($offerout_id) { try { $offerout = Model::Offerout()->findOrFail((int) $offerout_id); } catch (Exception $e) { return false; } $appointment = Model::Appointment()->where(['offerout_id', '=', (int) $offerout_id])->first(true); if ($appointment) { $appointment->delete(); } $offerout->status_id = (int) lib('status')->getId('offerout', 'ERASE'); return $offerout->save(); }
public function addAppointment($start, $end, $reseller_id, $reselleremployee_id, $offerout_id) { $time = lib('time'); $midnightStart = (int) $time->createFromTimestamp((int) $start)->startOfDay()->getTimestamp(); $midnightEnd = (int) $time->createFromTimestamp((int) $end)->startOfDay()->getTimestamp(); if ($midnightStart != $midnightEnd) { throw new Exception("start and end must be in the same day. Please cut your appointment."); } return Model::Appointment()->create(['reseller_id' => (int) $reseller_id, 'reselleremployee_id' => (int) $reselleremployee_id, 'offerout_id' => (int) $offerout_id, 'start' => (int) $start, 'end' => (int) $end])->save(); }