category default limit

This commit is contained in:
merdan 2022-03-14 15:38:15 +05:00
parent 4f33f210ac
commit 0d7fbf615a
6 changed files with 79 additions and 7 deletions

View File

@ -4,6 +4,7 @@ namespace Sarga\API\Http\Controllers;
use App\Http\Controllers\Controller;
use Sarga\API\Http\Resources\Catalog\Attribute;
use Sarga\API\Http\Resources\Catalog\Brand;
use Sarga\API\Http\Resources\Catalog\Category;
use Sarga\Shop\Repositories\CategoryRepository;
@ -35,12 +36,15 @@ class Categories extends Controller
}
public function filters($id){
$category = $this->categoryRepository->with('filterableAttributes')->find($id);
$category = $this->categoryRepository->with(['filterableAttributes','brands'])->find($id);
if($category)
return Attribute::collection($category->filterableAttributes);
return response([
'attributes' =>Attribute::collection($category->filterableAttributes),
'brands' => Brand::collection($category->brands),
]);
else{
return response()->json(['error'=>'not found'],404);
return response(['error'=>'not found'],404);
}
}

View File

@ -17,4 +17,8 @@ class Orders extends OrderController
{
return OrderResource::class;
}
public function cancelItem(){
}
}

View File

@ -117,6 +117,8 @@ Route::group(['prefix' => 'api'], function () {
Route::post('orders/{id}/cancel', [Orders::class, 'cancel']);
Route::post('orders/{id}/cancel/{item_id}', [Orders::class, 'cancelItem']);
Route::get('invoices', [InvoiceController::class, 'allResources']);
Route::get('invoices/{id}', [InvoiceController::class, 'getResource']);

View File

@ -0,0 +1,56 @@
<?php
namespace Sarga\Shop\Models;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Sarga\Brand\Models\BrandProxy;
use Webkul\Category\Database\Factories\CategoryFactory;
use Webkul\Category\Models\Category as WCategory;
class Category extends WCategory
{
/**
* Fillables.
*
* @var array
*/
protected $fillable = [
'position',
'status',
'display_mode',
'parent_id',
'additional',
'trendyol_url',
'lcw_url',
'default_weight',//todo remove when implemented in scraper
'product_limit'
];
/**
* Eager loading.
*
* @var array
*/
protected $with = ['translations'];
/**
* Appends.
*
* @var array
*/
protected $appends = ['image_url', 'category_icon_url'];
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory(): Factory
{
return CategoryFactory::new ();
}
public function brands() :BelongsToMany{
return $this->belongsToMany(BrandProxy::modelClass(),'category_brands');
}
}

View File

@ -2,10 +2,20 @@
namespace Sarga\Shop\Repositories;
use Sarga\Shop\Models\Category;
use Webkul\Category\Repositories\CategoryRepository as WCategoryRepository;
class CategoryRepository extends WCategoryRepository
{
/**
* Specify model class name.
*
* @return mixed
*/
public function model()
{
return Category::class;
}
public function getCategoryTree($id = null)
{

View File

@ -38,7 +38,6 @@ return [
'cart' => 'Корзина',
'profile' => 'Профиль',
'wishlist' => 'список желаний',
'cart' => 'Корзина',
'logout' => 'Выйти',
'search-text' => 'Искать товары здесь',
],
@ -65,7 +64,6 @@ return [
'already' => 'Вы уже подписаны на наш список подписки.',
'unsubscribed' => 'Вы отписались от подписных писем.',
'already-unsub' => 'Вы уже отписались.',
'not-subscribed' => 'Ошибка! Почта не может быть отправлена ​​в настоящее время, повторите попытку позже.',
],
'search' => [
@ -568,8 +566,6 @@ return [
'summary' => 'Итог заказа',
'price' => 'Цена',
'quantity' => 'Количество',
'billing-address' => 'Адрес для выставления счета',
'shipping-address' => 'Адреса доставки',
'contact' => 'Контакт',
'place-order' => 'Разместить заказ',
'new-address' => 'Добавьте новый адрес',