AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Order;
  4. use App\Models\Store;
  5. use Illuminate\Http\Request;
  6. use Inertia\Inertia;
  7. use Inertia\Response;
  8. /**
  9. * The merchant's view of a store's orders.
  10. */
  11. class OrderController extends Controller
  12. {
  13. public function index(Request $request, string $slug): Response
  14. {
  15. $store = $this->ownedStore($request, $slug);
  16. return Inertia::render('stores/orders/index', [
  17. 'store' => ['name' => $store->name, 'slug' => $store->slug],
  18. 'orders' => $store->orders()
  19. ->with('items')
  20. ->latest('id')
  21. ->limit(200)
  22. ->get()
  23. ->map(fn (Order $order) => $order->toDisplay()),
  24. ]);
  25. }
  26. public function show(Request $request, string $slug, int $order): Response
  27. {
  28. $store = $this->ownedStore($request, $slug);
  29. return Inertia::render('stores/orders/show', [
  30. 'store' => ['name' => $store->name, 'slug' => $store->slug],
  31. 'order' => $store->orders()->with('items')->whereKey($order)->firstOrFail()->toDisplay(),
  32. ]);
  33. }
  34. private function ownedStore(Request $request, string $slug): Store
  35. {
  36. return $request->user()->stores()->where('slug', $slug)->firstOrFail();
  37. }
  38. }