Nenhuma descrição

Rubric.php 719B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. public function activities()
  19. {
  20. return $this->belongsToMany('Activity', 'new_rubric_activity');
  21. }
  22. public function getCriterion($id, $criterion_id)
  23. {
  24. $rubric = Rubric::findOrFail($id);
  25. $rubric_contents = json_decode($rubric->contents);
  26. foreach ($rubric_contents as $key => $criterion)
  27. {
  28. if($criterion->id == $criterion_id)
  29. {
  30. return $criterion;
  31. }
  32. }
  33. }
  34. }