25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

34 satır
928B

  1. <?php
  2. namespace App\Http\Controllers\Locations;
  3. use App\Models\Location;
  4. use App\Models\Stock;
  5. use Framework\Routing\Router;
  6. class ShowLocationsController
  7. {
  8. public function handle(Router $router)
  9. {
  10. $locations = Location::all();
  11. $stock = Stock::all();
  12. $totalsByLocation = [];
  13. foreach ($stock as $row) {
  14. $totalsByLocation[$row->location_id] = ($totalsByLocation[$row->location_id] ?? 0) + $row->quantity;
  15. }
  16. foreach ($locations as $location) {
  17. $location->totalQuantity = $totalsByLocation[$location->id] ?? 0;
  18. $location->route = $router->route('view-location', ['location' => $location->id]);
  19. }
  20. return view('locations/index', [
  21. 'locations' => $locations,
  22. 'createAction' => $router->route('show-create-location-form'),
  23. 'canManage' => session()->has('user_id'),
  24. ]);
  25. }
  26. }

Powered by TurnKey Linux.