Passed
Push — master ( 4a884d...c9d1fc )
by Jeff
12:14
created

StateCityController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Front\Addresses;
4
5
use App\Http\Controllers\Controller;
6
use App\Shop\States\Repositories\StateRepository;
7
use App\Shop\States\Repositories\StateRepositoryInterface;
8
9
class StateCityController extends Controller
10
{
11
    private $stateRepo;
12
13
    /**
14
     * StateCityController constructor.
15
     *
16
     * @param StateRepositoryInterface $stateRepository
17
     */
18
    public function __construct(StateRepositoryInterface $stateRepository)
19
    {
20
        $this->stateRepo = $stateRepository;
21
    }
22
23
    /**
24
     * @param $state_code
25
     *
26
     * @return \Illuminate\Http\JsonResponse
27
     */
28
    public function index($state_code)
29
    {
30
        $state = $this->stateRepo->findOneBy(compact('state_code'));
31
32
        $stateRepo = new StateRepository($state);
33
        $data = $stateRepo->listCities();
34
35
        return response()->json(compact('data'));
36
    }
37
}