little refactoring
This commit is contained in:
@@ -4,11 +4,19 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Producer;
|
||||
use App\Repositories\Core\Tag;
|
||||
use App\Traits\Model\Basic;
|
||||
use App\Traits\Repository\Imageable;
|
||||
|
||||
class Producers
|
||||
{
|
||||
use Imageable;
|
||||
use Basic, Imageable;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
return [
|
||||
'tags_list' => TagGroups::getTreeTags(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function autocomplete($str)
|
||||
{
|
||||
@@ -31,21 +39,6 @@ class Producers
|
||||
return Tag::storeTags($variety, $tags);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Producer::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Producer::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Producer::find($id);
|
||||
}
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$producer = self::get($id);
|
||||
@@ -73,27 +66,8 @@ class Producers
|
||||
return $producer;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
public static function getModel()
|
||||
{
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Producer::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Producer::destroy($id);
|
||||
return Producer::query();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user