# CompanySettingController
app / Http / Controllers / CompanySettingController.php
# show
public function show($id)
{
if (!Auth::user()->can('View CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
return view('CompanySetting.show', ['companySetting'=>$companySetting]);
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# edit
public function edit($id)
{
if (!Auth::user()->can('Edit CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
return view('CompanySetting.edit', ['companySetting'=>$companySetting]);
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# update
public function update(UpdateCompanySettingRequest $request, $id)
{
if (!Auth::user()->can('Edit CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
$companySetting->company_name = $request->name;
$companySetting->company_phone = $request->phone;
$companySetting->company_email = $request->email;
$companySetting->company_address = $request->address;
$companySetting->office_start_time = $request->ost;
$companySetting->office_end_time = $request->oet;
$companySetting->break_start_time = $request->bst;
$companySetting->break_end_time = $request->bet;
$companySetting->update();
return redirect()
->route('company.show',$companySetting->id)
->with('update', $companySetting->company_name.' is successfully updated.');
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Code Overview
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreCompanySettingRequest;
use App\Http\Requests\UpdateCompanySettingRequest;
use App\Models\CompanySetting;
use Illuminate\Support\Facades\Auth;
class CompanySettingController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return abort('404');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return abort('404');
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\StoreCompanySettingRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreCompanySettingRequest $request)
{
return abort('404');
}
/**
* Display the specified resource.
*
* @param \App\Models\CompanySetting $companySetting
* @return \Illuminate\Http\Response
*/
public function show($id)
{
if (!Auth::user()->can('View CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
return view('CompanySetting.show', ['companySetting'=>$companySetting]);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\CompanySetting $companySetting
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
if (!Auth::user()->can('Edit CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
return view('CompanySetting.edit', ['companySetting'=>$companySetting]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\UpdateCompanySettingRequest $request
* @param \App\Models\CompanySetting $companySetting
* @return \Illuminate\Http\Response
*/
public function update(UpdateCompanySettingRequest $request, $id)
{
if (!Auth::user()->can('Edit CompanySetting')){
return abort('404');
}
$companySetting = CompanySetting::findOrfail($id);
$companySetting->company_name = $request->name;
$companySetting->company_phone = $request->phone;
$companySetting->company_email = $request->email;
$companySetting->company_address = $request->address;
$companySetting->office_start_time = $request->ost;
$companySetting->office_end_time = $request->oet;
$companySetting->break_start_time = $request->bst;
$companySetting->break_end_time = $request->bet;
$companySetting->update();
return redirect()
->route('company.show',$companySetting->id)
->with('update', $companySetting->company_name.' is successfully updated.');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\CompanySetting $companySetting
* @return \Illuminate\Http\Response
*/
public function destroy(CompanySetting $companySetting)
{
return abort('404');
}
}
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
104
105
106
107
108
109
110
111
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
104
105
106
107
108
109
110
111