56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories\Shop;
|
|
|
|
use Yajra\DataTables\DataTables;
|
|
|
|
use App\Models\Shop\PriceFamily;
|
|
|
|
class PriceFamilies
|
|
{
|
|
|
|
public static function getDatatable()
|
|
{
|
|
$model = PriceFamily::orderBy('name');
|
|
return Datatables::of($model)->make(true);
|
|
}
|
|
|
|
public static function getAll()
|
|
{
|
|
return PriceFamily::orderBy('name','asc')->get();
|
|
}
|
|
|
|
public static function get($id)
|
|
{
|
|
return PriceFamily::find($id);
|
|
}
|
|
|
|
public static function getOptions()
|
|
{
|
|
return PriceFamily::get()->pluck('name','id')->toArray();
|
|
}
|
|
|
|
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 PriceFamily::create($data);
|
|
}
|
|
|
|
public static function update($data)
|
|
{
|
|
return PriceFamily::find($id)->update($data);
|
|
}
|
|
|
|
public static function destroy($id)
|
|
{
|
|
return PriceFamily::destroy($id);
|
|
}
|
|
|
|
}
|