storageAddress(); } public function shelf() { return $this->belongsTo(StockShelf::class, 'shelf_id'); } public function sections() { return $this->hasMany(StockSection::class, 'position_id', 'position_id'); } public function storageAddress(): string { // eager-load the whole hierarchy if not already $this->loadMissing('shelf.rack.line.room'); $shelf = $this->shelf; $rack = $shelf->rack; $line = $rack->line; $room = $line->room; return sprintf( '%s-%s-%s-%s-%s', $room->room_symbol, $line->line_symbol, $rack->rack_symbol, $shelf->shelf_symbol, $this->position_symbol ); } }