TextInput::make('url')->lazy()
->afterStateUpdated(function (Closure $set, $state) {
$domain = UrlHelper::getDomain($state);
$faviconName = str($domain)->replace('.', '-');
$faviconPath = public_path('images/favicons/' . $faviconName . '.png');
try {
$ic = Image::make('https://api.faviconkit.com/' . $domain . '/16')
->encode('png')
->resize(16, 16)
->save($faviconPath);
$ic->destroy();
} catch (Exception) {
copy(public_path('images/default-favicon.png'), $faviconPath);
}
// How to do this?
$set('favicon', [$faviconPath]);
}),
FileUpload::make('favicon')->image(),
TextInput::make('url')->lazy()
->afterStateUpdated(function (Closure $set, $state) {
$domain = UrlHelper::getDomain($state);
$faviconName = str($domain)->replace('.', '-');
$faviconPath = public_path('images/favicons/' . $faviconName . '.png');
try {
$ic = Image::make('https://api.faviconkit.com/' . $domain . '/16')
->encode('png')
->resize(16, 16)
->save($faviconPath);
$ic->destroy();
} catch (Exception) {
copy(public_path('images/default-favicon.png'), $faviconPath);
}
// How to do this?
$set('favicon', [$faviconPath]);
}),
FileUpload::make('favicon')->image(),