HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux Bradford-Sitios 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: 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,pcntl_unshare,
Upload Files
File: /var/www/dtw.bradford/app/Models/OdooRenditions.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OdooRenditions extends Model
{
    use HasFactory;

    protected $table = 'odoo_renditions_view';

    public $timestamps = false;

    protected $fillable = [
        'account_move_id',
        'name',
        'display_name',
        'state',
        'move_type',
        'ref',
        'date',
        'invoice_date_due',
        'partner_id',
        'partner',
        'partner_id_vat',
        'currency_id',
        'currency',
        'amount_untaxed',
        'amount_tax',
        'amount_total',
        'amount_total_words',
        'payment_state',
        'journal_id',
        'journal',
        'partner_bank_id',
        'partner_bank',
        'company_id',
        'company',
        'invoice_payment_term',
        'create_uid_id',
        'create_uid_name',
        'account_move_lines' // JSON con los detalles de la factura
    ];

     // Método para obtener detalles de líneas de la factura
    protected function details()
    {
        // Decode JSON from account_move_lines to an array
        return collect(json_decode($this->account_move_lines, true))->map(function ($line) {
            return [
                'line_id' => $line['line_id'],
                'move_id' => $line['move_id'],
                'name' => $line['name'],
                'product_id' => $line['product_id'],
                'product' => $line['product'],
                'quantity' => $line['quantity'],
                'price_unit' => $line['price_unit'],
                'price_subtotal' => $line['price_subtotal'],
                'price_total' => $line['price_total'],
            ];
        });
    }
 
    // Sobrescribir el método toArray
    public function toArray()
    {
        $array = parent::toArray();
        $array['account_move_lines'] = $this->details(); // Añadir las líneas formateadas
        return $array;
    }
}