Add VerifactuLog

This commit is contained in:
David Bomba 2025-08-07 15:16:04 +10:00
parent d42735f2ee
commit bf5359cb72
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property int $company_id
* @property int $invoice_id
* @property string $nif
* @property Carbon $date
* @property string $invoice_number
* @property string $hash
* @property string $previous_hash
* @property string $status
* @property object|null $response
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property-read \App\Models\Company $company
* @property-read \App\Models\Invoice $invoice
*/
class VerifactuLog extends Model
{
public $timestamps = true;
protected $casts = [
'date' => 'date',
'response' => 'object',
];
public function company()
{
return $this->belongsTo(Company::class);
}
public function invoice()
{
return $this->belongsTo(Invoice::class);
}
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('verifactu_logs', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('company_id')->index();
$table->unsignedInteger('invoice_id')->index();
$table->string('nif');
$table->string('date');
$table->string('invoice_number');
$table->string('hash');
$table->string('previous_hash')->nullable();
$table->string('status');
$table->json('response')->nullable();;
$table->timestamps();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade')->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};