Scenario of disable sale/purchase price done

This commit is contained in:
Cihan Şentürk
2022-12-19 12:22:59 +03:00
committed by GitHub
parent a9703e45ca
commit afb1a9fadb
3 changed files with 8 additions and 2 deletions

View File

@ -88,6 +88,11 @@ class Item extends Model
return $query->where($billing . '_price', '=', null);
}
public function scopePriceType($query, $price_type)
{
return $query->whereNotNull($price_type . '_price');
}
/**
* Get the item id.
*

View File

@ -39,9 +39,10 @@ class ItemButton extends Component
*/
public function render()
{
$items = Item::enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
$price_type = $this->getPriceType($this->type, $this->isSale, $this->isPurchase);
$items = Item::priceType($price_type)->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
foreach ($items as $item) {
$price = $item->{$price_type . '_price'};

View File

@ -315,7 +315,7 @@ export default {
},
async fetchMatchedItems() {
await window.axios.get(url + '/common/items?search="' + this.search + '" enabled:1 limit:10')
await window.axios.get(url + '/common/items?search="' + this.search + '" not ' + this.price + ':NULL enabled:1 limit:10')
.then(response => {
this.item_list = [];
let items = response.data.data;