<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class PartnerWithdrawal extends BaseModel
{
    use HasFactory;

    public function getInfoAttribute($value)
    {
        return json_decode($value, true);
    }

    public function setInfoAttribute($value)
    {
        $this->attributes['info'] = json_encode($value,JSON_UNESCAPED_UNICODE);
    }

    public function getBillPicAttribute($value)
    {
        return json_decode($value, true);
    }

    public function setBillPicAttribute($value)
    {
        $this->attributes['bill_pic'] = json_encode($value,JSON_UNESCAPED_UNICODE);
    }
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function partner()
    {
        return $this->belongsTo(Partner::class,'user_id','user_id');
    }

    public function serviceUser()
    {
        return $this->belongsTo(ServiceUser::class,'user_id','user_id');
    }

    public function commissions()
    {
        return $this->belongsToMany(PartnerCommission::class,'commission_withdrawals','partner_withdrawals_id','partner_commission_id');
    }
}
