<?php

use Illuminate\Database\Eloquent\SoftDeletingTrait;

class Criterion extends Eloquent
{
    use SoftDeletingTrait;
    protected $dates = ['deleted_at'];

    protected $table = 'new_criteria';

    public function outcomes()
    {
//	    return $this->belongs('Objective')->belongs('Outcome');
//	    TODO: Changes here
//		return $this->belongs('Outcome');
        return $this->hasManyThrough('Outcome', 'Objective');
    }

    public function objectives()
    {
        return $this->belongsToMany('Objective');
    }

    public function rubrics()
    {
        return $this->belongsToMany('Rubric', 'new_criterion_rubric');
    }

	/**
	 * Return the program that the criterion belongs to
	 *
	 * @return Illuminate\Database\Eloquent\Model
	 */
	public function program()
	{
		return $this->belongsTo('Program');
	}

	public function subcriteria()
	{
		return json_decode($this->subcriteria);
	}

}
