Controller.php
2.04 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace App\Http\Controllers;
use App\Modules\Models\Machine\Machine;
use App\Modules\Models\Spot\Spot;
use App\Modules\Models\Explain\Explain;
use App\Modules\Models\Business\Business;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function responseSuccess($params = array())
{
$responseArray = array_merge($params, ["error_code"=>0]);
return response()->json($responseArray);
}
public function responseSuccessWithObject($obj)
{
if ($obj)
{
if (!is_array($obj))
{
$obj = $obj->toArray();
}
}
else
{
$obj = array();
}
$obj['error_code'] = 0;
return response()->json($obj);
}
public function business()
{
$busines= Business::select('id','business_name')->get()->toArray();
$info_business =[];
foreach ($busines as $busine){
$info_business[$busine['id']]=$busine['business_name'];
}
return $info_business;
}
public function spot()
{
$spot= Spot::select('id','spotname')->get()->toArray();
$info_spot =[];
foreach ($spot as $spots){
$info_spot[$spots['id']]=$spots['spotname'];
}
return $info_spot;
}
public function explain()
{
$info =Explain::select('id','name')->select()->get()->toArray();
$be =[];
foreach ($info as $infos){
$be[$infos['id']]=$infos['name'];
}
return $be;
}
public function mac_no()
{
$num = Machine::select('id','mac_no')->get()->toArray();
$mac_no =[];
foreach ($num as $nums) {
$mac_no[$nums['id']]= $nums['mac_no'];
}
return $mac_no;
}
}