<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Authenticatable;


class TypeCapteur extends Model {
	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'types_capteurs';


	function getNbRucheAttribute() {
		$t_id_ruches=Capteur::select('id_ruche')->where('id_type_capteur','=',$this->id)->pluck('id_ruche')->toArray();
		$nb=Ruche::whereIn('id',$t_id_ruches)->count();
		return $nb;
	}


	function getNbMesuresAttribute() {
		$t_id_capteurs=Capteur::select('id')->where('id_type_capteur','=',$this->id)->pluck('id')->toArray();
		$nb=Mesure::whereIn('id_capteur',$t_id_capteurs)->count();

		return $nb;
	}

}