update
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BioSpecimen extends Model
|
||||
{
|
||||
protected $table = 'bio_specimens';
|
||||
protected $guarded = [];
|
||||
|
||||
protected $appends = ['storage_days'];
|
||||
|
||||
public function cabinet()
|
||||
{
|
||||
return $this->belongsTo(BioCabinet::class, 'cabinet_id');
|
||||
}
|
||||
|
||||
public function rack()
|
||||
{
|
||||
return $this->belongsTo(BioRack::class, 'rack_id');
|
||||
}
|
||||
|
||||
public function getStorageDaysAttribute()
|
||||
{
|
||||
if (!$this->stored_at) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Carbon::parse($this->stored_at)->diffInDays(Carbon::now());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user