• File: TransferHistory.php
  • Full Path: /var/www/imaliapitest/app/TransferHistory.php
  • Date Modified: 05/19/2025 4:29 PM
  • File size: 1.46 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;


class TransferHistory extends Model
{
    use LogsActivity;

    protected $fillable = [
        'transaction_id', 'user_id', 'username', 'account_number', 'amount', 'description', 'comissao', 'estado_color', 'user_status',
        'estado', 'amount_debited', 'sender_id', 'receiver_id', 'client_id', 'transaction_type', 'transaction_name', 'reciever_account', 'sender_account'
    ];

    protected static $logAttributes = [
        'transaction_id', 'user_id', 'username', 'account_number', 'amount', 'description', 'comissao', 'estado_color', 'user_status',
        'estado', 'amount_debited', 'sender_id', 'receiver_id', 'client_id'
    ];

    protected static $logName = 'TransferHistory';

    public function getDescriptionForEvent(string $eventName): string
    {
        return "This model has been {$eventName}";
    }

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('d-m-Y H:i:s');
    }

    function transactionHistories()
    {
        return $this->hasMany(TransactionHistory::class);
    }

    function client()
    {
//        return $this->belongsTo(User::class);
        return $this->belongsTo(User::class, 'client_id');
    }

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()->logOnly(["*"]);
    }
}