Skip to content

Commit 875f938

Browse files
committed
working react
1 parent 84e5b00 commit 875f938

File tree

2,216 files changed

+243030
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,216 files changed

+243030
-45
lines changed

app/Http/Controllers/Auth/LoginController.php

+20-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ public function index()
5858
return view('admin.login.index');
5959
}
6060

61+
public function index1()
62+
{
63+
$company = Company::all()->count();
64+
if ($company == 0) {
65+
return view('admin.create.step1');
66+
}
67+
return view('react-admin.login.index');
68+
}
69+
70+
71+
6172
public function postCreateStep2()
6273
{
6374

@@ -148,7 +159,7 @@ public function login(Request $request)
148159
if (Auth::attempt(['username' => $request->username, 'password' => $request->password, 'status' => 1])) {
149160

150161

151-
162+
152163

153164
$staff = DB::table('staffs')
154165
->join('users', 'users.staffId', '=', 'staffs.staffId')
@@ -160,9 +171,16 @@ public function login(Request $request)
160171

161172
$staff = $staff[0];
162173

163-
return redirect()->intended('/system/dashboard')->with('staff', $staff);
174+
//laravel
175+
// return redirect()->intended('/system/dashboard')->with('staff', $staff);
176+
//laravel
177+
178+
179+
return redirect()->intended('/react/dashboard')->with('staff', $staff);
164180
} else {
181+
//laravel
165182
return redirect()->back()->with('msg', 'Your username or password incorrect');
183+
//laravel
166184
}
167185
}
168186

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\React;
4+
5+
use Illuminate\Http\Request;
6+
use Validator;
7+
use App\Http\Controllers\Controller;
8+
use App\AgencyType;
9+
use App\Agency;
10+
use Illuminate\Validation\Rule;
11+
12+
class AgencyController extends Controller
13+
{
14+
/**
15+
* Display a listing of the resource.
16+
*
17+
* @return \Illuminate\Http\Response
18+
*/
19+
public function index()
20+
{
21+
$agency = Agency::join('Agency_Types', 'Agencies.AgencyTypeId', '=', 'Agency_Types.AgencyTypeId')
22+
->select('*')->get();
23+
return View('admin.agency.index', compact('agency'));
24+
}
25+
26+
/**
27+
* Show the form for creating a new resource.
28+
*
29+
* @return \Illuminate\Http\Response
30+
*/
31+
public function create()
32+
{
33+
$type = AgencyType::where('status', '<>', -1)->get();
34+
return View('admin.agency.create', compact('type'));
35+
}
36+
37+
/**
38+
* Store a newly created resource in storage.
39+
*
40+
* @param \Illuminate\Http\Request $request
41+
* @return \Illuminate\Http\Response
42+
*/
43+
public function store(Request $request)
44+
{
45+
$attributes = self::validateAgency($request);
46+
47+
$attributes['tCOm'] = 0;
48+
$attributes['paid'] = 0;
49+
$attributes['amountDue'] = 0;
50+
51+
// dd($attributes);
52+
Agency::create($attributes);
53+
54+
return redirect('/system/agency');
55+
}
56+
57+
/**
58+
* Display the specified resource.
59+
*
60+
* @param int $id
61+
* @return \Illuminate\Http\Response
62+
*/
63+
public function show($id)
64+
{
65+
//
66+
}
67+
68+
/**
69+
* Show the form for editing the specified resource.
70+
*
71+
* @param int $id
72+
* @return \Illuminate\Http\Response
73+
*/
74+
public function edit($id)
75+
{
76+
$agency = Agency::where('agencyId', $id)->join('Agency_Types', 'Agencies.AgencyTypeId', '=', 'Agency_Types.AgencyTypeId')
77+
->select('*')->get();
78+
79+
$type = AgencyType::all();
80+
81+
return view('admin.agency.edit', compact('agency', 'type'));
82+
}
83+
84+
/**
85+
* Update the specified resource in storage.
86+
*
87+
* @param \Illuminate\Http\Request $request
88+
* @param int $id
89+
* @return \Illuminate\Http\Response
90+
*/
91+
public function update(Request $request, $id)
92+
{
93+
$attributes = self::validateAgency($request);
94+
95+
$agency = Agency::where('agencyId', $id)->firstOrFail();
96+
request()->validate([
97+
'email' => ['required', 'min:12', 'max:30', 'unique:agencies,email,' . $agency->email . ',email']
98+
]);
99+
100+
Agency::where('agencyId', $id)->update($attributes);
101+
102+
return redirect('/system/agency');
103+
}
104+
105+
/**
106+
* Remove the specified resource from storage.
107+
*
108+
* @param int $id
109+
* @return \Illuminate\Http\Response
110+
*/
111+
public function destroy($id)
112+
{
113+
Agency::where('agencyId', $id)->delete();
114+
115+
return redirect('/system/agency');
116+
}
117+
118+
public function validateAgency($request)
119+
{
120+
$attributes = request()->validate([
121+
'agency' => 'required|min:5|max:30|unique:agencies',
122+
'phone' => 'required|min:9|max:30|unique:agencies',
123+
'email' => ['required', 'min:12', 'max:30', 'unique:agencies'],
124+
'address' => 'required|min:10:max:191|unique:agencies',
125+
'agencyTypeId' => 'required'
126+
]);
127+
128+
$agencyType = AgencyType::where('agencyType', $request->agencyTypeId)->firstOrFail();
129+
$attributes['agencyTypeId'] = $agencyType->agencyTypeId;
130+
131+
return $attributes;
132+
}
133+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\React;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
use App\AgencyType;
8+
use App\Agency;
9+
use Illuminate\Validation\Rule;
10+
11+
class AgencyTypeController extends Controller
12+
{
13+
/**
14+
* Display a listing of the resource.
15+
*
16+
* @return \Illuminate\Http\Response
17+
*/
18+
public function index($getTrash = false)
19+
{
20+
21+
22+
if ($getTrash) {
23+
$agencyType = AgencyType::all();
24+
25+
$url = url('/system/agencyType/');
26+
27+
$checkTrash = 'checked';
28+
} else {
29+
$agencyType = AgencyType::where('status', '<>', -1)->get();
30+
$url = url('/system/agencyType/trash');
31+
32+
33+
$checkTrash = '';
34+
}
35+
36+
37+
38+
39+
$data = array(
40+
'agencyType' => $agencyType,
41+
'trashUrl' => $url,
42+
'checkTrash' => $checkTrash
43+
);
44+
45+
46+
47+
48+
return View('admin.agencyType.index', $data);
49+
}
50+
51+
/**
52+
* Show the form for creating a new resource.
53+
*
54+
* @return \Illuminate\Http\Response
55+
*/
56+
public function create()
57+
{
58+
return View('admin.agencyType.create');
59+
}
60+
61+
/**
62+
* Store a newly created resource in storage.
63+
*
64+
* @param \Illuminate\Http\Request $request
65+
* @return \Illuminate\Http\Response
66+
*/
67+
public function store(Request $request)
68+
{
69+
70+
$this->validate($request, [
71+
'type' => 'required|unique:agency_types,agencyType'
72+
73+
]);
74+
75+
$agencyType = new AgencyType();
76+
77+
78+
$agencyType->agencyType = $request->type;
79+
80+
$agencyType->save();
81+
82+
83+
return redirect('/system/agencyType');
84+
}
85+
86+
/**
87+
* Display the specified resource.
88+
*
89+
* @param int $id
90+
* @return \Illuminate\Http\Response
91+
*/
92+
public function show($id)
93+
{
94+
//
95+
}
96+
97+
/**
98+
* Show the form for editing the specified resource.
99+
*
100+
* @param int $id
101+
* @return \Illuminate\Http\Response
102+
*/
103+
public function edit($id)
104+
{
105+
106+
$agencyType = AgencyType::where('agencyTypeId', $id)->get()[0];
107+
108+
109+
110+
111+
$data = [
112+
'agencyType' => $agencyType
113+
114+
];
115+
116+
117+
return View('admin.agencyType.edit', $data);
118+
}
119+
120+
/**
121+
* Update the specified resource in storage.
122+
*
123+
* @param \Illuminate\Http\Request $request
124+
* @param int $id
125+
* @return \Illuminate\Http\Response
126+
*/
127+
public function update(Request $request, $id)
128+
{
129+
$this->validate($request, [
130+
'agencyTypeId' => [
131+
Rule::unique('agency_types')->ignore($id, 'agencyTypeId'),
132+
],
133+
]);
134+
135+
136+
AgencyType::where('agencyTypeId', $id)->update(array(
137+
'agencyType' => $request->type,
138+
139+
));
140+
return redirect('/system/agencyType');
141+
}
142+
143+
/**
144+
* Remove the specified resource from storage.
145+
*
146+
* @param int $id
147+
* @return \Illuminate\Http\Response
148+
*/
149+
public function destroy($id)
150+
{
151+
//
152+
}
153+
154+
155+
public function setStatus($id, $status)
156+
{
157+
158+
$status = $status == 'trash' ? -1 : 1;
159+
160+
AgencyType::where('agencyTypeId', $id)->update(array(
161+
'status' => $status,
162+
));
163+
164+
return redirect()->back();
165+
}
166+
}

0 commit comments

Comments
 (0)