<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class TrainingWorkout extends Model
{
    protected $fillable = [
        "box_id", "name", "description", "category"
    ];

    protected $with = ['trainingWorkoutSections'];

    public function trainingWorkoutSections(){
        return $this->hasMany("App\TrainingWorkoutSection");
    }

    public function trainingSessions(){
        return $this->hasMany("App\TrainingSession","training_workout_id","id");
    }

    public function userBenchmarks() {
        return $this->hasManyThrough("App\UserBenchmark", "App\TrainingSession");
    }

    public function box(){
        return $this->belongsTo("App\Box","box_id");
    }

    public function isGeneric() {
        return $this->box == null;
    }

    public function users() {
        return $this->belongsToMany("App\TrainingWorkout");
    }
}
