Add new version in repository

This commit is contained in:
Ludovic CANDELLIER
2021-07-25 23:19:27 +02:00
parent f75632b054
commit b879f11c99
608 changed files with 12235 additions and 7513 deletions

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use App\Models\Shop\PriceListValue;
class PriceListValues
{
public static function getByPriceListValue($id)
{
return PriceListValue::byPriceListValue($id)->get();
}
public static function getDatatable()
{
$model = PriceListValue::orderBy('name');
return Datatables::of($model)->make(true);
}
public static function getAll()
{
return PriceListValue::orderBy('name', 'asc')->get();
}
public static function get($id)
{
return PriceListValue::find($id);
}
public static function storePrices($generic_id, $values)
{
foreach ($values as $value) {
$value['price_generic_id'] = $generic_id;
self::store($value);
}
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$price = $id ? self::update($data) : self::create($data);
return $price->id;
}
public static function create($data)
{
return PriceListValue::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return PriceListValue::destroy($id);
}
}