1: <?php
2:
3: /**
4: * Mapeo de la tabla representantes
5: * @package modelos
6: * @author Fernando Salas <rfsalas@rutatec.com>
7: * @since 2016-02-23
8: */
9: class Student extends Eloquent {
10:
11: /**
12: * @string variable para mapeo de la tabla estudiante con el nombre que le corresponde en la base de datos
13: */
14: protected $table = 'student';
15:
16: /**
17: * @string variable llave primaria utilizada en la tabla student
18: */
19: protected $primaryKey = 'serial_std';
20:
21: /**
22: * @string variable de tiempo
23: */
24: public $timestamps = false;
25:
26: /**
27: * Establece la relacion con la tabla usuarios
28: *
29: * @param void
30: *
31: * @return void
32: * @throws InvalidArgumentException
33: * @since 2016-02-23
34: * @author Fernando Salas <rfsalas@rutatec.com>
35: *
36: * @edit 2016-02-23<br />
37: * Fernando Salas <rfsalas@rutatec.com><br />
38: * documentacion del metodo<br/>
39: * #edit1
40: */
41: public function user() {
42: return $this->belongsTo('User', 'serial_usr');
43: }
44:
45: /**
46: * Establece una consulta con las tablas curso, seccion,paralelo, nivel
47: *
48: * @param void
49: *
50: * @return void
51: * @throws InvalidArgumentException
52: * @since 2016-02-23
53: * @author Fernando Salas <rfsalas@rutatec.com>
54: *
55: * @edit 2016-02-23<br />
56: * Fernando Salas <rfsalas@rutatec.com><br />
57: * documentacion del metodo<br/>
58: * #edit1
59: */
60: public function course() {
61: return $this->join('student_by_course', function($join) {
62: $join->on('student.serial_std', '=', 'student_by_course.serial_std')
63: ->where('student_by_course.serial_std', '=', $this->serial_std)
64: ->where('student_by_course.status_stc', '=', 'ACTIVE');
65: })
66: ->join('course', function($join) {
67: $join->on('student_by_course.serial_crs', '=', 'course.serial_crs')
68: ->where('course.status_crs', '=', 'ACTIVE');
69: })
70: ->join('section', function($join) {
71: $join->on('course.serial_set', '=', 'section.serial_set')->where('section.status_set', '=', 'ACTIVE');
72: })
73: ->join('level', function($join) {
74: $join->on('course.serial_lvl', '=', 'level.serial_lvl')->where('level.status_lvl', '=', 'ACTIVE');
75: })
76: ->join('class_group', function($join) {
77: $join->on('course.serial_clg', '=', 'class_group.serial_clg')->where('class_group.status_clg', '=', 'ACTIVE');
78: })
79: ->where('student.status_std', '=', 'ACTIVE')
80: ->select('course.serial_crs', 'section.serial_set', 'section.name_set', 'level.serial_lvl', 'level.name_lvl', 'class_group.serial_clg', 'class_group.name_clg')
81: ->first();
82: }
83:
84: }
85: