[WIP] Refactor project
This commit is contained in:
53
app/Repositories/Shop/Customers.php
Normal file
53
app/Repositories/Shop/Customers.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Customer;
|
||||
|
||||
class Customers
|
||||
{
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Customer::orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByPackage($package_id)
|
||||
{
|
||||
return Customer::byPackage($package_id)->orderBy('value','asc')->get()->pluck('value','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Customer::orderBy('value','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Customer::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data, $id) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Customer::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
return Customer::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Customer::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user