<?php namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
class reporteaveria extends Sximo  {
	
	protected $table = 'ordendetrabajo';
	protected $primaryKey = 'OrdenID';

	public function __construct() {
		parent::__construct();
		
			$id = Auth::id();

		$dbcon = 0;
		$sql = \DB::table('tb_users')->where('id',$id)->get();
		if(count($sql)){
			$row = $sql[0];
			$dbcon =$row->dbcon;
			 $this->setConnection($dbcon);
		}
		
		
	}

	public static function querySelect(  ){
		
		return "  SELECT ordendetrabajo.* FROM ordendetrabajo  ";
	}	

	public static function queryWhere(  ){
	    
	     $id = Auth::id();

		$dbcon = 0;
		$sql = \DB::table('tb_users')->where('id',$id)->get();
		if(count($sql)){
			$row = $sql[0];
			$Email =$row->email;
		}	
	    
		
		return "  WHERE ordendetrabajo.OrdenID IS NOT NULL AND ordendetrabajo.email='$Email' ";
	}
	
	public static function queryGroup(){
		return "  ";
	}
	

}
