Прайсы и подбор — в Telegram (B2B-поставки для юрлиц/ИП)
public function getImage(): string
{
// 1. локальный файл
$localPath = public_path("images/products/{$this->id}.jpg");
if (file_exists($localPath)) {
return "/images/products/{$this->id}.jpg";
}
// 2. если есть старые images()
if ($this->images()->exists()) {
return $this->images()->first()->url;
}
// 3. автозагрузка
try {
$parser = new \App\Services\ProductImageParser();
$image = $parser->getImage($this->name, $this->id);
if ($image) {
return $image;
}
} catch (\Throwable $e) {
// не ломаем страницу
}
// 4. fallback
return "/images/no-image.jpg";
}public function getImage(): string
{
// 1. локальный файл
$localPath = public_path("images/products/{$this->id}.jpg");
if (file_exists($localPath)) {
return "/images/products/{$this->id}.jpg";
}
// 2. если есть старые images()
if ($this->images()->exists()) {
return $this->images()->first()->url;
}
// 3. автозагрузка
try {
$parser = new \App\Services\ProductImageParser();
$image = $parser->getImage($this->name, $this->id);
if ($image) {
return $image;
}
} catch (\Throwable $e) {
// не ломаем страницу
}
// 4. fallback
return "/images/no-image.jpg";
}public function getImage(): string
{
// 1. локальный файл
$localPath = public_path("images/products/{$this->id}.jpg");
if (file_exists($localPath)) {
return "/images/products/{$this->id}.jpg";
}
// 2. если есть старые images()
if ($this->images()->exists()) {
return $this->images()->first()->url;
}
// 3. автозагрузка
try {
$parser = new \App\Services\ProductImageParser();
$image = $parser->getImage($this->name, $this->id);
if ($image) {
return $image;
}
} catch (\Throwable $e) {
// не ломаем страницу
}
// 4. fallback
return "/images/no-image.jpg";
}public function getImage(): string
{
// 1. локальный файл
$localPath = public_path("images/products/{$this->id}.jpg");
if (file_exists($localPath)) {
return "/images/products/{$this->id}.jpg";
}
// 2. если есть старые images()
if ($this->images()->exists()) {
return $this->images()->first()->url;
}
// 3. автозагрузка
try {
$parser = new \App\Services\ProductImageParser();
$image = $parser->getImage($this->name, $this->id);
if ($image) {
return $image;
}
} catch (\Throwable $e) {
// не ломаем страницу
}
// 4. fallback
return "/images/no-image.jpg";
}
Class "App\Models\Product" does not exist