mivita/dev/bak/routes/utility.php
2025-08-12 18:01:59 +02:00

74 lines
2.6 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| Utility Routes
|--------------------------------------------------------------------------
|
| Storage, images and general utility routes that are accessible from all domains
|
*/
Route::get('storage/images/{from}/{slug}', function ($from = null, $slug = null) {
if ($from == 'shop') {
if ($image = \App\Models\UserShop::where('filename', $slug)->first()) {
$path = storage_path('app/public') . '/images/shop' . '/' . $image->filename;
if (file_exists($path)) {
return Response::file($path);
}
}
}
})->name('storage_images');
Route::get('/product/image/{slug}', function ($slug = null) {
if ($image = \App\Models\ProductImage::where('slug', $slug)->first()) {
$path = storage_path('app/public') . '/images/product' . '/' . $image->product_id . '/' . $image->filename;
if (file_exists($path)) {
return Response::file($path);
}
}
})->name('product_image');
Route::get('/iq/image/{slug}', function ($slug = null) {
if ($image = \App\Models\IqImage::where('slug', $slug)->first()) {
$path = storage_path('app/public') . '/images/iq_images/' . $image->filename;
if (file_exists($path)) {
return Response::file($path);
}
}
})->name('iq_image');
Route::get('/user_shop/image/{slug}', function ($slug = null) {
if ($image = \App\Models\UserShopOnSite::where('slug', $slug)->first()) {
$path = storage_path('app/public') . '/images/user_shop' . '/' . $image->user_shop_id . '/' . $image->filename;
if (file_exists($path)) {
return Response::file($path);
}
}
})->name('user_shop_image');
Route::get('/shop/product/image/{slug}', function ($slug = null) {
if ($image = \App\Models\ProductImage::where('slug', $slug)->first()) {
$path = storage_path('app/public') . '/images/product' . '/' . $image->product_id . '/' . $image->filename;
if (file_exists($path)) {
return Response::file($path);
}
}
})->name('shop_product_image');
Route::get('translation/{locale}', function ($locale) {
\Session::put('locale', $locale);
\App::setLocale($locale);
if (Auth::guard('user')->check()) {
$user = Auth::guard('user')->user();
$user->lang = $locale;
$user->save();
}
if (Auth::guard('customers')->check()) {
$user = Auth::guard('customers')->user();
$user->language = $locale;
$user->save();
}
return redirect()->back();
})->name('translation');