belongsTo(Cliente::class, 'cliente_id'); } public function usuario(){ return $this->belongsTo(User::class, 'usuario_id'); } public function projeto(){ return $this->belongsTo(ProjetoCusto::class, 'projeto_id'); } public function produtos() { return $this->hasMany(ProdutoPlanejamentoCusto::class, 'planejamento_id'); } public function servicos() { return $this->hasMany(ServicoPlanejamentoCusto::class, 'planejamento_id')->where('terceiro', 0); } public function servicosTerceiro() { return $this->hasMany(ServicoPlanejamentoCusto::class, 'planejamento_id')->where('terceiro', 1); } public function custosAdm() { return $this->hasMany(CustoAdmPlanejamentoCusto::class, 'planejamento_id'); } public function itensProposta() { return $this->hasMany(ItemPropostaPlanejamentoCusto::class, 'planejamento_id'); } public function cotacoes() { return $this->hasMany(Cotacao::class, 'planejamento_id'); } public function logs() { return $this->hasMany(PlanejamentoCustoLog::class, 'planejamento_id')->orderBy('id', 'desc'); } public static function estados(){ return [ // 'novo' => 'Novo', 'cotacao' => 'Cotação', 'proposta' => 'Proposta', 'producao' => 'Produção', 'cancelado' => 'Cancelado', 'finalizado' => 'Finalizado', ]; } public function proximosEstados(){ $insere = false; $retorno = ['' => 'Selecione']; return PlanejamentoCusto::estados(); foreach(PlanejamentoCusto::estados() as $key => $e){ if($insere){ $retorno[$key] = $e; } if($key == $this->estado){ $insere = true; } } return $retorno; } public function _estado(){ if($this->estado == 'novo'){ return "