TKK_E32230220/app/Models/SortingSession.php

52 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use MongoDB\Laravel\Eloquent\Model;
class SortingSession extends Model
{
protected $connection = 'mongodb';
protected $collection = 'sorting_sessions';
protected $fillable = [
'status', // 'active' or 'completed'
'started_at',
'ended_at',
'total_raw_banana_weight',
'total_ripe_banana_weight',
'total_raw_orange_weight',
'total_ripe_orange_weight',
'total_records',
];
protected $casts = [
'started_at' => 'datetime',
'ended_at' => 'datetime',
];
/**
* Get the sorting history records for this session
*/
public function histories()
{
return $this->hasMany(SortingHistory::class, 'session_id');
}
/**
* Get the fruit images captured during this session
*/
public function images()
{
return $this->hasMany(FruitImage::class, 'session_id');
}
/**
* Scope for active sessions
*/
public function scopeActive($query)
{
return $query->where('status', 'active');
}
}