Fixes on adding price & errors
This commit is contained in:
@@ -17,6 +17,7 @@ class PriceListsDataTable extends DataTable
|
||||
|
||||
public function query(PriceList $model)
|
||||
{
|
||||
$model = $model->with('sale_channel');
|
||||
$model = self::filterByTariff($model);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
@@ -32,6 +33,7 @@ class PriceListsDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title('Canal de vente'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class TariffsDataTable extends DataTable
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('sale_channel.name')->title('Canal de vente'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('sale_channel.name')->title('Canal de vente par défaut'),
|
||||
Column::make('code')->title('Code'),
|
||||
Column::make('ref')->title('Référence'),
|
||||
Column::make('name')->title('Nom'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class PriceListController extends Controller
|
||||
|
||||
public function modalEdit($id)
|
||||
{
|
||||
$data['price_list'] = PriceLists::getFull($id);
|
||||
$data['price_list'] = PriceLists::edit($id);
|
||||
$data['sale_channels'] = SaleChannels::getOptions();
|
||||
$data['statuses'] = Tariffs::getStatuses();
|
||||
return view('Admin.Shop.PriceLists.modal', $data);
|
||||
|
||||
@@ -21,11 +21,6 @@ class PriceListValueController extends Controller
|
||||
return $dataTable->render('Admin.Shop.PriceListValues.list', $data);
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return PriceListValues::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data['unities'] = Unities::getOptions();
|
||||
@@ -66,4 +61,12 @@ class PriceListValueController extends Controller
|
||||
$data['generic'] = PriceListValues::getFull($id);
|
||||
return view('Admin.Shop.PriceListValues.partials.table-prices', $data);
|
||||
}
|
||||
|
||||
public function addPrice($index)
|
||||
{
|
||||
$data['index'] = $index;
|
||||
return view('Admin.Shop.PriceListValues.partials.row_price', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,4 +26,19 @@ class PriceList extends Model
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\PriceListValue');
|
||||
}
|
||||
|
||||
public function scopeByTariff($query, $id)
|
||||
{
|
||||
return $query->where('tariff_id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySaleChannel($query, $id)
|
||||
{
|
||||
return $query->where('sale_channel_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where('status_id', $id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,19 +10,14 @@ use App\Models\Shop\PriceList;
|
||||
|
||||
class PriceLists
|
||||
{
|
||||
public static function getByArticle($id)
|
||||
public static function getByTariff($id)
|
||||
{
|
||||
return PriceList::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithValues($id)
|
||||
{
|
||||
return PriceList::with('values')->byArticle($id)->get();
|
||||
return PriceList::byTariff($id)->get();
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return PriceList::with('prices')->get()->toArray();
|
||||
return PriceList::pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
@@ -30,6 +25,14 @@ class PriceLists
|
||||
return PriceList::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
$price_list = self::getFull($id)->toArray();
|
||||
$n = count($price_list['price_list_values']);
|
||||
$price_list['price_list_values'] += array_fill($n, 3 - $n, '');
|
||||
return $price_list;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return PriceList::find($id);
|
||||
|
||||
Reference in New Issue
Block a user