change cart and category resource
This commit is contained in:
parent
c51e580dac
commit
e247632af2
|
|
@ -14,7 +14,7 @@ namespace Beike\Repositories;
|
|||
use Beike\Models\Category;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Beike\Shop\Http\Resources\CategoryList;
|
||||
use Beike\Shop\Http\Resources\CategoryDetail;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class CategoryRepo
|
||||
|
|
@ -44,7 +44,7 @@ class CategoryRepo
|
|||
->orderBy('position')
|
||||
->get();
|
||||
|
||||
$categoryList = CategoryList::collection($topCategories);
|
||||
$categoryList = CategoryDetail::collection($topCategories);
|
||||
return json_decode($categoryList->toJson(), true);
|
||||
}
|
||||
|
||||
|
|
@ -57,26 +57,18 @@ class CategoryRepo
|
|||
*/
|
||||
public static function list(array $filter = [])
|
||||
{
|
||||
$keyword = $filter['keyword'] ?? '';
|
||||
$builder = Category::query()->with(['description']);
|
||||
if ($keyword) {
|
||||
// $builder->whereExists('name')
|
||||
}
|
||||
return $builder->get();
|
||||
}
|
||||
|
||||
public static function updateViewNumber()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function multipleUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function autocomplete($name)
|
||||
/**
|
||||
* 自动完成
|
||||
*
|
||||
* @param $name
|
||||
* @return array
|
||||
*/
|
||||
public static function autocomplete($name): array
|
||||
{
|
||||
$categories = Category::query()->with('paths.pathCategory.description')
|
||||
->whereHas('paths', function ($query) use ($name) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CartList extends JsonResource
|
||||
class CartDetail extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
|
|
@ -5,7 +5,7 @@ namespace Beike\Shop\Http\Resources;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CategoryList extends JsonResource
|
||||
class CategoryDetail extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
|
|
@ -11,10 +11,9 @@
|
|||
|
||||
namespace Beike\Shop\Services;
|
||||
|
||||
use Beike\Models\CartProduct;
|
||||
use Exception;
|
||||
use Beike\Models\Cart;
|
||||
use Beike\Shop\Http\Resources\CartList;
|
||||
use Beike\Models\CartProduct;
|
||||
use Beike\Shop\Http\Resources\CartDetail;
|
||||
|
||||
class CartService
|
||||
{
|
||||
|
|
@ -48,7 +47,7 @@ class CartService
|
|||
return $description && $product;
|
||||
});
|
||||
|
||||
$cartList = CartList::collection($cartItems)->jsonSerialize();
|
||||
$cartList = CartDetail::collection($cartItems)->jsonSerialize();
|
||||
return $cartList;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue