fix inventory
This commit is contained in:
@@ -23,6 +23,13 @@ class InventoryMovement extends BaseModel
|
||||
'teacher_id',
|
||||
'student_id',
|
||||
'class_section_id',
|
||||
// Audit/correction fields
|
||||
'voided_at',
|
||||
'voided_by',
|
||||
'void_reason',
|
||||
'corrects_movement_id',
|
||||
'source_type',
|
||||
'source_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -32,8 +39,23 @@ class InventoryMovement extends BaseModel
|
||||
'teacher_id' => 'integer',
|
||||
'student_id' => 'integer',
|
||||
'class_section_id'=> 'integer',
|
||||
'voided_by' => 'integer',
|
||||
'corrects_movement_id' => 'integer',
|
||||
'source_id' => 'integer',
|
||||
'voided_at' => 'datetime',
|
||||
];
|
||||
|
||||
/* Scopes */
|
||||
public function scopeNotVoided($query)
|
||||
{
|
||||
return $query->whereNull('voided_at');
|
||||
}
|
||||
|
||||
public function scopeVoided($query)
|
||||
{
|
||||
return $query->whereNotNull('voided_at');
|
||||
}
|
||||
|
||||
/* Optional relationships */
|
||||
public function item()
|
||||
{
|
||||
@@ -59,4 +81,19 @@ class InventoryMovement extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(ClassSection::class, 'class_section_id');
|
||||
}
|
||||
|
||||
public function voidedBy()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'voided_by');
|
||||
}
|
||||
|
||||
public function correctsMovement()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'corrects_movement_id');
|
||||
}
|
||||
|
||||
public function corrections()
|
||||
{
|
||||
return $this->hasMany(self::class, 'corrects_movement_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user