More model updates to more places than I anticipated.

This probably broke a lot of things.
This commit is contained in:
Dane Everitt 2017-02-09 17:43:54 -05:00
parent 0d61417814
commit 4f61637284
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
21 changed files with 339 additions and 433 deletions

View file

@ -45,35 +45,11 @@ class UserController extends Controller
//
}
// @TODO: implement nicolaslopezj/searchable to clean up this disaster.
public function getIndex(Request $request)
{
$query = User::select('users.*');
if ($request->input('filter') && ! is_null($request->input('filter'))) {
preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches);
foreach ($matches[0] as $match) {
$match = str_replace('"', '', $match);
if (strpos($match, ':')) {
list($field, $term) = explode(':', $match);
$query->orWhere($field, 'LIKE', '%' . $term . '%');
} else {
$query->where('email', 'LIKE', '%' . $match . '%');
$query->orWhere([
['uuid', 'LIKE', '%' . $match . '%'],
['root_admin', 'LIKE', '%' . $match . '%'],
]);
}
}
}
try {
$users = $query->paginate(20);
} catch (\Exception $ex) {
Alert::warning('There was an error with the search parameters provided.');
$users = User::all()->paginate(20);
}
return view('admin.users.index', [
'users' => $users,
'users' => User::paginate(25),
]);
}
@ -85,12 +61,7 @@ class UserController extends Controller
public function getView(Request $request, $id)
{
return view('admin.users.view', [
'user' => User::findOrFail($id),
'servers' => Server::select('servers.*', 'nodes.name as nodeName', 'locations.long as location')
->join('nodes', 'servers.node_id', '=', 'nodes.id')
->join('locations', 'nodes.location', '=', 'locations.id')
->where('owner', $id)
->get(),
'user' => User::with('servers.node')->findOrFail($id),
]);
}
@ -162,10 +133,6 @@ class UserController extends Controller
public function getJson(Request $request)
{
foreach (User::select('email')->get() as $user) {
$resp[] = $user->email;
}
return $resp;
return User::select('email')->get()->pluck('email');
}
}