Aucune description

Rubric.php 677B

123456789101112131415161718192021222324252627282930313233343536373839
  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', '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. if ($criterion->id == $criterion_id) {
  28. return $criterion;
  29. }
  30. }
  31. }
  32. }