MachineController.php
2.35 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
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/2/5
* Time: 11:43
*/
namespace App\Http\Controllers\Backend\Machine;
use App\Http\Controllers\Controller;
use App\Modules\Models\Machine\Machine;
use App\Repositories\Backend\Machine\MachineRepository;
use App\Http\Requests\Backend\Machine\StoreMachineRequest;
use App\Http\Requests\Backend\Machine\UpdateMachineRequest;
class MachineController extends Controller
{
private $machine;
public function __construct(MachineRepository $machine)
{
$this->machine = $machine;
}
public function index()
{
// $id=Create_num::add();die();
return view('backend.machine.index');
}
public function create()
{
$business = $this->business();
$spotinfo =$this->spot();
return view('backend.machine.create', [
'spot' => $spotinfo,
'business' => $business,
]);
}
public function store(StoreMachineRequest $request)
{
$this->machine->create(
[
'data' => $request->only(
'lat',
'lng',
'address',
'one_day_price',
'deposit',
'free_time',
'spot_id',
'business_id',
'type'
// , 'hatch_number'
),
]);
return redirect()->route('admin.machine.index')->withFlashSuccess(trans('alerts.backend.machine.created'));
}
public function edit(Machine $machine)
{
$spotinfo =$this->spot();
$userinfo =$this->business();
return view('backend.machine.edit', [
'spot' => $spotinfo,
'user' => $userinfo,
])->with('machine', $machine);
}
public function update(Machine $machine, UpdateMachineRequest $request)
{
$this->machine->change($machine,
$request->only(
'lat',
'lng',
'address',
'one_day_price',
'free_time',
'spot_id',
'business_id',
'type'
// , 'hatch_number'
));
return redirect()->route('admin.machine.index')->withFlashSuccess(trans('alerts.backend.machine.updated'));
}
}