403Webshell
Server IP : 54.94.228.101  /  Your IP : 172.28.20.13
Web Server : Apache
System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/vinumday2_0/app/Modules/Cadastro/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/vinumday2_0/app/Modules/Cadastro/Models/Cadastro.php
<?php

namespace App\Modules\Cadastro\Models;

use DB;
use App\MyModel;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use App\CampoModulo;

class Cadastro extends MyModel
{
	use LogsActivity;
	use HasSlug;

	protected $table = 'cadastro';
	protected $fillable = ['id_facebook', 'id_twitter', 'id_google', 'nome', 'sobrenome', 'bloqueio_cliente', 'data_nascimento', 'genero', 'telefone', 'cpf', 'receber_novidades','cliente_analisado','obs_nota_fiscal','empresa_id', 'observacoes_internas', 'adega_virada_popup_contagem', 'cnpj', 'tipo_pessoa'];
	private $rules = array();
	private $messages = array();

	public function __construct(){
		parent::__construct();
		$this->setMessages($this->messages);
		$this->setRules($this->rules);
	}

	public function getLogNameToUse(string $eventName = ''): string
	{
		return 'log_cadastro';
	}

	/**
	* Get the options for generating the slug.
	*/
	public function getSlugOptions() : SlugOptions
	{
		return SlugOptions::create()
		->generateSlugsFrom(['nome', 'titulo'])
		->saveSlugsTo('slug');
	}

	public function getBySlug($slug){
		return DB::table($this->table)->where('slug',$slug)->firstOrFail();
	}

	public function criar($fields, $input){
		$insert = [];
		foreach ($fields as $field) {
			$insert[$field] = $input[$field];
		}

		$cadastro = new Cadastro();
		$cadastro->fill($insert);
		$cadastro->save();

		return $cadastro->id;
	}

	public function editar($fields, $input, $id){
		$insert = [];
		foreach ($fields as $field) {
			$insert[$field] = $input[$field];
		}

		$cadastro = Cadastro::find($id);
		$cadastro->fill($insert);
		$cadastro->save();

		return $id;
	}

	public function deletar($id){
		$cadastro = Cadastro::find($id);
		$cadastro->delete();
		return true;
	}


	public function getImagem($id){
		return DB::table($this->table.'_imagens')->find($id);
	}

	public function getImagens($id){
		return DB::table($this->table.'_imagens')->where('id_cadastro', $id)->get();
	}
	public function criar_imagem($input){
		return DB::table($this->table.'_imagens')->insert([
			[
				'id_cadastro' => $input['id_cadastro'],
				'thumbnail_principal' => $input['thumbnail_principal'],
			]
		]);
	}
	public function deletar_imagem($id){
		return DB::table($this->table.'_imagens')
		->where('id', $id)
		->delete();
	}

	public function getNextAutoIncrement(){
		$lastId = DB::select("SELECT AUTO_INCREMENT FROM information_schema.tables WHERE TABLE_NAME = '$this->table' ORDER BY table_name;")[0]->AUTO_INCREMENT;
		return $lastId;
	}

	public function nome_completo(){
		return $this->nome . (!empty($this->sobrenome) ? " {$this->sobrenome}" : "");
	}

	public function whatsapp(){
		return $this->hasOne('App\Modules\Whatsapp\Models\Whatsapp', 'cadastro_id');
	}

	public function adegaViradaParticipante(){
		return $this->hasOne('App\Modules\AdegaViradaParticipante\Models\AdegaViradaParticipante', 'cadastro_id')->orderBy('id', 'DESC')->limit(1);
	}

	public function adegaViradaParticipanteIndicacao(){
		return $this->hasOne('App\Modules\AdegaViradaParticipanteIndicacao\Models\AdegaViradaParticipanteIndicacao', 'cadastro_id')->orderBy('adega_virada_cupom_id', 'DESC')->limit(1);
	}

	public function contaCorrente(){
		return $this->hasOne('App\Modules\ContaCorrente\Models\ContaCorrente', 'cadastro_id')->whereRaw('confraria_id IS NULL')->orderBy('id', 'DESC')->limit(1);
	}

	public function contaCorrenteValidade(){
		return $this->hasOne('App\Modules\ContaCorrente\Models\ContaCorrente', 'cadastro_id')->where('tipo_movimento', 'E')->where('saldo_usado', 0)->whereRaw('confraria_id IS NULL')->orderBy('id', 'ASC')->limit(1);
	}

	public function contaCorrenteLancamentos(){
		return $this->hasMany('App\Modules\ContaCorrente\Models\ContaCorrente', 'cadastro_id')->whereRaw('confraria_id IS NULL')->orderBy('id', 'DESC');
	}

	public function influencer(){
		return $this->hasOne('App\Modules\Influencer\Models\Influencer', 'cadastro_id');
	}

	public function compras(){
		return $this->hasMany('App\Modules\PedidoVenda\Models\PedidoVenda', 'id_cliente')->where('frete', 0);
	}

	public function cartoes(){
		return $this->hasMany('App\Modules\CadastroCartao\Models\CadastroCartao', 'cadastro_id')->where('empresa_id', '=', $this->empresa_id)->where('ativo', 1);
	}

	public function cartoesDiferentes(){
		return $this->hasMany('App\Modules\CadastroCartao\Models\CadastroCartao', 'cadastro_id')->where('empresa_id', '<>', $this->empresa_id)->where('ativo', 1);
	}

	public function enderecos(){
		return $this->hasMany('App\Modules\CadastroEndereco\Models\CadastroEndereco', 'cadastro_id')
            ->where('cadastro_endereco.deletado', 0);
	}

	public function enderecoPrincipal(){
		return $this->hasOne('App\Modules\CadastroEndereco\Models\CadastroEndereco', 'cadastro_id')->where('principal', 1);
	}

	public function comentarios(){
		return $this->hasMany('App\Modules\CadastroHasComentario\Models\CadastroHasComentario', 'cadastro_id');
	}

	public function user(){
		return $this->belongsTo('App\User', 'user_id');
	}

	public function empresa(){
		return $this->belongsTo('App\Modules\Empresa\Models\Empresa', 'empresa_id');
	}

	public function confraria(){
		return $this->hasOne('App\Modules\Confraria\Models\Confraria', 'cadastro_id')->where('confraria.deleted', 0);
	}

	public function confrariaMembro(){
		return $this->hasOne('App\Modules\ConfrariaMembro\Models\ConfrariaMembro', 'cadastro_id')->where('confraria_membro.deleted', 0);
	}

	public function confrariaConvites(){
		return $this->hasMany('App\Modules\ConfrariaConvite\Models\ConfrariaConvite', 'cadastro_id');
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit