Files
fdesk/app/common/model/FinPaymentApply.php
T
2025-11-01 14:44:47 +08:00

76 lines
1.9 KiB
PHP

<?php
namespace app\common\model;
use Illuminate\Database\Eloquent\SoftDeletes;
use support\Model;
class FinPaymentApply extends Model
{
use SoftDeletes;
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'fin_payment_apply';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'apply_no', 'doc_user_id', 'sales_user_id', 'corp_id', 'account_id', 'payment_account', 'payment_entity', 'entity_type', 'currency_id', 'amount', 'swift', 'remit_bank', 'country_id', 'remitter', 'exchange_rate', 'total_amount_cny', 'voucher_file', 'voucher_name', 'submit_files','receipt_id','claimed_at','warn', 'received_at', 'created_at', 'updated_at', 'deleted_at', 'claimed_by', 'created_by',];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
/**
* 获取对应的收款记录(1-1,可为空)
*/
public function receipt()
{
return $this->hasOne(FinReceipt::class, 'payment_apply_id', 'id');
}
/**
* 关联的备货单(通过中间表)
*/
public function stocks()
{
return $this->belongsToMany(StockOrders::class, 'fin_payment_stock', 'payment_apply_id', 'stock_id');
}
/**
* 查询 submit_files 不为空的记录
*/
public function scopeWithNonEmptyFiles($query)
{
return $query->whereNotNull('submit_files')
->whereRaw('JSON_LENGTH(submit_files) > 0');
}
}