<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Unit;

class Pipeline extends Model
{
    //
    protected $table = 'pipelines';
    protected $fillable = ['name', 'slug', 'public','description','hidden'];


    public function units()
    {
        return $this->belongsToMany('App\Unit', 'unit_pipeline')->withPivot('order')->orderBy('pivot_order');
    }

    public function unitsByRevision($revision)
    {
        return $this->belongsToMany('App\Unit', 'unit_pipeline')->withPivot(['order','revision'])->where('revision',$revision)->orderBy('pivot_order')->get();
    }
}


