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

namespace App;

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

class Link extends Model
{
    use HasFactory;

    protected $fillable = [
        'link_id',
        'customer_link_id',
        'partner_transaction_id',
        // 'payment_transaction_id',
        'title',
        'amount',
        'imali_fee',
        'send_to_phone',
        'amount_to_credit',
        'short_description',
        'type',
        'store_id',
        'business_account_id',
        'thumbnail_image', // nao obrigatorio
        'thumbnail_location', // nao obrigatorio
        'expiration_datetime',

        'payment_frequence',
        'next_payment_date',

        'status', // 
    ];


    public function getThumbnailImageAttribute($thumbnail_image)
    {
        // $thumbnail_location;
        if ($this->thumbnail_location == 'COMERCIANTE_LOGO') {
            return $_ENV['IMG_STORES_LOGO'] . $thumbnail_image;
        }
        return $_ENV['IMG_LINKS_URL'] . $thumbnail_image;
    }

    // public function getLinkIdAttribute($link_id)
    // {
    //     return $_ENV['PAYMENT_LINK_URL'] . $link_id;
    // }

    public function getCustomerLinkIdAttribute($customer_link_id)
    {
        return ($customer_link_id != null) ? $_ENV['PAYMENT_LINK_URL'] . $customer_link_id : $_ENV['PAYMENT_LINK_URL'] . $this->link_id;
        // ($customer_link_id != null) ? $customer_link_id : $this->link_id;
    }
}