Mise à jour
This commit is contained in:
@@ -14,62 +14,49 @@ use App\Models\Shop\Price;
|
||||
class Prices
|
||||
{
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
$prices = Price::byArticle($id)->with('price')->get()->toArray();
|
||||
$data = [];
|
||||
foreach ($prices as $price)
|
||||
{
|
||||
if ($price['price_type'] == 'App\Models\Shop\ArticlePrice')
|
||||
{
|
||||
$data[] = $price['price'];
|
||||
} else {
|
||||
$values = PriceGenericValues::getByPriceGeneric($price['price']['id'])->toArray();
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$data[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
$data['prices'] = Price::byArticle($id)->notGeneric()->get()->toArray();
|
||||
$data['generics'] = Price::byArticle($id)->generic()->with(['generic.prices','generic.category'])->get()->toArray();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Price::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name','asc')->get();
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
return Price::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::find($id);
|
||||
}
|
||||
public static function get($id)
|
||||
{
|
||||
return Price::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Price::create($data);
|
||||
}
|
||||
public static function create($data)
|
||||
{
|
||||
return Price::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Price::find($id)->update($data);
|
||||
}
|
||||
public static function update($data)
|
||||
{
|
||||
return Price::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
}
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Price::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
58
app/Repositories/Shop/Unities.php
Normal file
58
app/Repositories/Shop/Unities.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Unity;
|
||||
|
||||
class Unities
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Unity::orderBy('value','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Unity::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Unity::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Unity::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Unity::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user