Files
boursecu_server/app/Models/GiftCard.php
T

60 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2026-09-21 11:09:40 +03:30
use App\Models\Customer;
use App\Models\GiftCardCodes;
class GiftCard extends Model
{
use HasFactory,Selector;
protected $table = 'giftcards';
protected $fillable = [
'customer_id',
2026-06-11 22:08:47 +03:30
'use_once',
2026-09-21 11:09:40 +03:30
'show_in_app',
'count',
'amount',
'total',
'unit',
'unique_code',
'created_at',
'sts',
'expiry_date',
'used_count',
'description',
'name',
'mobile',
];
public function giftcardcodes(){
return $this->hasMany(GiftCardCodes::class, 'giftcard_id', 'id');
}
2026-09-21 11:09:40 +03:30
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id')->select('id', 'name', 'mobile');
}
static $STS = [
1 => "فعال",
2 => "تمام شده",
3 => "منقضی شده"
];
static $UNIT = [
1=>'IRR',
2=>'Golden'
];
public function getStsStrAttribute()
{
return self::$STS[$this->sts] ?? null;
}
}