diff --git a/README-fa.md b/README-fa.md
index 811178e..f15a46a 100644
--- a/README-fa.md
+++ b/README-fa.md
@@ -50,7 +50,7 @@ yarn dev
> اطلاعات ورود اولیه : `developer@example.com` (به عنوان توسعه دهنده) یا `admin@example.com` (به عنوان مدیر) و
> گذرواژه : `password`
-## افزودن تصاویر نممونه
+## افزودن تصاویر نمونه
- دانلود و آمادهسازی تصاویر
@@ -62,8 +62,9 @@ php artisan seeding:prepare
```
-- nor copy your image folder to `database/seeders/images/`
-- then: Seeding image for models: [Group, Category, Post, Product, Slider]
+
+- ویا تصاویر خود را با پوشه مورد نظر در این مسیر کپی کنید: `database/seeders/images/`
+- سپس یکی از مدل ها دلخواه را seed image کنید: [Group, Category, Post, Product, Slider]
@@ -114,6 +115,27 @@ composer install --optimize-autoloader --no-dev
```
+## اضافه کردن cron job
+
+جهت اجرا کامل برنامه ها زماندار فروشگاه باید یک دستور زیر رو بزنید:
+
+
+
+```bash
+crontab -e
+```
+
+
+و این خط رو اضافه کنید:
+
+
+
+```bash
+* * * * * cd /home/[yourusername]/[your-public-html-project-root] && php artisan schedule:run >> /dev/null 2>&1
+```
+
+
+
## ساختن xController
درواقع xController یک کنترولر بسیار پیشرفته با همراه لاگ و CRUD برای توسعه آسان است با فرض زیر:
@@ -150,6 +172,7 @@ php artisan make:part PartName segmentName
```bash
php artisan client
+php artisan build
```
diff --git a/README.md b/README.md
index 2ea8ece..86dfa5c 100644
--- a/README.md
+++ b/README.md
@@ -95,6 +95,20 @@ php artisan optimize
composer install --optimize-autoloader --no-dev
```
+## Add cron job
+
+You must add crontab for your project:
+
+```bash
+crontab -e
+```
+
+Add this line:
+```bash
+* * * * * cd /home/[yourusername]/[your-public-html-project-root] && php artisan schedule:run >> /dev/null 2>&1
+```
+
+
## make xController
Controller with log and semi-automatic CURD with logs
@@ -122,6 +136,7 @@ Optimize client assets, `scss`,`js`,`css`
```bash
php artisan client
+php artisan build
```
### theme parts file
diff --git a/app/Console/Commands/AssetsBuild.php b/app/Console/Commands/AssetsBuild.php
new file mode 100644
index 0000000..e3c83d5
--- /dev/null
+++ b/app/Console/Commands/AssetsBuild.php
@@ -0,0 +1,130 @@
+getLaravelRoot());
+
+ // Check if npm is installed
+ $npmVersion = new Process(['npm', '-v']);
+ $npmVersion->setWorkingDirectory($this->getLaravelRoot());
+ $npmVersion->run();
+
+ if (!$npmVersion->isSuccessful()) {
+ $this->addOutput('npm is not installed. Please install npm first.');
+ return Command::FAILURE;
+ }
+
+ // Check if package.json exists
+ if (!file_exists($this->getLaravelRoot() . '/package.json')) {
+ $this->addOutput('package.json not found in ' . $this->getLaravelRoot());
+ return Command::FAILURE;
+ }
+
+
+ // Check if node_modules exists
+ if (!file_exists($this->getLaravelRoot() . '/node_modules')) {
+ $this->addOutput('node_modules not found. Installing dependencies...');
+
+ $installProcess = new Process(['npm', 'install']);
+ $installProcess->setWorkingDirectory($this->getLaravelRoot());
+ $installProcess->setTimeout(3600); // 1 hour timeout
+
+ $installProcess->run(function ($type, $buffer) {
+ $this->addOutput($buffer);
+ });
+
+ if (!$installProcess->isSuccessful()) {
+ throw new ProcessFailedException($installProcess);
+ }
+ }
+
+ // Run npm build
+ $this->addOutput('Starting build process in: ' . $this->getLaravelRoot());
+
+ $buildProcess = new Process(['./node_modules/.bin/vite', 'build']);
+ $buildProcess->setWorkingDirectory($this->getLaravelRoot());
+// $this->addOutput($this->getLaravelRoot());
+
+ $buildProcess->setTimeout(3600); // 1 hour timeout
+
+ $buildProcess->run(function ($type, $buffer) {
+ $this->addOutput($buffer);
+ });
+
+ if (!$buildProcess->isSuccessful()) {
+ throw new ProcessFailedException($buildProcess);
+ }
+
+ $this->addOutput('Build completed successfully!');
+
+ // Store output in cache for retrieval
+ cache()->put('build_command_output', $this->commandOutput, now()->addMinutes(5));
+
+ return Command::SUCCESS;
+
+ } catch (\Exception $e) {
+ $errorMessage = 'Build process failed: ' . $e->getMessage();
+ $this->addOutput($errorMessage);
+ cache()->put('build_command_output', $this->commandOutput, now()->addMinutes(5));
+ return Command::FAILURE;
+ }
+ }
+
+ /**
+ * Add output to both console and stored output
+ */
+ private function addOutput($output)
+ {
+ $this->commandOutput .= $output . PHP_EOL;
+ $this->info($output); // This will only show in CLI
+ }
+
+ /**
+ * Get the command output
+ */
+ public function getOutput()
+ {
+ return $this->commandOutput;
+ }
+}
diff --git a/app/Http/Controllers/Admin/AreaController.php b/app/Http/Controllers/Admin/AreaController.php
index 602832b..f7ceb3a 100644
--- a/app/Http/Controllers/Admin/AreaController.php
+++ b/app/Http/Controllers/Admin/AreaController.php
@@ -222,4 +222,26 @@ class AreaController extends Controller
logAdmin(__METHOD__, __CLASS__, $p->area_id);
return ['OK' => true, 'message' => __("As you wished sort saved")];
}
+
+ public function build(){
+
+ $exitCode = \Artisan::call('build');
+
+ // Get the command output from cache
+ $output = cache()->get('build_command_output', 'No output available');
+
+// return response()->json([
+// 'success' => $exitCode === 0,
+// 'exit_code' => $exitCode,
+// 'output' => $output
+// ]);
+ logAdmin(__METHOD__, __CLASS__, null);
+ if ($exitCode == 0){
+ \Log::info($output);
+ return redirect()->back()->with(['message' => __('Assets build successfully')]);
+ }else{
+ \Log::error($output);
+ return redirect()->back()->with(['message' => __('Assets build failed')]);
+ }
+ }
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 3362219..f5c6967 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -1,11 +1,11 @@
commands([
TranslatorCommand::class,
+ AssetsBuild::class,
]);
foreach (config('xshop.payment.gateways') as $gateway){
/** @var \App\Contracts\Payment $gateway */
diff --git a/resources/js/panel/responsive-control.js b/resources/js/panel/responsive-control.js
index a202b74..4dac191 100644
--- a/resources/js/panel/responsive-control.js
+++ b/resources/js/panel/responsive-control.js
@@ -11,7 +11,7 @@ const responsiveControl = function () {
document.querySelectorAll('.table-list')?.forEach(function (table) {
- console.log(table);
+ // console.log(table);
// Get all the header cells
const headers = Array.from(table.querySelectorAll('th')).map(th => th.textContent.trim());
diff --git a/resources/lang/fa.json b/resources/lang/fa.json
index 2e3bf02..eb0abe7 100644
--- a/resources/lang/fa.json
+++ b/resources/lang/fa.json
@@ -87,6 +87,8 @@
"As you wished restored successfully": "همانطور که شما مایل بودید بازیافت شد",
"As you wished sort saved": "همانطور که شما مایل بودید مرتب شدند",
"As you wished updated successfully": "همانطور که شما مایل بودید به روز شد",
+ "Assets build failed": "داراییها ساخته نشدهاند",
+ "Assets build successfully": "داراییها با موفقیت ساخته شدن",
"Attaching": "پیوست کردن",
"Attachment": "پیوست",
"Attachments": "پیوستها",
@@ -105,6 +107,7 @@
"Batch delete": "حذف چندگانه",
"Batch restore": "بازیافت چندگانه",
"Before proceeding, please check your email for a verification link.": "قبل از ادامه فرآیند لطفا رایانه خودتون رو بررسی کنید که لینک ارسال شده باشد",
+ "Build assets": "ساخت داراییهای طراحی",
"Bulk actions:": "کار دستهجمعی",
"Cache cleared": "حافظه نهان پاک شد",
"Call us!": "با ما تماس بگیرید!",
@@ -423,6 +426,7 @@
"SEO Score": "امتیاز سئو",
"SKU": "",
"SMS": "پیامک",
+ "SVG image": "تصویر SVG",
"Save": "ذخیره",
"Save all settings": "ذخیره همه تنظیمات",
"Search": "جستجو",
@@ -463,7 +467,8 @@
"Sliders": "اسلایدرها",
"Sliders list": "فهرست اسلایدر",
"Slug": "نامک",
- "Sort": "مرتب",
+ "Sort": "ترتیب",
+ "Sort & filter": "ترتیب و صافی",
"State": "استان",
"States": "استانها",
"States list": "فهرست استانها",
@@ -476,6 +481,7 @@
"Subtitle": "زیرعنوان",
"Successfully Invoices": "صورتحساب های موفق",
"Summary": "خلاصه",
+ "Svg image": "تصویر SVG",
"System notification": "پیام سیستم",
"Table of contents": "فهرست عناوین",
"Tag": "برچسب",
@@ -619,6 +625,7 @@
"news": "خبر",
"not searchable": "غیرقابل جستجو",
"one second ago": "یک ثانیه پیش",
+ "or build it using the button below": "یا توسط دکمه ساختن دارایی پایین اقدام کنید",
"paragraphs": "بند",
"parent_id": "والد",
"password repeat": "تکرار گذرواژه",
diff --git a/resources/views/admin/areas/area-list.blade.php b/resources/views/admin/areas/area-list.blade.php
index b9807a6..eeed81e 100644
--- a/resources/views/admin/areas/area-list.blade.php
+++ b/resources/views/admin/areas/area-list.blade.php
@@ -7,8 +7,10 @@
@if(config('app.demo'))
{{__("Theme loaded every :M minutes in demo version", ['M' => 5])}}
+ {{__("or build it using the button below")}}
@endif
+ @include('components.err')
@foreach($areas as $area)
@@ -18,5 +20,11 @@
@endforeach
+
@endsection
diff --git a/routes/web.php b/routes/web.php
index 5c90042..9cb8f49 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -361,6 +361,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::post('update/{area}', [\App\Http\Controllers\Admin\AreaController::class, "update"])->name('update');
Route::post('update/model/{model}/{id}', [\App\Http\Controllers\Admin\AreaController::class, "updateModel"])->name('update.model');
Route::get('sort/{area}', [\App\Http\Controllers\Admin\AreaController::class, "sort"])->name('sort');
+ Route::get('build', [\App\Http\Controllers\Admin\AreaController::class, "build"])->name('build');
Route::post('sort-save/{area}', [\App\Http\Controllers\Admin\AreaController::class, "sortSave"])->name('sort-save');
}
);