First Commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FluxoCaixaPro\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CashFlowAnalysis
|
||||
*
|
||||
* Represents an AI-generated cash flow analysis in the Fluxo de Caixa Pró module.
|
||||
*
|
||||
* @package Modules\FluxoCaixaPro\Models
|
||||
*/
|
||||
class CashFlowAnalysis extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'cash_flow_analysis';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'idbus',
|
||||
'iduser',
|
||||
'analysis_date',
|
||||
'summary_data',
|
||||
'recommendations',
|
||||
'projections'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'idbus' => 'integer',
|
||||
'iduser' => 'integer',
|
||||
'analysis_date' => 'date',
|
||||
'summary_data' => 'array',
|
||||
'projections' => 'array'
|
||||
];
|
||||
|
||||
/**
|
||||
* The "booted" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('company', function ($query) {
|
||||
if (isset($_SESSION['user_idbus']) && $_SESSION['user_idbus'] !== null && (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'super_admin')) {
|
||||
$query->where('idbus', $_SESSION['user_idbus']);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($model) {
|
||||
if (isset($_SESSION['user_idbus'])) {
|
||||
$model->idbus = $_SESSION['user_idbus'];
|
||||
}
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$model->iduser = $_SESSION['user_id'];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SysCMS - Content Management System
|
||||
*
|
||||
* Copyright (c) 2026 SysCMS Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: SysCMS Team
|
||||
* Project: SysCMS
|
||||
*/
|
||||
|
||||
namespace Modules\FluxoCaixaPro\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Category - Model for cash flow categories
|
||||
*
|
||||
* @package Modules\FluxoCaixaPro\Models
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'cash_flow_categories';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'idbus',
|
||||
'iduser',
|
||||
'name',
|
||||
'type',
|
||||
'color',
|
||||
'icon',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'idbus' => 'integer',
|
||||
'iduser' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime'
|
||||
];
|
||||
|
||||
/**
|
||||
* The "booted" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('company', function ($query) {
|
||||
if (isset($_SESSION['user_idbus']) && $_SESSION['user_idbus'] !== null && (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'super_admin')) {
|
||||
$query->where('idbus', $_SESSION['user_idbus']);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($model) {
|
||||
if (isset($_SESSION['user_idbus'])) {
|
||||
$model->idbus = $_SESSION['user_idbus'];
|
||||
}
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$model->iduser = $_SESSION['user_id'];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* transactions - Get transactions for this category
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class, 'category_id');
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\FluxoCaixaPro\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Class Transaction
|
||||
*
|
||||
* Represents a financial transaction in the Fluxo de Caixa Pró module.
|
||||
*
|
||||
* @package Modules\FluxoCaixaPro\Models
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'cash_flow_transactions';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'idbus',
|
||||
'iduser',
|
||||
'category_id',
|
||||
'description',
|
||||
'amount',
|
||||
'transaction_date',
|
||||
'due_date',
|
||||
'payment_date',
|
||||
'type',
|
||||
'status',
|
||||
'is_personal',
|
||||
'notes',
|
||||
'metadata'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'idbus' => 'integer',
|
||||
'iduser' => 'integer',
|
||||
'amount' => 'decimal:2',
|
||||
'transaction_date' => 'date',
|
||||
'due_date' => 'date',
|
||||
'payment_date' => 'date',
|
||||
'is_personal' => 'boolean',
|
||||
'metadata' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime'
|
||||
];
|
||||
|
||||
/**
|
||||
* The "booted" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('company', function ($query) {
|
||||
if (isset($_SESSION['user_idbus']) && $_SESSION['user_idbus'] !== null && (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'super_admin')) {
|
||||
$query->where('idbus', $_SESSION['user_idbus']);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function ($model) {
|
||||
if (isset($_SESSION['user_idbus'])) {
|
||||
$model->idbus = $_SESSION['user_idbus'];
|
||||
}
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$model->iduser = $_SESSION['user_id'];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category that owns the transaction.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'category_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user