68 lines
1.3 KiB
PHP
68 lines
1.3 KiB
PHP
<?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\PriceGeneric;
|
|
|
|
class PriceGenerics
|
|
{
|
|
|
|
public static function getByArticle($id)
|
|
{
|
|
return PriceGeneric::byArticle($id)->get();
|
|
}
|
|
|
|
public static function getByArticleWithValues($id)
|
|
{
|
|
return PriceGeneric::with('values')->byArticle($id)->get();
|
|
}
|
|
|
|
public static function getDatatable()
|
|
{
|
|
$model = PriceGeneric::orderBy('name');
|
|
return Datatables::of($model)->make(true);
|
|
}
|
|
|
|
public static function getAll()
|
|
{
|
|
return PriceGeneric::orderBy('name','asc')->get();
|
|
}
|
|
|
|
public static function get($id)
|
|
{
|
|
return PriceGeneric::find($id);
|
|
}
|
|
|
|
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 PriceGeneric::create($data);
|
|
}
|
|
|
|
public static function update($data, $id = false)
|
|
{
|
|
$id = isset($data['id']) ? $data['id'] : false;
|
|
$article = PriceGeneric::find($id);
|
|
$article->update($data);
|
|
return $article;
|
|
}
|
|
|
|
public static function destroy($id)
|
|
{
|
|
return PriceGeneric::destroy($id);
|
|
}
|
|
|
|
}
|