Leave.php 706 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Leave extends Model
  5. {
  6. protected $table = 'leaves';
  7. protected $guarded = [];
  8. public function student()
  9. {
  10. return $this->belongsTo('App\Models\Student');
  11. }
  12. public function course()
  13. {
  14. return $this->belongsTo('App\Models\Course');
  15. }
  16. public function studentCourse()
  17. {
  18. return $this->belongsTo('App\Models\StudentCourse');
  19. }
  20. public function getStudentName()
  21. {
  22. return empty($this['student']) ? '' : $this['student']->name;
  23. }
  24. public function getCourseName()
  25. {
  26. return empty($this['course']) ? '' : $this['course']->name;
  27. }
  28. }