diff --git a/app/Http/Controllers/Dashboard/Category/Controller.php b/app/Http/Controllers/Dashboard/Category/Controller.php index c017a70..764fbdf 100755 --- a/app/Http/Controllers/Dashboard/Category/Controller.php +++ b/app/Http/Controllers/Dashboard/Category/Controller.php @@ -24,11 +24,11 @@ class Controller extends ExController public function index() { $this->authorize('view', 'categories'); - $categories = Category::select('id', 'name->ru as category', 'position', 'parent_id') + $categories = Category::select('id', 'name->ru as category', 'position', 'parent_id', 'image') ->where('parent_id', null) ->with(['children' => function ($parent) { - return $parent->select('id', 'name->ru as category', 'parent_id', 'position')->orderBy('position', 'asc')->with(['children' => function ($parent) { - return $parent->select('id', 'name->ru as category', 'parent_id', 'position')->orderBy('position', 'asc'); + return $parent->select('id', 'name->ru as category', 'parent_id', 'position', 'image')->orderBy('position', 'asc')->with(['children' => function ($parent) { + return $parent->select('id', 'name->ru as category', 'parent_id', 'position', 'image')->orderBy('position', 'asc'); }]); }])->orderBy('position', 'asc')->get(); @@ -102,11 +102,7 @@ class Controller extends ExController return view('dashboard.category.update', compact('parent_categories', 'category', 'brands')); } - if ($request->hasFile('image')) { - $image = $request->file('image')->store('uploads/categories', 'local'); - } else { - $image = $category->image; - } + $image = $request->getImage($category); $this->dispatchSync(new UpdateJob($category, $request, $image)); diff --git a/app/Models/Category.php b/app/Models/Category.php index 3a0f9ac..992ad11 100755 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -53,6 +53,8 @@ class Category extends Model 'title_seo' => 'array', 'is_filter_power' => 'boolean' ]; + + protected $appends = ['image_url']; protected $hidden = [ 'created_at', @@ -137,6 +139,11 @@ class Category extends Model return ''; } + public function getImageUrlAttribute(): string + { + return $this->getImage(); + } + public function getImage(): string { if (!in_array($this->image, ['null', null])) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5135035..8f02e94 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -26,7 +26,7 @@ class AppServiceProvider extends ServiceProvider date_default_timezone_set('Asia/Tashkent'); // set lang to uz if (App::environment(['staging', 'production'])) { - URL::forceScheme('https'); + URL::forceScheme('http'); } } } diff --git a/deployment_guide.md b/deployment_guide.md new file mode 100644 index 0000000..d5acb20 --- /dev/null +++ b/deployment_guide.md @@ -0,0 +1,82 @@ +# Production Deployment Guide + +Ushbu yo'riqnoma local o'zgarishlarni (MinIO va API ulanishlari) serverga (Production) ko'chirish uchun kerakli qadamlarni o'z ichiga oladi. + +## 1. Backend (Laravel) - `api.quyoshli.uz` + +Serverga kirib, loyiha papkasida quyidagi ishlarni bajaring: + +### `.env` faylini yangilash +Production serverda local MinIO emas, balki **haqiqiy masofaviy MinIO** ma'lumotlari bo'lishi kerak: +```env +FILESYSTEM_DISK=s3 +AWS_USE_PATH_STYLE_ENDPOINT=false + +MINIO_ACCESS_KEY=1121RspAhfuxdjqCrkXH +MINIO_SECRET_KEY=97rvdUg266dIAseFKeJ3l2cHRavRmCrhEDQTvaDH +MINIO_BUCKET=quyoshli +MINIO_ENDPOINT=https://minio.quyoshli.uz +``` +> [!IMPORTANT] +> Masofaviy MinIO-da `AWS_USE_PATH_STYLE_ENDPOINT=false` bo'lishi mumkin (sozlamaga qarab), lekin odatda HTTPS endpointlar uchun `false` ishlatiladi. + +### Buyruqlar ketma-ketligi +```bash +# Kodni yangilash +git pull origin main + +# Bog'liqliklarni o'rnatish +composer install --no-dev --optimize-autoloader + +# Ma'lumotlar bazasini yangilash +php artisan migrate --force + +# Keshni tozalash va optimizatsiya +php artisan optimize +php artisan config:cache +php artisan view:cache + +# Frontend assetlarni yig'ish (agar Laravel Vite ishlatilsa) +npm install +npm run build +``` + +### Ruxsatnomalar (Permissions) +Serverda papkalarga to'g'ri ruxsat berish juda muhim: +```bash +sudo chown -R www-data:www-data storage bootstrap/cache public/uploads +sudo chmod -R 775 storage bootstrap/cache public/uploads +``` + +--- + +## 2. Frontend (Next.js) - `getgreen.uz` + +Frontend loyihasida `.env` faylini quyidagicha sozlashingiz kerak: + +### `.env` fayli +```env +API_URL=https://api.quyoshli.uz/api +PORT=3000 +``` + +### Qayta qurish (Rebuild) +Agar Docker ishlatayotgan bo'lsangiz: +```bash +docker-compose up -d --build +``` +Agar Docker-siz bo'lsa: +```bash +npm install +npm run build +pm2 restart all # yoki boshqa process manager +``` + +--- + +## 3. MinIO Sozlamalari (Masofaviy) +Masofaviy MinIO serveringizda `quyoshli` bucket-i yaratilganiga va ruxsatnomalari (Policy) to'g'ri sozlanganiga ishonch hosil qiling: +- Rasmlar hamma uchun ochiq bo'lishi uchun Bucket Policy-ni **Public** yoki **Read-only** qilib sozlash tavsiya etiladi. + +> [!TIP] +> Agar rasmlar production-da ko'rinmasa, `.env` faylidagi `AWS_USE_PATH_STYLE_ENDPOINT` qiymatini `true` yoki `false` qilib almashtirib ko'ring. diff --git a/public/uploads/calc/2026/04/15/YyqWQsuViSt04C9Wdty66GljQvCCWFkpLqLHMS8N.png b/public/uploads/calc/2026/04/15/YyqWQsuViSt04C9Wdty66GljQvCCWFkpLqLHMS8N.png old mode 100644 new mode 100755 diff --git a/public/uploads/categories/N7IZZAoxta5GWwUwvxPqQHEVOy6LKWlfOVsyDMt0.jpg b/public/uploads/categories/N7IZZAoxta5GWwUwvxPqQHEVOy6LKWlfOVsyDMt0.jpg new file mode 100644 index 0000000..ec3f860 Binary files /dev/null and b/public/uploads/categories/N7IZZAoxta5GWwUwvxPqQHEVOy6LKWlfOVsyDMt0.jpg differ diff --git a/public/uploads/posters/2026/04/15/TrLZTb7KVgadw1yLaKzInuv4BecNYTwwRilUkfwy.png b/public/uploads/posters/2026/04/15/TrLZTb7KVgadw1yLaKzInuv4BecNYTwwRilUkfwy.png old mode 100644 new mode 100755 diff --git a/public/uploads/posters/thumbs/2026/04/15/TrLZTb7KVgadw1yLaKzInuv4BecNYTwwRilUkfwy.png b/public/uploads/posters/thumbs/2026/04/15/TrLZTb7KVgadw1yLaKzInuv4BecNYTwwRilUkfwy.png old mode 100644 new mode 100755 diff --git a/public/uploads/screens/2026/04/15/hi4Ts1no1D6bCvqGT6sx46zpWVNaL9NnuTCHG3bS.png b/public/uploads/screens/2026/04/15/hi4Ts1no1D6bCvqGT6sx46zpWVNaL9NnuTCHG3bS.png old mode 100644 new mode 100755 diff --git a/public/uploads/screens/thumbs/2026/04/15/hi4Ts1no1D6bCvqGT6sx46zpWVNaL9NnuTCHG3bS.png b/public/uploads/screens/thumbs/2026/04/15/hi4Ts1no1D6bCvqGT6sx46zpWVNaL9NnuTCHG3bS.png old mode 100644 new mode 100755 diff --git a/resources/js/components/Dashboard/Category/Index.vue b/resources/js/components/Dashboard/Category/Index.vue index b267999..1febd73 100755 --- a/resources/js/components/Dashboard/Category/Index.vue +++ b/resources/js/components/Dashboard/Category/Index.vue @@ -71,9 +71,10 @@ >   - + ID: {{ data.id }} - {{ data.category }} + + {{ data.category }}
diff --git a/resources/js/components/Dashboard/Category/Update.vue b/resources/js/components/Dashboard/Category/Update.vue index 1ee3bf4..ddc4cc9 100755 --- a/resources/js/components/Dashboard/Category/Update.vue +++ b/resources/js/components/Dashboard/Category/Update.vue @@ -130,7 +130,7 @@ width: 300px; height: auto; " - :src="category.image" + :src="category.image_url" />