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)
|
|
|
|
{
|
2025-01-25 11:44:58 -05:00
|
|
|
return collect(json_decode((string) $value, true))->map(function ($item) {
|
2025-01-23 01:48:12 -05:00
|
|
|
return PlanService::getPeriodKey($item);
|
|
|
|
})->toArray();
|
|
|
|
}
|
2025-01-23 13:26:22 -05:00
|
|
|
|
2023-11-17 01:44:01 -05:00
|
|
|
}
|