Added prune logic for transaction models
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
This commit is contained in:
@@ -4,30 +4,33 @@ namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Prunable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductionQuantity extends Model
|
||||
{
|
||||
use Prunable;
|
||||
use SoftDeletes;
|
||||
|
||||
public static $importing = false; // Add this flag
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"shift_id",
|
||||
"line_id",
|
||||
"item_id",
|
||||
"serial_number",
|
||||
"production_order",
|
||||
"operator_id",
|
||||
'plant_id',
|
||||
'shift_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'serial_number',
|
||||
'production_order',
|
||||
'operator_id',
|
||||
// "success_status",
|
||||
// "notok_at",
|
||||
// "no_of_employee",
|
||||
// "list_of_employee",
|
||||
"created_at",
|
||||
"updated_at"
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -66,8 +69,7 @@ class ProductionQuantity extends Model
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$productionPlan)
|
||||
{
|
||||
if (! $productionPlan) {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id)
|
||||
->where('shift_id', $productionQuantity->shift_id)
|
||||
->where('line_id', $productionQuantity->line_id)
|
||||
@@ -88,4 +90,9 @@ class ProductionQuantity extends Model
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function prunable(): Builder
|
||||
{
|
||||
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user