Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get svg data to use with seeder or migragtion? #16

Open
scramatte opened this issue Dec 5, 2022 · 1 comment
Open

Get svg data to use with seeder or migragtion? #16

scramatte opened this issue Dec 5, 2022 · 1 comment

Comments

@scramatte
Copy link

Hi,

I'm using your package and I've created a seeder to fill tables.
Does it exists a method to get icon svg to be able to use it into migration or seeder?

Regards

@AlexAzartsev
Copy link
Owner

Unfortunately no, but you can write helper function in your seeder to get content of desired icon using file_get_contents, for example:

    public static function icon(string $type = 'outline', string $icon = ''): string
    {
        if ($type !== 'outline' && $type !== 'solid') {
            throw new InvalidArgumentException("Only solid or outline type accepted");
        }
        if (!empty($icon) && file_exists(resource_path("img/icons/heroicons/$type/$icon.svg"))) {
            return file_get_contents(resource_path("img/icons/heroicons/$type/$icon.svg"));
        }
        $files = glob(resource_path("img/icons/heroicons/$type") . '/*.svg');
        $file = array_rand($files);

        return file_get_contents($files[$file]);
    }

you need to use proper path for you icon set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants