Нема описа

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class Rubric extends Eloquent
  3. {
  4. /**
  5. * Searchable rules.
  6. *
  7. * @var array
  8. */
  9. protected $searchable = [
  10. 'columns' => [
  11. 'name' => 10,
  12. ],
  13. ];
  14. public function professor()
  15. {
  16. return $this->belongsTo('User')->orderBy('created_at');
  17. }
  18. /*
  19. * TODO Check if this is true later.
  20. */
  21. public function activities()
  22. {
  23. return $this->hasMany('Activity');
  24. }
  25. public function getCriterion($id, $criterion_id)
  26. {
  27. $rubric = Rubric::findOrFail($id);
  28. $rubric_contents = json_decode($rubric->contents);
  29. foreach ($rubric_contents as $key => $criterion)
  30. {
  31. if($criterion->id == $criterion_id)
  32. {
  33. return $criterion;
  34. }
  35. }
  36. }
  37. }