Fixes on prices & add ArticlePriceGeneric
This commit is contained in:
67
app/Repositories/Shop/ArticlePriceGenerics.php
Normal file
67
app/Repositories/Shop/ArticlePriceGenerics.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\ArticlePriceGeneric;
|
||||
|
||||
class ArticlePriceGenerics
|
||||
{
|
||||
|
||||
public static function getByArticle($id)
|
||||
{
|
||||
return ArticlePriceGeneric::byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getByArticleWithAttribute($id)
|
||||
{
|
||||
return ArticlePriceGeneric::with('article_attribute.attribute_value')->byArticle($id)->get();
|
||||
}
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = ArticlePriceGeneric::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return ArticlePriceGeneric::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return ArticlePriceGeneric::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 ArticlePriceGeneric::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$article = ArticlePriceGeneric::find($id);
|
||||
$article->update($data);
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return ArticlePriceGeneric::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user