mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 10:30:51 +08:00
- Fix known bugs in user, plan, and server modules - Standardize code formatting and structure - Optimize database queries and model relationships - Improve request validation and error handling - Update admin controllers for better consistency
29 lines
666 B
PHP
29 lines
666 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\PlanService;
|
|
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',
|
|
'show' => 'boolean',
|
|
];
|
|
|
|
public function getLimitPeriodAttribute($value)
|
|
{
|
|
return collect(json_decode((string) $value, true))->map(function ($item) {
|
|
return PlanService::getPeriodKey($item);
|
|
})->toArray();
|
|
}
|
|
|
|
}
|