28 lines
627 B
PHP
28 lines
627 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UniformIssue extends Model
|
|
{
|
|
protected $fillable = ['employee_id', 'stock_variant_id', 'quantity', 'returned_quantity', 'issued_at', 'status', 'notes'];
|
|
|
|
protected $casts = ['issued_at' => 'date'];
|
|
|
|
public function employee()
|
|
{
|
|
return $this->belongsTo(Employee::class);
|
|
}
|
|
|
|
public function variant()
|
|
{
|
|
return $this->belongsTo(StockVariant::class, 'stock_variant_id');
|
|
}
|
|
|
|
public function getOutstandingQuantityAttribute(): int
|
|
{
|
|
return $this->quantity - $this->returned_quantity;
|
|
}
|
|
}
|