Add new version in repository
This commit is contained in:
67
app/Repositories/Shop/PriceListValues.php
Normal file
67
app/Repositories/Shop/PriceListValues.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user