No Description

Section.php 744B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. class Section extends Model
  6. {
  7. protected $fillable = [
  8. 'course_id',
  9. 'semester_code',
  10. 'code',
  11. 'credits',
  12. 'student_count',
  13. 'syllabus'
  14. ];
  15. public $timestamps = false;
  16. public function semester() {
  17. return $this->belongsTo(Semester::class);
  18. }
  19. public function course() {
  20. return $this->belongsTo(Course::class);
  21. }
  22. public function professors() {
  23. return $this->belongsToMany(Professor::class);
  24. }
  25. public function getExtraCreditsAttribute() {
  26. return calcExtraCredits($this->credits, $this->student_count);
  27. }
  28. }