-membuat tabel pivot -menyesuaikan seeder -menyesuaikan logika yang berkaitan dengan perubahan tersebut
36 lines
838 B
PHP
36 lines
838 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\IsActive;
|
|
use App\Enums\VoucherType;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Voucher extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => VoucherType::class,
|
|
'discount_amount' => 'int',
|
|
'min_purchase' => 'int',
|
|
'max_discount' => 'int',
|
|
'quota' => 'int',
|
|
'limit_per_user' => 'int',
|
|
'is_active' => IsActive::class,
|
|
];
|
|
}
|
|
|
|
public function outlets(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Outlet::class);
|
|
}
|
|
}
|