40 lines
936 B
PHP
40 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StoreSale extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'store_id', 'household_id', 'quantity',
|
|
'retail_price_centavos', 'commission_centavos',
|
|
'payment_id', 'sold_at', 'is_prepaid',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'sold_at' => 'datetime',
|
|
'quantity' => 'integer',
|
|
'retail_price_centavos' => 'integer',
|
|
'commission_centavos' => 'integer',
|
|
'is_prepaid' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PartnerStore::class, 'store_id');
|
|
}
|
|
|
|
public function household(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Household::class);
|
|
}
|
|
}
|