48 lines
979 B
PHP
48 lines
979 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Shop;
|
|
|
|
use App\Models\Shop\ArticleNature;
|
|
|
|
class ArticleNatures
|
|
{
|
|
public static function getOptions()
|
|
{
|
|
return ArticleNature::get()->pluck('name', 'id')->toArray();
|
|
}
|
|
|
|
public static function getAll()
|
|
{
|
|
return ArticleNature::orderBy('name', 'asc')->get();
|
|
}
|
|
|
|
public static function get($id)
|
|
{
|
|
return ArticleNature::find($id);
|
|
}
|
|
|
|
public static function store($data)
|
|
{
|
|
$item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
|
return $item->id;
|
|
}
|
|
|
|
public static function create($data)
|
|
{
|
|
return ArticleNature::create($data);
|
|
}
|
|
|
|
public static function update($data, $id = false)
|
|
{
|
|
$id = $id ? $id : $data['id'];
|
|
$item = self::get($id);
|
|
$ret = $item->update($data);
|
|
return $item;
|
|
}
|
|
|
|
public static function destroy($id)
|
|
{
|
|
return ArticleNature::destroy($id);
|
|
}
|
|
}
|