403Webshell
Server IP : 54.94.228.101  /  Your IP : 172.28.1.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/Empresa/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

namespace App\Modules\Empresa\Models;

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

class Empresa extends MyModel
{
	use LogsActivity;
	use HasSlug;
	use Translatable;

	protected $table = 'empresa';
	protected $guarded = [];
	private $rules = array();
	private $messages = array();
	public $translatedAttributes = [];
	public $translationModel = 'App\Modules\Empresa\Models\EmpresaDescricao';

	public function __construct(){
		parent::__construct();
		$this->setMessages($this->messages);
		$this->setRules($this->rules);
		$this->translatedAttributes = CampoModulo::join('sis_modulos', 'sis_campo_modulo.id_modulo', '=', 'sis_modulos.id')->where('sis_campo_modulo.translatable', 1)->where('sis_modulos.nome', 'Empresa')->pluck('sis_campo_modulo.nome')->toArray();
	}

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

	/**
	* 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];
		}

		$empresa = new Empresa();
		$empresa->fill($insert);
		$empresa->save();

		return $empresa->id;
	}

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

		$empresa = Empresa::find($id);
		$empresa->fill($insert);
		$empresa->save();

		return $id;
	}

	public function deletar($id){
		$empresa = Empresa::find($id);
		$empresa->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_empresa', $id)->get();
	}
	public function criar_imagem($input){
		return DB::table($this->table.'_imagens')->insert([
			[
				'id_empresa' => $input['id_empresa'],
				'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 static function default(){
        return Empresa::where('slug', 'vinum-veritas')->first();

        /*
		$empresa = Empresa::where('classificacao', '=', 1)->first();
		if(!$empresa)
			$empresa = Empresa::find(4);
		return $empresa;
        */
	}

	public static function getApiKeyPagarMe($empresa = FALSE){
        try {

        	if(!$empresa)
        		$empresa = Empresa::default();
            
            if($empresa && !empty($empresa->api_key_pagar_me)){
                return $empresa->api_key_pagar_me;
            }

            return env("PAGARME_KEY");

        } catch (Exception $e) {
            return env("PAGARME_KEY");
        }
    }

    public static function getApiKeyTinyErp($empresa = FALSE){
        try {

        	if(!$empresa)
        		$empresa = Empresa::default();
            
            if($empresa && !empty($empresa->api_key_tiny_erp)){
                return $empresa->api_key_tiny_erp;
            }

            return env("TINYERP_KEY");

        } catch (Exception $e) {
            return env("TINYERP_KEY");
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit