diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 5247261..9a4ea14 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -52,11 +52,15 @@ class ProductController extends XController // dd($request->all()); $product->name = $request->input('name'); - $product->slug = $this->getSlug($product,'slug','title'); + $product->slug = $this->getSlug($product,'slug','name'); + $product->table = $request->input('table'); $product->description = $request->input('desc'); $product->excerpt = $request->input('excerpt'); $product->stock_status = $request->input('stock_status'); + $product->price = $request->input('price',0); + $product->buy_price = $request->input('bye_price',0); + if (!$request->has('quantity')) { $product->price = $request->input('price',0); $product->stock_quantity = $request->input('stock_quantity'); diff --git a/app/Http/Controllers/XController.php b/app/Http/Controllers/XController.php index 384d65d..a886a28 100644 --- a/app/Http/Controllers/XController.php +++ b/app/Http/Controllers/XController.php @@ -120,7 +120,9 @@ abstract class XController extends Controller logAdmin(__METHOD__, $this->_MODEL_, $item->id); if ($request->ajax()) { - return ['OK' => true, "message" => __('As you wished created successfully'), "id" => $item->id]; + return ['OK' => true, "message" => __('As you wished created successfully'), + "id" => $item->id, + 'url' => getRoute('edit', $item->{$item->getRouteKeyName()})]; } else { return redirect(getRoute('edit', $item->{$item->getRouteKeyName()})) ->with(['message' => __('As you wished created successfully')]); diff --git a/database/migrations/2024_05_07_130016_create_products_table.php b/database/migrations/2024_05_07_130016_create_products_table.php index 863281b..b00e931 100644 --- a/database/migrations/2024_05_07_130016_create_products_table.php +++ b/database/migrations/2024_05_07_130016_create_products_table.php @@ -22,6 +22,7 @@ return new class extends Migration $table->boolean('virtual')->nullable()->default(false)->index()->comment('If this product is a non-physical item, for example a service, which does not need shipping.'); $table->boolean('downloadable')->nullable()->default(false)->index()->comment('If purchasing this product gives a customer access to a downloadable file, e.g. software'); $table->unsignedBigInteger('price')->nullable()->default(null)->index(); + $table->unsignedBigInteger('buy_price')->default(0)->comment('bye price to calculate your Gross Margin'); $table->unsignedBigInteger('category_id')->comment('main category id'); $table->unsignedBigInteger('user_id'); $table->boolean('on_sale')->nullable()->default(true)->index(); diff --git a/package.json b/package.json index dd1be3d..67cdeea 100644 --- a/package.json +++ b/package.json @@ -1,3 +1,4 @@ + { "private": true, "type": "module", diff --git a/resources/js/app.js b/resources/js/app.js index 10da649..fd50bd9 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -14,6 +14,8 @@ import './bootstrap'; import { createApp } from 'vue'; +import ToastPlugin from 'vue-toast-notification'; +import {useToast} from 'vue-toast-notification'; import './panel/raw.js'; import './panel/navbar.js'; import './panel/list-checkboxs.js'; @@ -29,6 +31,9 @@ import './panel/product-upload-controller.js'; */ const app = createApp({}); +const $toast = useToast({ + duration: 10000, +}); import ExampleComponent from './components/ExampleComponent.vue'; app.component('example-component', ExampleComponent); @@ -37,7 +42,7 @@ import VueJalaliCalendar from './components/vueJalaliCalendar.vue'; app.component('vue-jalali-calendar', VueJalaliCalendar); import CurrencyInput from './components/CurrencyInput.vue'; -app.component('currency-input', CurrencyInput); +app.component('currency-input',CurrencyInput); import RemixIconPicker from './components/RemixIconPicker.vue'; app.component('remix-icon-picker', RemixIconPicker); @@ -88,5 +93,8 @@ app.component('props-type-input', PropTypeInput); * an "id" attribute of "app". This element is included with the "auth" * scaffolding. Otherwise, you will need to add an element yourself. */ - +app.use(ToastPlugin); app.mount('#app'); + +window.app = app; +window.$toast = $toast; diff --git a/resources/js/panel/product-upload-controller.js b/resources/js/panel/product-upload-controller.js index a70fef1..0bcf92b 100644 --- a/resources/js/panel/product-upload-controller.js +++ b/resources/js/panel/product-upload-controller.js @@ -114,10 +114,11 @@ document.addEventListener('DOMContentLoaded', () => { for (let i in error.response.data.errors) { document.getElementById(i)?.classList.add('is-invalid'); for (const err of error.response.data.errors[i]) { - // alertify.error(err); - console.log(err); + $toast.error(err); + // console.log(err); } } + $toast.error('Error:' +error.response.status); }); }); uploadingImages?.addEventListener('dblclick', (e) => { diff --git a/resources/sass/panel/_fix.scss b/resources/sass/panel/_fix.scss index 287e46a..58a30d1 100644 --- a/resources/sass/panel/_fix.scss +++ b/resources/sass/panel/_fix.scss @@ -58,3 +58,7 @@ a,a:visited{ --bs-pagination-color: #cb00a5; --bs-pagination-hover-color: red; } + +.v-toast__item{ + width: 275px ; +} diff --git a/resources/views/admin/products/sub-pages/product-step1.blade.php b/resources/views/admin/products/sub-pages/product-step1.blade.php index feb7b14..8616ca9 100644 --- a/resources/views/admin/products/sub-pages/product-step1.blade.php +++ b/resources/views/admin/products/sub-pages/product-step1.blade.php @@ -25,7 +25,7 @@ -
+
-
+
+
+ + + +
+
+
-
+
-
+