0, 'ledger_status' => LedgerStatus::Pending, ]; protected $casts = [ 'ledger_status' => LedgerStatus::class, ]; protected $fillable = [ 'store_id', 'date', 'new_customers', 'sales', 'expenditure', 'handover_amount', 'ledger_amount', 'expected_commission', 'actual_commission', 'expected_income', 'actual_income', 'photos', 'ledger_status', ]; public function store(): BelongsTo { return $this->belongsTo(Store::class); } public function items(): HasMany { return $this->hasMany(LedgerItem::class); } protected function ledgerDifference(): Attribute { return Attribute::make( get: function (mixed $value, array $attributes) { if (is_numeric($attributes['ledger_amount'])) { return bcsub($attributes['handover_amount'], $attributes['ledger_amount'], 2); } return null; }, ); } protected function photos(): Attribute { return Attribute::make( get: function (mixed $value) { if (! is_array($photos = json_decode($value ?? '', true))) { $photos = []; } return $photos; }, set: fn (mixed $value) => json_encode(is_array($value) ? $value : []), ); } }