Initial commit for new repo
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m4s

This commit is contained in:
dhanabalan
2025-12-16 17:05:04 +05:30
commit 3f0d529640
862 changed files with 141157 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Prunable;
use Illuminate\Database\Eloquent\Builder;
class GuardPatrolEntry extends Model
{
use SoftDeletes;
use Prunable;
protected $fillable = [
'plant_id',
'guard_name_id',
'check_point_name_id',
'reader_code',
'patrol_time',
'created_by',
'updated_by',
];
public function plant(): BelongsTo
{
return $this->belongsTo(Plant::class);
}
public function guardNames(): BelongsTo
{
//return $this->belongsTo(CheckPointName::class);
return $this->belongsTo(GuardName::class, 'guard_name_id');
}
public function checkPointNames(): BelongsTo
{
//return $this->belongsTo(CheckPointName::class);
return $this->belongsTo(CheckPointName::class, 'check_point_name_id');
}
public function prunable(): Builder
{
// $start = now()->subMonth()->startOfMonth();
// $end = now()->subMonth()->endOfMonth();
// return static::whereBetween('created_at', [$start, $end]);
// Start of two months ago (first day of that month)
$startOfTwoMonthsAgo = now()->subMonthsNoOverflow(2)->startOfMonth();
// End of previous month (last day of last month)
$endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
}
}