added buy price

fixed redirect for insert category_id in list
pull/44/head
A1Gard 3 months ago
parent 6265c8cf77
commit 5dd4f3b03d

@ -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');

@ -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')]);

@ -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();

@ -1,3 +1,4 @@
{
"private": true,
"type": "module",

@ -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;

@ -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) => {

@ -58,3 +58,7 @@ a,a:visited{
--bs-pagination-color: #cb00a5;
--bs-pagination-hover-color: red;
}
.v-toast__item{
width: 275px ;
}

@ -25,7 +25,7 @@
</div>
<div class="col-lg-3 mt-3">
<div class="col-lg-6 mt-3">
<div class="form-group">
<label for="price">
{{__('Base price')}}
@ -35,7 +35,17 @@
:err="true" @enderror :xvalue="{{old('price',$item->price??null)}}"></currency-input>
</div>
</div>
<div class="col-lg-3 mt-3">
<div class="col-lg-6 mt-3">
<div class="form-group">
<label for="buy_price">
{{__('Purchase price')}}
</label>
<currency-input name="buy_price" xid="buy_price" @error('buy_price')
:err="true" @enderror :xvalue="{{old('buy_price',$item->buy_price??0)}}"></currency-input>
</div>
</div>
<div class="col-lg-4 mt-3">
<div class="form-group">
<label for="categoryId">
{{__('Main product category')}}1
@ -55,7 +65,7 @@
:close-on-Select="true"></searchable-select>
</div>
</div>
<div class="col-lg-3 mt-3">
<div class="col-lg-4 mt-3">
<div class="form-group">
<label for="price">
{{__('SKU')}}
@ -67,7 +77,7 @@
value="{{old('sku',$item->sku??null)}}"/>
</div>
</div>
<div class="col-lg-3 mt-3">
<div class="col-lg-4 mt-3">
<div class="form-group">
<label for="status">
{{__('Status')}}

@ -185,6 +185,11 @@
{{ $item->user?->name??'-' }}
</a>
@break
@case($col == 'category_id')
<a href="{{route('admin.category.edit',$item->category?->slug)}}">
{{ $item->category?->name??'-' }}
</a>
@break
@default
{{$item->$col}}
@endswitch

Loading…
Cancel
Save