<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Pricing extends Model
{
    protected $table = 'pricings';

    protected $primaryKey = 'id';

    protected $fillable = [
        'company_id', 'name', "stripe_id", 'description', 'price', 'vat_included', 'wod_counter', 'open_counter',
        'total_counter', 'days', 'start_time', 'end_time', 'recharge_weekly', 'is_public'
    ];

    protected $casts = [
        "recharge_weekly" => "boolean",
        "is_public" => "boolean"
    ];

    protected $with = ["boxes"];

    public function company(){
        return $this->belongsTo("App\Company", "company_id")->without("boxes");
    }

    public function boxes(){
        return $this->belongsToMany("App\Box", "pricing_box")->without("company");
    }

    public function user_subscriptions(){
        return $this->hasMany("App\UserSubscription","pricing_id","id");
    }
}
