added buy price

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

@ -52,11 +52,15 @@ class ProductController extends XController
// dd($request->all()); // dd($request->all());
$product->name = $request->input('name'); $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->table = $request->input('table');
$product->description = $request->input('desc'); $product->description = $request->input('desc');
$product->excerpt = $request->input('excerpt'); $product->excerpt = $request->input('excerpt');
$product->stock_status = $request->input('stock_status'); $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')) { if (!$request->has('quantity')) {
$product->price = $request->input('price',0); $product->price = $request->input('price',0);
$product->stock_quantity = $request->input('stock_quantity'); $product->stock_quantity = $request->input('stock_quantity');

@ -120,7 +120,9 @@ abstract class XController extends Controller
logAdmin(__METHOD__, $this->_MODEL_, $item->id); logAdmin(__METHOD__, $this->_MODEL_, $item->id);
if ($request->ajax()) { 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 { } else {
return redirect(getRoute('edit', $item->{$item->getRouteKeyName()})) return redirect(getRoute('edit', $item->{$item->getRouteKeyName()}))
->with(['message' => __('As you wished created successfully')]); ->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('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->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('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('category_id')->comment('main category id');
$table->unsignedBigInteger('user_id'); $table->unsignedBigInteger('user_id');
$table->boolean('on_sale')->nullable()->default(true)->index(); $table->boolean('on_sale')->nullable()->default(true)->index();

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

@ -14,6 +14,8 @@
import './bootstrap'; import './bootstrap';
import { createApp } from 'vue'; import { createApp } from 'vue';
import ToastPlugin from 'vue-toast-notification';
import {useToast} from 'vue-toast-notification';
import './panel/raw.js'; import './panel/raw.js';
import './panel/navbar.js'; import './panel/navbar.js';
import './panel/list-checkboxs.js'; import './panel/list-checkboxs.js';
@ -29,6 +31,9 @@ import './panel/product-upload-controller.js';
*/ */
const app = createApp({}); const app = createApp({});
const $toast = useToast({
duration: 10000,
});
import ExampleComponent from './components/ExampleComponent.vue'; import ExampleComponent from './components/ExampleComponent.vue';
app.component('example-component', ExampleComponent); app.component('example-component', ExampleComponent);
@ -88,5 +93,8 @@ app.component('props-type-input', PropTypeInput);
* an "id" attribute of "app". This element is included with the "auth" * an "id" attribute of "app". This element is included with the "auth"
* scaffolding. Otherwise, you will need to add an element yourself. * scaffolding. Otherwise, you will need to add an element yourself.
*/ */
app.use(ToastPlugin);
app.mount('#app'); app.mount('#app');
window.app = app;
window.$toast = $toast;

@ -114,10 +114,11 @@ document.addEventListener('DOMContentLoaded', () => {
for (let i in error.response.data.errors) { for (let i in error.response.data.errors) {
document.getElementById(i)?.classList.add('is-invalid'); document.getElementById(i)?.classList.add('is-invalid');
for (const err of error.response.data.errors[i]) { for (const err of error.response.data.errors[i]) {
// alertify.error(err); $toast.error(err);
console.log(err); // console.log(err);
} }
} }
$toast.error('Error:' +error.response.status);
}); });
}); });
uploadingImages?.addEventListener('dblclick', (e) => { uploadingImages?.addEventListener('dblclick', (e) => {

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

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

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

Loading…
Cancel
Save