новый дизайн
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Concerns\BuildsPortalProps;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\SaveShopCategoryRequest;
|
||||
use App\Http\Requests\Admin\SaveShopProductRequest;
|
||||
@@ -9,15 +10,73 @@ use App\Models\ShopCategory;
|
||||
use App\Models\ShopProduct;
|
||||
use App\Services\ShopCatalogService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function index(ShopCatalogService $catalog): View
|
||||
use BuildsPortalProps;
|
||||
|
||||
public function index(Request $request, ShopCatalogService $catalog): Response
|
||||
{
|
||||
return view('admin.shop.index', [
|
||||
'categories' => $catalog->categories(),
|
||||
'products' => $catalog->products(),
|
||||
$categories = $catalog->categories();
|
||||
|
||||
return Inertia::render('Admin/Shop', [
|
||||
...$this->portalProps($request),
|
||||
'categories' => $categories
|
||||
->map(fn (ShopCategory $category): array => [
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
'icon' => $category->icon,
|
||||
'required_rank' => $category->requiredRank,
|
||||
'flags' => $category->flags,
|
||||
'enabled' => $category->enabled,
|
||||
'products_count' => $category->products_count,
|
||||
'update_url' => route('admin.shop.categories.update', $category),
|
||||
'destroy_url' => route('admin.shop.categories.destroy', $category),
|
||||
])
|
||||
->values()
|
||||
->all(),
|
||||
'products' => $catalog->products()
|
||||
->map(fn (ShopProduct $product): array => [
|
||||
'id' => $product->id,
|
||||
'category_ids' => $product->categories->pluck('id')->values()->all(),
|
||||
'category_names' => $product->categories->pluck('name')->values()->all(),
|
||||
'type' => (int) $product->type,
|
||||
'name' => $product->name,
|
||||
'tooltip_name' => $product->tooltipName,
|
||||
'tooltip_type' => $product->tooltipType,
|
||||
'tooltip_text' => $product->tooltipText,
|
||||
'icon' => $product->icon,
|
||||
'price' => (int) $product->price,
|
||||
'hyperlink_id' => (int) $product->hyperlinkId,
|
||||
'creature_entry' => (int) $product->creatureEntry,
|
||||
'discount_amount' => (int) $product->discountAmount,
|
||||
'flags' => (int) $product->flags,
|
||||
'rewards' => collect(range(1, 8))->map(fn (int $slot): array => [
|
||||
'slot' => $slot,
|
||||
'id' => (int) $product->{'reward_'.$slot},
|
||||
'count' => (int) $product->{'rewardcount_'.$slot},
|
||||
])->all(),
|
||||
'is_new' => (bool) $product->new,
|
||||
'enabled' => (bool) $product->enabled,
|
||||
'update_url' => route('admin.shop.products.update', $product),
|
||||
'destroy_url' => route('admin.shop.products.destroy', $product),
|
||||
])
|
||||
->values()
|
||||
->all(),
|
||||
'categoryStoreUrl' => route('admin.shop.categories.store'),
|
||||
'productStoreUrl' => route('admin.shop.products.store'),
|
||||
'productTypes' => collect([
|
||||
1 => 'Предмет',
|
||||
3 => 'Маунт',
|
||||
4 => 'Питомец',
|
||||
5 => 'Бафф',
|
||||
7 => 'Услуга персонажа',
|
||||
8 => 'Буст',
|
||||
9 => 'Титул',
|
||||
])->map(fn (string $label, int $value): array => compact('value', 'label'))->values()->all(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user