<?php

namespace App;

use App\Extensions\CustomStripeUserBillableTrait;
use Illuminate\Database\Eloquent\Model;

class StripeUser extends Model {

    use CustomStripeUserBillableTrait; //nomes per guardar metode de pagament

    protected $fillable = ["user_id", "company_id"];

    protected $hidden = ["stripe_payment_id"];

    protected $appends = ["is_stripe_active"];

    protected $casts = [
        "is_stripe_active" => "boolean"
    ];

    public function getIsStripeActiveAttribute() {
        return $this->stripe_id!=null && $this->stripe_payment_method_id!=null;
    }

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

    public function user() {
        return $this->belongsTo("App\User");
    }
}
