<?php

namespace Tricks\LaravelSitemapForDynamicPages\Traits;

use Illuminate\Support\Str;

trait HasFrontendUrls
{
    protected function getFrontendUrls($paths): array
    {
        return collect($paths)
            ->map(function ($value, $language) {
                return Str::of($value)
                    ->prepend(config('sitemap-for-dynamic-pages.frontend.paths')[self::class][$language])
                    ->prepend(rtrim(config('sitemap-for-dynamic-pages.frontend.baseUrl'), '/'))
                    ->finish('/')
                    ->__toString();
            })->flatten()->toArray();
    }
}
