コード例 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $student = Student::find($id);
     if ($student == NULL) {
         throw new Exception('Invalid Student ID');
     }
     $student->year = (int) substr($student->year, 2, 4);
     $student_category = StudentCategories::find($student->category);
     $student->category = $student_category->category;
     $student_branch = Branch::find($student->branch);
     $student->branch = $student_branch->branch;
     if ($student->rejected == 1) {
         unset($student->approved);
         unset($student->books_issued);
         $student->rejected = (bool) $student->rejected;
         return $student;
     }
     if ($student->approved == 0) {
         unset($student->rejected);
         unset($student->books_issued);
         $student->approved = (bool) $student->approved;
         return $student;
     }
     unset($student->rejected);
     unset($student->approved);
     $student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get();
     foreach ($student_issued_books as $issued_book) {
         $issue = Issue::find($issued_book->book_issue_id);
         $book = Books::find($issue->book_id);
         $issued_book->name = $book->title;
         $issued_book->issued_at = date('d-M', $issued_book->issued_at);
     }
     $student->issued_books = $student_issued_books;
     return $student;
 }
コード例 #2
0
ファイル: AdminController.php プロジェクト: bersace/strass
 function logAction()
 {
     $t = new Logs();
     $this->metas(array('DC.Title' => 'Journal système'));
     $this->branche->append();
     $s = $t->select()->from('log')->order('date DESC');
     $this->view->events = new Strass_Pages_Model_Rowset($s, 30, $this->_getParam('page'));
 }
コード例 #3
0
 public function index()
 {
     $logs = Logs::select('id', 'book_issue_id', 'student_id', 'issued_at')->where('return_time', '=', 0)->orderBy('issued_at', 'DESC');
     $logs = $logs->get();
     for ($i = 0; $i < count($logs); $i++) {
         $issue_id = $logs[$i]['book_issue_id'];
         $student_id = $logs[$i]['student_id'];
         // to get the name of the book from book issue id
         $issue = Issue::find($issue_id);
         $book_id = $issue->book_id;
         $book = Books::find($book_id);
         $logs[$i]['book_name'] = $book->title;
         // to get the name of the student from student id
         $student = Student::find($student_id);
         $logs[$i]['student_name'] = $student->first_name . ' ' . $student->last_name;
         // change issue date and return date in human readable format
         $logs[$i]['issued_at'] = date('d-M', $logs[$i]['issued_at']);
         $logs[$i]['return_at'] = date('d-M', $logs[$i]['issued_at'] + 1209600);
     }
     return $logs;
 }
コード例 #4
0
ファイル: Logs.php プロジェクト: nattaphat/cuse2
 public function getDataStat()
 {
     $rs = Logs::select(DB::raw("count (*) "), "data_id", "data_name")->join("data", "data.id", '=', "logs.data_id")->groupBy("data_id", "data_name")->orderBy("data_id")->get();
     return $rs;
 }