Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Planejamento;
- use Illuminate\Database\Eloquent\Model;
- class Planejamento extends Model
- {
- protected $table = 'e001pla';
- protected $primaryKey = 'codpla';
- protected $fillable = [
- 'codemp',
- 'codfil',
- 'codsaf',
- 'codpla',
- 'iddiv3',
- 'codtec',
- 'codtci',
- 'plaare',
- 'codcul',
- ];
- public $timestamps = false;
- public function empresa()
- {
- return $this->hasOne('Planejamento\Empresa', 'codemp', 'codemp');
- }
- public function filial()
- {
- return $this
- ->hasOne('Planejamento\Filial', 'codemp', 'codemp')
- ->where('codfil', $this->codfil);
- }
- public function cultura()
- {
- return $this->hasOne('Planejamento\Cultura', 'codcul', 'codcul');
- }
- public function tecnologia()
- {
- return $this->hasOne('Planejamento\Tecnologia', 'codtec', 'codtec');
- }
- public function tipociclo()
- {
- return $this->hasOne('Planejamento\TipoCiclo', 'codtci', 'codtci');
- }
- public function talhao()
- {
- return $this->hasOne('Planejamento\Talhao', 'codemp', 'codemp')
- ->where('iddiv3', $this->iddiv3);
- }
- public function divisao()
- {
- return $this->hasOne('Planejamento\Bloco', 'codemp', 'codemp')
- ->where('codfil', $this->talhao->codfil)
- ->where('coddv2', $this->talhao->coddv2);
- }
- public function bloco()
- {
- return $this->hasOne('Planejamento\Divisao', 'codemp', 'codemp')
- ->where('codfil', $this->talhao->codfil)
- ->where('coddv1', $this->talhao->coddv1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement