refactor: update relationships in models to include withTrashed() for soft deletes, ensuring proper handling of related records
This commit is contained in:
parent
709eb76873
commit
fe5dfd382f
@ -130,7 +130,7 @@ public function registerMediaCollections(): void
|
|||||||
// 5. Relation
|
// 5. Relation
|
||||||
public function employee(): BelongsTo
|
public function employee(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Employee::class);
|
return $this->belongsTo(Employee::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payrollAdjustments(): HasMany
|
public function payrollAdjustments(): HasMany
|
||||||
|
|||||||
@ -191,7 +191,7 @@ public function cashAccount(): BelongsTo
|
|||||||
|
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function order(): HasOne
|
public function order(): HasOne
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public function ensureEditable(): void
|
|||||||
// 6. Relation
|
// 6. Relation
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function materials(): HasMany
|
public function materials(): HasMany
|
||||||
@ -130,6 +130,6 @@ public function results(): HasMany
|
|||||||
|
|
||||||
public function submittedBy(): BelongsTo
|
public function submittedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'submitted_by_id');
|
return $this->belongsTo(User::class, 'submitted_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,21 +81,21 @@ private function formatQuantityInput(float|string|null $value): string
|
|||||||
// 5. Relation
|
// 5. Relation
|
||||||
public function cutting(): BelongsTo
|
public function cutting(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Cutting::class);
|
return $this->belongsTo(Cutting::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rawMaterialPrice(): BelongsTo
|
public function rawMaterialPrice(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(RawMaterialPrice::class);
|
return $this->belongsTo(RawMaterialPrice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function combination(): BelongsTo
|
public function combination(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CuttingMaterialCombination::class, 'combination_id');
|
return $this->belongsTo(CuttingMaterialCombination::class, 'combination_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,12 +24,12 @@ protected function casts(): array
|
|||||||
|
|
||||||
public function cutting(): BelongsTo
|
public function cutting(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Cutting::class);
|
return $this->belongsTo(Cutting::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function materials(): HasMany
|
public function materials(): HasMany
|
||||||
|
|||||||
@ -28,16 +28,16 @@ protected function casts(): array
|
|||||||
// 3. Relation
|
// 3. Relation
|
||||||
public function cutting(): BelongsTo
|
public function cutting(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Cutting::class);
|
return $this->belongsTo(Cutting::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function productVariant(): BelongsTo
|
public function productVariant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class);
|
return $this->belongsTo(ProductVariant::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,11 +53,11 @@ public function typeLabel(): Attribute
|
|||||||
// 4. Relation
|
// 4. Relation
|
||||||
public function cutting(): BelongsTo
|
public function cutting(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Cutting::class);
|
return $this->belongsTo(Cutting::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function productVariant(): BelongsTo
|
public function productVariant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class);
|
return $this->belongsTo(ProductVariant::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,6 @@ public function payrolls(): HasMany
|
|||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -201,7 +201,7 @@ public function cashTransaction(): BelongsTo
|
|||||||
|
|
||||||
public function employee(): BelongsTo
|
public function employee(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Employee::class);
|
return $this->belongsTo(Employee::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function paidBy(): BelongsTo
|
public function paidBy(): BelongsTo
|
||||||
|
|||||||
@ -56,6 +56,6 @@ public function employeeAdvance(): BelongsTo
|
|||||||
|
|
||||||
public function paidBy(): BelongsTo
|
public function paidBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'paid_by_id');
|
return $this->belongsTo(User::class, 'paid_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,11 +64,11 @@ public function registerMediaCollections(): void
|
|||||||
// 5. Relation
|
// 5. Relation
|
||||||
public function cashTransaction(): BelongsTo
|
public function cashTransaction(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CashTransaction::class);
|
return $this->belongsTo(CashTransaction::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,7 +158,7 @@ public static function canSubmit(User $user): bool
|
|||||||
// 6. Relation
|
// 6. Relation
|
||||||
public function employee(): BelongsTo
|
public function employee(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Employee::class);
|
return $this->belongsTo(Employee::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifiedBy(): BelongsTo
|
public function verifiedBy(): BelongsTo
|
||||||
|
|||||||
@ -45,6 +45,6 @@ public function markAsRead(): void
|
|||||||
// 4. Relation
|
// 4. Relation
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -289,17 +289,17 @@ public function registerMediaCollections(): void
|
|||||||
// 6. Relation
|
// 6. Relation
|
||||||
public function cashTransaction(): BelongsTo
|
public function cashTransaction(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CashTransaction::class);
|
return $this->belongsTo(CashTransaction::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customer(): BelongsTo
|
public function customer(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Customer::class);
|
return $this->belongsTo(Customer::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function items(): HasMany
|
public function items(): HasMany
|
||||||
@ -309,6 +309,6 @@ public function items(): HasMany
|
|||||||
|
|
||||||
public function marketing(): BelongsTo
|
public function marketing(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'marketing_id');
|
return $this->belongsTo(User::class, 'marketing_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,16 +67,16 @@ public function unitPriceFormatted(): Attribute
|
|||||||
// 4. Relation
|
// 4. Relation
|
||||||
public function order(): BelongsTo
|
public function order(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Order::class);
|
return $this->belongsTo(Order::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function productVariant(): BelongsTo
|
public function productVariant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class);
|
return $this->belongsTo(ProductVariant::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,11 +184,11 @@ public function subject(): MorphTo
|
|||||||
|
|
||||||
public function submittedBy(): BelongsTo
|
public function submittedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'submitted_by_id');
|
return $this->belongsTo(User::class, 'submitted_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifiedBy(): BelongsTo
|
public function verifiedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'verified_by_id');
|
return $this->belongsTo(User::class, 'verified_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,7 +163,7 @@ public function cashTransaction(): BelongsTo
|
|||||||
|
|
||||||
public function employee(): BelongsTo
|
public function employee(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Employee::class);
|
return $this->belongsTo(Employee::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function paidBy(): BelongsTo
|
public function paidBy(): BelongsTo
|
||||||
|
|||||||
@ -83,7 +83,7 @@ public function attendance(): BelongsTo
|
|||||||
|
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payroll(): BelongsTo
|
public function payroll(): BelongsTo
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public function isOpen(): bool
|
|||||||
// 6. Relation
|
// 6. Relation
|
||||||
public function closedBy(): BelongsTo
|
public function closedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'closed_by_id');
|
return $this->belongsTo(User::class, 'closed_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payrolls(): HasMany
|
public function payrolls(): HasMany
|
||||||
|
|||||||
@ -44,6 +44,6 @@ public function priceInput(): Attribute
|
|||||||
// 4. Relation
|
// 4. Relation
|
||||||
public function variant(): BelongsTo
|
public function variant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class, 'variant_id');
|
return $this->belongsTo(ProductVariant::class, 'variant_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,6 +94,6 @@ public function prices(): HasMany
|
|||||||
|
|
||||||
public function product(): BelongsTo
|
public function product(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Product::class);
|
return $this->belongsTo(Product::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,6 +114,6 @@ public function pendingOwnerVerificationRequest(): MorphOne
|
|||||||
|
|
||||||
public function supplier(): BelongsTo
|
public function supplier(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Supplier::class);
|
return $this->belongsTo(Supplier::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,16 +80,16 @@ public function unitPriceFormatted(): Attribute
|
|||||||
// 4. Relation
|
// 4. Relation
|
||||||
public function purchase(): BelongsTo
|
public function purchase(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Purchase::class);
|
return $this->belongsTo(Purchase::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rawMaterialPrice(): BelongsTo
|
public function rawMaterialPrice(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(RawMaterialPrice::class);
|
return $this->belongsTo(RawMaterialPrice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,6 @@ public function purchaseItems(): HasMany
|
|||||||
|
|
||||||
public function rawMaterial(): BelongsTo
|
public function rawMaterial(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(RawMaterial::class);
|
return $this->belongsTo(RawMaterial::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,6 @@ public function rejectable(): MorphTo
|
|||||||
|
|
||||||
public function rejectedBy(): BelongsTo
|
public function rejectedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'rejected_by_id');
|
return $this->belongsTo(User::class, 'rejected_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,11 +29,11 @@ protected function casts(): array
|
|||||||
// 2. Relation
|
// 2. Relation
|
||||||
public function productVariant(): BelongsTo
|
public function productVariant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class);
|
return $this->belongsTo(ProductVariant::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,7 @@ public function statusLabel(): Attribute
|
|||||||
// 5. Relation
|
// 5. Relation
|
||||||
public function createdBy(): BelongsTo
|
public function createdBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'created_by_id');
|
return $this->belongsTo(User::class, 'created_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function items(): HasMany
|
public function items(): HasMany
|
||||||
@ -99,6 +99,6 @@ public function items(): HasMany
|
|||||||
|
|
||||||
public function verifiedBy(): BelongsTo
|
public function verifiedBy(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class, 'verified_by_id');
|
return $this->belongsTo(User::class, 'verified_by_id')->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,11 +43,11 @@ public function getVariantNameAttribute(): string
|
|||||||
// 3. Relation
|
// 3. Relation
|
||||||
public function productVariant(): BelongsTo
|
public function productVariant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(ProductVariant::class);
|
return $this->belongsTo(ProductVariant::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stokOpname(): BelongsTo
|
public function stokOpname(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(StokOpname::class);
|
return $this->belongsTo(StokOpname::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,6 @@ public function registerMediaCollections(): void
|
|||||||
// 5. Relation
|
// 5. Relation
|
||||||
public function user(): BelongsTo
|
public function user(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user