CustomerAddressController.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Http\Controllers\Admin\Customers;
  3. use App\Shop\Addresses\Repositories\Interfaces\AddressRepositoryInterface;
  4. use App\Shop\Countries\Repositories\Interfaces\CountryRepositoryInterface;
  5. use App\Http\Controllers\Controller;
  6. use App\Shop\Provinces\Repositories\Interfaces\ProvinceRepositoryInterface;
  7. class CustomerAddressController extends Controller
  8. {
  9. /**
  10. * @var AddressRepositoryInterface
  11. */
  12. private $addressRepo;
  13. /**
  14. * @var CountryRepositoryInterface
  15. */
  16. private $countryRepo;
  17. /**
  18. * @var ProvinceRepositoryInterface
  19. */
  20. private $provinceRepo;
  21. /**
  22. * CustomerAddressController constructor.
  23. * @param AddressRepositoryInterface $addressRepository
  24. * @param CountryRepositoryInterface $countryRepository
  25. * @param ProvinceRepositoryInterface $provinceRepository
  26. */
  27. public function __construct(
  28. AddressRepositoryInterface $addressRepository,
  29. CountryRepositoryInterface $countryRepository,
  30. ProvinceRepositoryInterface $provinceRepository
  31. ) {
  32. $this->addressRepo = $addressRepository;
  33. $this->countryRepo = $countryRepository;
  34. $this->provinceRepo = $provinceRepository;
  35. }
  36. /**
  37. * Show the customer's address
  38. *
  39. * @param int $customerId
  40. * @param int $addressId
  41. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  42. */
  43. public function show(int $customerId, int $addressId)
  44. {
  45. return view('admin.addresses.customers.show', [
  46. 'address' => $this->addressRepo->findAddressById($addressId),
  47. 'customerId' => $customerId
  48. ]);
  49. }
  50. /**
  51. * Show the edit form
  52. *
  53. * @param int $customerId
  54. * @param int $addressId
  55. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  56. */
  57. public function edit(int $customerId, int $addressId)
  58. {
  59. $this->countryRepo->findCountryById(env('COUNTRY_ID', 1));
  60. $province = $this->provinceRepo->findProvinceById(1);
  61. return view('admin.addresses.customers.edit', [
  62. 'address' => $this->addressRepo->findAddressById($addressId),
  63. 'countries' => $this->countryRepo->listCountries(),
  64. 'provinces' => $this->countryRepo->findProvinces(),
  65. 'cities' => $this->provinceRepo->listCities($province->id),
  66. 'customerId' => $customerId
  67. ]);
  68. }
  69. }