[ 'name' => 10, ], ]; public function professor() { return $this->belongsTo('User')->orderBy('created_at'); } public function activities() { return $this->belongsToMany('Activity', 'new_rubric_activity'); } public function getCriterion($id, $criterion_id) { $rubric = Rubric::findOrFail($id); $rubric_contents = json_decode($rubric->contents); foreach ($rubric_contents as $key => $criterion) { if($criterion->id == $criterion_id) { return $criterion; } } } }