Initial commit: Horux Backend API

- API REST para gestion de facturas electronicas mexicanas (CFDI)
- Laravel 9 con autenticacion OAuth 2.0 (Passport)
- Integracion con Syntage, Clerk y Facturama
- 30 modelos Eloquent, 39 controladores
- Documentacion completa en /docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-18 07:44:29 +00:00
commit 61320b44d8
191 changed files with 22895 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class CancellationType extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'description',
];
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Conciliation extends Model
{
use HasFactory;
protected $fillable = [
'invoice_id',
'rfc_id',
'payment_description',
'payment_at',
'is_conciliated',
'conciliated_at'
];
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
public function rfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
}

35
app/Models/Currency.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Currency extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
public $incrementing = false;
protected $keyType = 'string';
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoicePayments(): HasMany
{
return $this->hasMany(InvoicePayment::class);
}
}

22
app/Models/Dimension.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class Dimension extends Model
{
use HasFactory;
public function salesRevenues(): HasMany
{
return $this->hasMany(SalesRevenue::class);
}
public function expenditures(): HasMany
{
return $this->hasMany(Expenditure::class);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Model;
class EconomicActivity extends Model
{
use HasFactory;
public function taxPayers(): BelongsToMany
{
return $this->belongsToMany(TaxPayers::class);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class Expenditure extends Model
{
use HasFactory;
public function taxpayer(): BelongsTo
{
return $this->belongsTo(Taxpayer::class);
}
public function dimension(): BelongsTo
{
return $this->belongsTo(Dimension::class);
}
}

11
app/Models/Industry.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Industry extends Model
{
use HasFactory;
}

230
app/Models/Invoice.php Normal file
View File

@@ -0,0 +1,230 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class Invoice extends Model
{
use HasFactory;
protected $fillable = [
'id',
'api_id',
'rfc_id',
'version',
'invoice_type_id',
'usage_id',
'payment_type_id',
'payment_method_id',
'zip_code',
'currency_id',
'exchange_rate',
'status_id',
'pac',
'issued_at',
'certified_at',
'cancellation_status_id',
'cancellation_type_id',
'cancelled_at',
'discount',
'tax',
'subtotal',
'total',
'paid_amount',
'due_amount',
'fully_paid_at',
'last_payment_date',
'issuer_rfc_id',
'issuer_name',
'receiver_rfc_id',
'receiver_name',
'is_issuer',
'is_receiver',
'internal_id',
'reference',
'credited_amount',
'subtotal_credited_amount',
'applied_taxes',
'total_transferred_taxes',
'transferred_local_taxes',
'transferred_vat',
'transferred_sin_tax',
'total_retained_taxes',
'retained_local_taxes',
'retained_vat',
'retained_income_tax',
'retained_sin_tax',
'is_conciliated',
];
public function invoiceType(): BelongsTo
{
return $this->belongsTo(InvoiceType::class);
}
public function rfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function usage(): BelongsTo
{
return $this->belongsTo(Usage::class);
}
public function paymentType(): BelongsTo
{
return $this->belongsTo(PaymentType::class);
}
public function paymentMethod(): BelongsTo
{
return $this->belongsTo(PaymentMethod::class);
}
public function currency(): BelongsTo
{
return $this->belongsTo(Currency::class);
}
public function status(): BelongsTo
{
return $this->belongsTo(Status::class);
}
public function cancellationType(): BelongsTo
{
return $this->belongsTo(CancellationType::class);
}
public function cancellationStatus(): BelongsTo
{
return $this->belongsTo(Status::class);
}
public function issuerRfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function receiverRfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function invoiceLines(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
public function conciliations(): HasMany
{
return $this->hasMany(Conciliation::class);
}
public function invoicePayments(): HasMany
{
return $this->hasMany(InvoicePayment::class);
}
public function getRfcAttribute()
{
return $this->rfc()->first()->rfc;
}
public function getStatusAttribute()
{
return $this->status()->first()->description;
}
public function getCancellationTypeAttribute()
{
return $this->cancellationType()->first()->description;
}
public function getCancellationStatusAttribute()
{
return $this->cancellationStatus()->first()->description;
}
public function getIssuerRfcAttribute()
{
return $this->issuerRfc()->first()->rfc;
}
public function getReceiverRfcAttribute()
{
return $this->receiverRfc()->first()->rfc;
}
public function getTotalInMxnAttribute()
{
if ($this->exchange_rate) {
$totalMXN = $this->total * $this->exchange_rate;
} else {
$totalMXN = $this->total;
}
return $totalMXN;
}
public function getTaxInMxnAttribute()
{
if ($this->exchange_rate) {
$taxMXN = $this->tax * $this->exchange_rate;
} else {
$taxMXN = $this->tax;
}
return $taxMXN;
}
public function getTransferredVatInMxnAttribute()
{
if ($this->exchange_rate) {
$transferredVatMXN = $this->transferred_vat * $this->exchange_rate;
} else {
$transferredVatMXN = $this->transferred_vat;
}
return $transferredVatMXN;
}
public function getTransferredSinTaxInMxnAttribute()
{
if ($this->exchange_rate) {
$transferredSinMXN = $this->transferred_sin_tax * $this->exchange_rate;
} else {
$transferredSinMXN = $this->transferred_sin_tax;
}
return $transferredSinMXN;
}
public function getRetainedVatInMxnAttribute()
{
if ($this->exchange_rate) {
$retainedVatMXN = $this->retained_vat * $this->exchange_rate;
} else {
$retainedVatMXN = $this->retained_vat;
}
return $retainedVatMXN;
}
public function getRetainedIncomeTaxInMxnAttribute()
{
if ($this->exchange_rate) {
$retainedIncomeTaxMXN = $this->retained_income_tax * $this->exchange_rate;
} else {
$retainedIncomeTaxMXN = $this->retained_income_tax;
}
return $retainedIncomeTaxMXN;
}
protected $keyType = 'string';
protected $hidden = ['rfc_id', 'status_id', 'cancellation_type_id', 'cancellation_status_id', 'issuer_rfc_id', 'receiver_rfc_id'];
protected $appends = ['rfc', 'status', 'cancellation_type', 'cancellation_status', 'issuer_rfc', 'receiver_rfc', 'total_in_mxn',
'tax_in_mxn', 'transferred_vat_in_mxn', 'transferred_sin_tax_in_mxn', 'retained_vat_in_mxn', 'retained_income_tax_in_mxn'];
}

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class InvoiceLine extends Model
{
use HasFactory;
protected $fillable = [
'id'
];
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
public function rfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function invoiceType(): BelongsTo
{
return $this->belongsTo(InvoiceType::class);
}
public function paymentType(): BelongsTo
{
return $this->belongsTo(PaymentType::class);
}
public function issuerRfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function receiverRfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function getIssuerRfcAttribute()
{
return $this->issuerRfc()->first()->rfc;
}
public function getReceiverRfcAttribute()
{
return $this->receiverRfc()->first()->rfc;
}
protected $keyType = 'string';
protected $hidden = ['issuer_rfc_id', 'receiver_rfc_id'];
protected $appends = ['issuer_rfc', 'receiver_rfc'];
}

View File

@@ -0,0 +1,162 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class InvoicePayment extends Model
{
use HasFactory;
protected $fillable = [
'id',
'cancelled_at'
];
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
public function rfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function paymentMethod(): BelongsTo
{
return $this->belongsTo(PaymentMethod::class);
}
public function currency(): BelongsTo
{
return $this->belongsTo(Currency::class);
}
public function getIssuerRfcAttribute()
{
return $this->invoice()->first()->issuer_rfc;
}
public function getReceiverRfcAttribute()
{
return $this->invoice()->first()->receiver_rfc;
}
public function getTotalInMxnAttribute()
{
if ($this->invoice()->first()->exchange_rate) {
$totalMXN = $this->invoice()->first()->total * $this->invoice()->first()->exchange_rate;
} else {
$totalMXN = $this->invoice()->first()->total;
}
return $totalMXN;
}
public function getAmountInMxnAttribute()
{
if ($this->exchange_rate) {
$amountMXN = abs($this->amount * $this->exchange_rate);
} else {
$amountMXN = abs($this->amount);
}
return $amountMXN;
}
public function getTransferredVatInMxnAttribute()
{
if ($this->invoice()->first()->exchange_rate) {
$transferredVatMXN = $this->invoice()->first()->transferred_vat * $this->invoice()->first()->exchange_rate;
} else {
$transferredVatMXN = $this->invoice()->first()->transferred_vat;
}
return $transferredVatMXN;
}
public function getRetainedVatInMxnAttribute()
{
if ($this->invoice()->first()->exchange_rate) {
$retainedVatMXN = $this->invoice()->first()->retained_vat * $this->invoice()->first()->exchange_rate;
} else {
$retainedVatMXN = $this->invoice()->first()->retained_vat;
}
return $retainedVatMXN;
}
public function getRetainedIncomeTaxInMxnAttribute()
{
if ($this->invoice()->first()->exchange_rate) {
$retainedIncomeTaxMXN = $this->invoice()->first()->retained_income_tax * $this->invoice()->first()->exchange_rate;
} else {
$retainedIncomeTaxMXN = $this->invoice()->first()->retained_income_tax;
}
return $retainedIncomeTaxMXN;
}
public function getTransferredVatPercentageAttribute()
{
$totalMXN = $this->getTotalInMxnAttribute();
$transferredVatMXN = $this->getTransferredVatInMxnAttribute();
$retainedVatMXN = $this->getRetainedVatInMxnAttribute();
$transferredVatPercentage = round(100*(($transferredVatMXN)/($totalMXN - $transferredVatMXN)));
return $transferredVatPercentage;
}
public function getTransferredVatPpdAttribute()
{
$transferredVatPercentage = $this->getTransferredVatPercentageAttribute();
if ($this->exchange_rate) {
$transferredVatPPD = round((abs($this->amount*$this->exchange_rate)/(1+($transferredVatPercentage*0.01)))*($transferredVatPercentage*0.01), 2);
} else {
$transferredVatPPD = round((abs($this->amount)/(1+($transferredVatPercentage*0.01)))*($transferredVatPercentage*0.01), 2);
}
return $transferredVatPPD;
}
public function getRetainedVatPercentageAttribute()
{
$totalMXN = $this->getTotalInMxnAttribute();
$transferredVatMXN = $this->getTransferredVatInMxnAttribute();
$retainedVatMXN = $this->getRetainedVatInMxnAttribute();
$retainedVatPercentage = round(100*(($retainedVatMXN)/($totalMXN - $transferredVatMXN)));
return $retainedVatPercentage;
}
public function getRetainedVatPpdAttribute()
{
$retainedVatPercentage = $this->getRetainedVatPercentageAttribute();
$transferredVatPercentage = $this->getTransferredVatPercentageAttribute();
if ($this->exchange_rate) {
$retainedVatPPD = round((abs($this->amount*$this->exchange_rate)/(1+($transferredVatPercentage*0.01)))*($retainedVatPercentage*0.01), 2);
} else {
$retainedVatPPD = round((abs($this->amount)/(1+($transferredVatPercentage*0.01)))*($retainedVatPercentage*0.01), 2);
}
return $retainedVatPPD;
}
public function getAbsAmountAttribute()
{
$absAmount = abs($this->amount);
return $absAmount;
}
protected $appends = [
'issuer_rfc', 'receiver_rfc', 'total_in_mxn',
'transferred_vat_in_mxn', 'retained_vat_in_mxn',
'retained_income_tax_in_mxn',
'transferred_vat_percentage', 'transferred_vat_ppd',
'retained_vat_percentage', 'retained_vat_ppd',
'abs_amount', 'amount_in_mxn'
];
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class InvoiceRequest extends Model
{
use HasFactory;
public function rfcs(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class InvoiceType extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoiceLines(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LinkedSocialAccount extends Model
{
use HasFactory;
protected $fillable = [
'provider_name',
'provider_id',
];
public function user()
{
return $this->belongsTo(User::class);
}
}

22
app/Models/ManagerOTP.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class ManagerOTP extends Model
{
use HasFactory;
public function users(): HasMany
{
return $this->belongsTo(User::class);
}
public function rfcs(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class PaymentMethod extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoicePayments(): HasMany
{
return $this->hasMany(InvoicePayment::class);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class PaymentType extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoiceLines(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
}

22
app/Models/PostalCode.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PostalCode extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProdServCode extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
}

62
app/Models/Rfc.php Normal file
View File

@@ -0,0 +1,62 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Model;
class Rfc extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'rfc',
];
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
public function managerOTP(): HasMany
{
return $this->hasMany(ManagerOTP::class);
}
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoiceLines(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
public function invoicePayments(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
public function invoiceRequest(): HasMany
{
return $this->hasMany(InvoiceRequest::class);
}
public function taxpayers(): HasMany
{
return $this->hasMany(Taxpayer::class);
}
public function conciliations(): HasMany
{
return $this->hasMany(Conciliation::class);
}
}

17
app/Models/Risk.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Model;
class Risk extends Model
{
use HasFactory;
public function taxPayers(): BelongsToMany
{
return $this->belongsToMany(TaxPayers::class);
}
}

27
app/Models/Role.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Role extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'description',
];
public function users(): HasMany
{
return $this->hasMany(User::class);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
class SalesRevenue extends Model
{
use HasFactory;
public function taxpayer(): BelongsTo
{
return $this->belongsTo(Taxpayer::class);
}
public function dimension(): BelongsTo
{
return $this->belongsTo(Dimension::class);
}
}

33
app/Models/Status.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class Status extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
public function invoiceLines(): HasMany
{
return $this->hasMany(InvoiceLine::class);
}
}

23
app/Models/Tax.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Tax extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
}

23
app/Models/TaxRate.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TaxRate extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'tax_id',
'description'
];
}

17
app/Models/TaxRegime.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Model;
class TaxRegime extends Model
{
use HasFactory;
public function taxPayers(): BelongsToMany
{
return $this->belongsToMany(TaxPayers::class);
}
}

48
app/Models/Taxpayer.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
class Taxpayer extends Model
{
use HasFactory;
protected $fillable = [
'rfc_id'
];
public function rfc(): BelongsTo
{
return $this->belongsTo(Rfc::class);
}
public function economicActivities(): BelongsToMany
{
return $this->belongsToMany(EconomicActivity::class);
}
public function taxRegimes(): BelongsToMany
{
return $this->belongsToMany(TaxRegime::class);
}
public function risks(): BelongsToMany
{
return $this->belongsToMany(Risks::class);
}
public function salesRevenues(): HasMany
{
return $this->hasMany(SalesRevenue::class);
}
public function expenditures(): HasMany
{
return $this->hasMany(Expenditure::class);
}
}

23
app/Models/UnitCode.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UnitCode extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
}

23
app/Models/Usage.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Usage extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'description'
];
protected $keyType = 'string';
}

70
app/Models/User.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use App\Models\LinkedSocialAccount;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable, HasApiTokens;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'role_id'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function linkedSocialAccounts()
{
return $this->hasMany(LinkedSocialAccount::class);
}
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}
public function rfcs(): BelongsToMany
{
return $this->belongsToMany(Rfc::class);
}
public function managerOTPs(): HasMany
{
return $this->hasMany(ManagerOTP::class);
}
}