MachineController.php
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Created by PhpStorm.
* User: machengjun
* Date: 2018/3/22
* Time: 下午3:26
*/
namespace App\Http\Controllers\Api\Business;
use App\Http\Controllers\Controller;
use App\Http\Requests\Business\Api\BusinessLoginRequest;
use App\Repositories\Business\BusinessRepository;
use App\Repositories\Business\MachineRepository;
use App\Repositories\Business\SpotRepository;
use App\Repositories\CustomerRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/**
* Class CustomerController
* @package App\Http\Controllers\Api
*/
class MachineController extends Controller
{
protected $business;
protected $spot;
protected $machine;
public function __construct(BusinessRepository $business, SpotRepository $spot, MachineRepository $machine)
{
$this->business = $business;
$this->spot = $spot;
$this->machine = $machine;
}
public function getSpotMachine(Request $request)
{
Log::info("[businessLogin]params" . json_encode($request->all()));
$spot_id = $request->get('spot_id');
//验证指定景点权限
$this->spot->spotPermission($request->get('user'), $spot_id);
$machines_obj = $this->machine->getSpotMachineList($spot_id);
$response['machine'] = $this->_formatSpotMachine($machines_obj);
return $this->responseSuccess($response);
}
private function _formatSpotMachine($machines_obj)
{
$data = [];
if ($machines_obj != null) {
foreach ($machines_obj as $k => $v) {
$data[$k]['id'] = $v->id;
$data[$k]['mac_no'] = $v->mac_no;
}
}
return $data;
}
}