First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace Modules\Erp\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class Customer extends Model
{
protected $table = 'sis_cadclientes';
protected $primaryKey = 'cliente_id';
public $timestamps = false;
protected $fillable = [
'cliente_razaosocial',
'cliente_nfantasia',
'cliente_contato',
'cliente_email',
'cliente_endereco',
'cliente_bairro',
'cliente_cidade',
'cliente_cep',
'cliente_uf',
'cliente_cnpj', // CNPJ
'cliente_ccpf', // CPF
'cliente_telefone',
'cliente_ative',
'cliente_data',
'cliente_horadecad',
'cliente_idbus'
];
/**
* Boot the model.
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('company', function (Builder $builder) {
if (isset($_SESSION['user_idbus']) && $_SESSION['user_idbus'] !== null && (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'super_admin')) {
$builder->where('cliente_idbus', $_SESSION['user_idbus']);
}
});
static::creating(function ($model) {
if (empty($model->cliente_data)) {
$model->cliente_data = date('d/m/Y');
}
if (empty($model->cliente_horadecad)) {
$model->cliente_horadecad = date('H:i:s');
}
if (empty($model->cliente_ative)) {
$model->cliente_ative = 'yes';
}
});
}
}