38 lines
873 B
PHP
38 lines
873 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StorePurchase extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'store_id', 'batch_id', 'quantity',
|
|
'wholesale_price_centavos', 'paid_at', 'payment_id', 'is_prepaid',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'paid_at' => 'datetime',
|
|
'quantity' => 'integer',
|
|
'wholesale_price_centavos' => 'integer',
|
|
'is_prepaid' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PartnerStore::class, 'store_id');
|
|
}
|
|
|
|
public function batch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(QrCodeBatch::class, 'batch_id');
|
|
}
|
|
}
|