/**
  * Approve the specified attendance
  *
  * @param $id
  * @return mixed
  */
 public function approve($id)
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $a = Attendance::find($id);
     if ($a->approved == 0) {
         $a->approved = 1;
     } elseif ($a->approved == 1) {
         $a->approved = 2;
     }
     $a->save();
     return Redirect::route('attendances.index');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $attd = Attendance::find(Input::get('id'));
     $ispresent = Input::get('ispresent');
     if ($ispresent == null) {
         $attd->status = "No";
     } else {
         $attd->status = "Yes";
     }
     $attd->save();
     echo '<script> alert("attendacne updated successfully.");window.close();</script>';
 }
 public static function fullParentInfo($startId)
 {
     $cacheName = "att." . App::$instance->tbId . ".parentInfo.{$startId}";
     $result = App::$instance->cache->get($cacheName);
     if (!$result) {
         $result = [];
         if ($startId == 1) {
             return false;
         } else {
             $att = Attendance::find($startId);
             $result[] = $att;
         }
         while ($att->parent_id != 1) {
             $att = Attendance::find($att->parent_id);
             $result[] = $att;
         }
         $cachedObj = new CachedObject($result, ['tag.' . $cacheName]);
         App::$instance->cache->set($cacheName, $cachedObj, 3600 * 24 * 7);
     }
     return array_reverse($result);
 }