<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Packages extends Model {

    //
    public function prices() {
        return $this->hasMany(PackagePrices::class, 'package_id', 'id');
    }

    public function facilities() {
        return $this->hasMany(PackageFacilities::class, 'package_id', 'id');
    }

    public function category() {
        return $this->hasOne(Categories::class, 'id', 'category_id');
    }

    public function metrics() {
        return Facilities::join('package_facilities', 'package_facilities.facility_id', '=', 'facilities.id')
                        ->join('packages', 'package_facilities.package_id', '=', 'packages.id')
                        ->where('packages.id', $this->id);
    }

}
