<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ProductCategory extends Model
{

	use SoftDeletes;
	
	protected $hidden = ['created_at', 'updated_at', 'deleted_at'];

	public function company()
	{
		return $this->belongsTo('App\Company');
	}
	
	public function products()
	{
		return $this->hasMany('App\Product');
	}
	
	public function getTotalProductsAttribute()
    {
        return Product::where('product_category_id', $this->id)->count();
    }

}
