Нет описания

Section.php 849B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. 'quota'
  15. ];
  16. public $timestamps = false;
  17. public function semester() {
  18. return $this->belongsTo(Semester::class);
  19. }
  20. public function course() {
  21. return $this->belongsTo(Course::class);
  22. }
  23. public function professors() {
  24. return $this->belongsToMany(Professor::class);
  25. }
  26. public function schedules() {
  27. return $this->hasMany(Schedule::class);
  28. }
  29. public function getExtraCreditsAttribute() {
  30. return calcExtraCredits($this->credits, $this->student_count);
  31. }
  32. }