hasMany(LogActivity::class, 'file_directory_id', 'file_directory_id') ->where('statusenabled', true) ->where('action_type', 'Membuka Dokumen'); } public function downloadLogs() { return $this->hasMany(LogActivity::class, 'file_directory_id', 'file_directory_id') ->where('statusenabled', true) ->where('action_type', 'Download Dokumen'); } public function kategori(){ return $this->belongsTo(MasterKategori::class, 'master_kategori_directory_id', 'master_kategori_directory_id'); } public function unit(){ // Each file belongs to exactly one unit; skip the subUnitKerja eager load from UnitKerja. return $this->belongsTo(UnitKerja::class, 'id_unit_kerja', 'id')->select('id', 'name') ->without('subUnitKerja'); } }