Xboard/app/Models/Coupon.php

27 lines
626 B
PHP
Raw Normal View History

2023-11-17 01:44:01 -05:00
<?php
namespace App\Models;
2025-01-23 01:48:12 -05:00
use App\Services\PlanService;
2023-11-17 01:44:01 -05:00
use Illuminate\Database\Eloquent\Model;
class Coupon extends Model
{
protected $table = 'v2_coupon';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'limit_plan_ids' => 'array',
'limit_period' => 'array'
];
2025-01-23 01:48:12 -05:00
public function getLimitPeriodAttribute($value)
{
return collect(json_decode($value, true))->map(function ($item) {
return PlanService::getPeriodKey($item);
})->toArray();
}
2023-11-17 01:44:01 -05:00
}