hasMany(BorrowTransaction::class, 'book_id'); } public function availableCopies() { $borrowed = $this->borrowTransactions() ->where('status', 'dipinjam') ->count(); return $this->jumlah_eksemplar - $borrowed; } public function getFormattedTitleAttribute() { return ucwords(strtolower($this->judul)); } }