66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Tenancy\HasTenant;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class QrCodeBatch extends Model
|
|
{
|
|
use HasFactory, HasTenant, SoftDeletes;
|
|
|
|
public const PURPOSE_FREE = 'free_allocation';
|
|
|
|
public const PURPOSE_STORE = 'store_inventory';
|
|
|
|
public const PURPOSE_PROMO = 'promotional';
|
|
|
|
protected $table = 'qr_code_batches';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'batch_number',
|
|
'quantity',
|
|
'purpose',
|
|
'target_area_id',
|
|
'target_store_id',
|
|
'created_by_admin_id',
|
|
'printed_at',
|
|
'expires_at',
|
|
'notes',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'printed_at' => 'datetime',
|
|
'expires_at' => 'datetime',
|
|
'quantity' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'batch_number';
|
|
}
|
|
|
|
public function targetArea(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ServiceArea::class, 'target_area_id');
|
|
}
|
|
|
|
public function createdBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by_admin_id');
|
|
}
|
|
|
|
public function codes(): HasMany
|
|
{
|
|
return $this->hasMany(QrCode::class, 'batch_id');
|
|
}
|
|
}
|