CountryStateController.php 932 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Controllers\Front\Addresses;
  3. use App\Http\Controllers\Controller;
  4. use App\Shop\Countries\Repositories\CountryRepository;
  5. use App\Shop\Countries\Repositories\Interfaces\CountryRepositoryInterface;
  6. class CountryStateController extends Controller
  7. {
  8. private $countryRepo;
  9. /**
  10. * CountryStateController constructor.
  11. *
  12. * @param CountryRepositoryInterface $countryRepository
  13. */
  14. public function __construct(CountryRepositoryInterface $countryRepository)
  15. {
  16. $this->countryRepo = $countryRepository;
  17. }
  18. /**
  19. * @param $countryId
  20. *
  21. * @return \Illuminate\Http\JsonResponse
  22. */
  23. public function index($countryId)
  24. {
  25. $country = $this->countryRepo->findCountryById($countryId);
  26. $countryRepo = new CountryRepository($country);
  27. $data = $countryRepo->listStates();
  28. return response()->json(compact('data'));
  29. }
  30. }