Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

35 wiersze
948B

  1. <?php
  2. namespace App\Http\Controllers\Locations;
  3. use App\Models\Location;
  4. use Framework\Routing\Router;
  5. class CreateLocationController
  6. {
  7. public function handle(Router $router)
  8. {
  9. if (!session()->has('user_id')) {
  10. return redirect($router->route('show-register-form'));
  11. }
  12. secure();
  13. $data = validate($_POST, [
  14. 'code' => ['required'],
  15. 'name' => ['required'],
  16. 'description' => [],
  17. 'capacity' => ['positive_integer'],
  18. ], 'create_location_errors');
  19. $location = new Location();
  20. $location->code = $data['code'];
  21. $location->name = $data['name'];
  22. $location->description = $data['description'] ?? '';
  23. $location->capacity = !empty($data['capacity']) ? (int) $data['capacity'] : null;
  24. $location->save();
  25. return redirect($router->route('view-location', ['location' => $location->id]));
  26. }
  27. }

Powered by TurnKey Linux.