53 lines
945 B
PHP
53 lines
945 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Shop;
|
|
|
|
use App\Models\Shop\Unity;
|
|
|
|
class Unities
|
|
{
|
|
|
|
public static function getOptions()
|
|
{
|
|
return Unity::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
|
}
|
|
|
|
public static function getOptionsByPackage($package_id)
|
|
{
|
|
return Unity::byPackage($package_id)->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);
|
|
}
|
|
|
|
}
|