Advertisement
Guest User

Untitled

a guest
May 31st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Planejamento;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6.  
  7. class Planejamento extends Model
  8. {
  9.     protected $table = 'e001pla';
  10.     protected $primaryKey = 'codpla';
  11.     protected $fillable = [
  12.         'codemp',
  13.         'codfil',
  14.         'codsaf',
  15.         'codpla',
  16.         'iddiv3',
  17.         'codtec',
  18.         'codtci',
  19.         'plaare',
  20.         'codcul',
  21.     ];
  22.     public $timestamps = false;
  23.  
  24.     public function empresa()
  25.     {
  26.         return $this->hasOne('Planejamento\Empresa', 'codemp', 'codemp');
  27.     }
  28.  
  29.     public function filial()
  30.     {
  31.         return $this
  32.                     ->hasOne('Planejamento\Filial', 'codemp', 'codemp')
  33.                     ->where('codfil', $this->codfil);
  34.     }
  35.  
  36.     public function cultura()
  37.     {
  38.         return $this->hasOne('Planejamento\Cultura', 'codcul', 'codcul');
  39.     }
  40.  
  41.     public function tecnologia()
  42.     {
  43.         return $this->hasOne('Planejamento\Tecnologia', 'codtec', 'codtec');
  44.     }
  45.  
  46.     public function tipociclo()
  47.     {
  48.         return $this->hasOne('Planejamento\TipoCiclo', 'codtci', 'codtci');
  49.     }
  50.  
  51.     public function talhao()
  52.     {
  53.         return $this->hasOne('Planejamento\Talhao', 'codemp', 'codemp')
  54.                     ->where('iddiv3', $this->iddiv3);
  55.     }
  56.  
  57.     public function divisao()
  58.     {
  59.         return $this->hasOne('Planejamento\Bloco', 'codemp', 'codemp')
  60.                     ->where('codfil', $this->talhao->codfil)
  61.                     ->where('coddv2', $this->talhao->coddv2);
  62.     }
  63.  
  64.     public function bloco()
  65.     {
  66.         return $this->hasOne('Planejamento\Divisao', 'codemp', 'codemp')
  67.                     ->where('codfil', $this->talhao->codfil)
  68.                     ->where('coddv1', $this->talhao->coddv1);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement