fix report ۴
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Rooyesh\Wallet\models;
|
||||
use App\Models\Selector;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class Transaction extends Model
|
||||
@@ -27,6 +28,23 @@ class Transaction extends Model
|
||||
9 => 'سود زیر مجموعه',
|
||||
10 => 'برداشت طلایی',
|
||||
];
|
||||
|
||||
/**
|
||||
* type_str گاهی از API enrich میشود (مثلاً «واریز کاتد مس»).
|
||||
* اگر مقدار از قبل متن باشد، accessor نباید آن را به «تعریف نشده» برگرداند.
|
||||
*/
|
||||
public function getTypeStrAttribute($value)
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_string($value) && !is_numeric(trim($value))) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return Arr::get(self::$TYPES, (int) $value, 'تعریف نشده');
|
||||
}
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Customer')->select(['id','name']);
|
||||
|
||||
Reference in New Issue
Block a user