mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
fix getting user from UserRepository by custom property
This commit is contained in:
parent
f5dd7c8c5f
commit
4276b56e0c
@ -12,7 +12,7 @@ class HomeController extends Controller
|
||||
{
|
||||
public function index(UserRepository $users, Request $request)
|
||||
{
|
||||
return view('index')->with('user', $users->get(session('uid')));
|
||||
return view('index')->with('user', $users->getCurrentUser());
|
||||
}
|
||||
|
||||
public function locale($lang, Request $request)
|
||||
|
@ -20,7 +20,7 @@ class UserRepository extends Repository
|
||||
if ($type == "uid") {
|
||||
return Arr::has($this->items, $identification);
|
||||
} else {
|
||||
return Arr::where((array) $this->items, function($key, $value) use ($identification, $type) {
|
||||
return (bool) Arr::where((array) $this->items, function($key, $value) use ($identification, $type) {
|
||||
if (property_exists($value, $type))
|
||||
return false;
|
||||
|
||||
@ -56,9 +56,20 @@ class UserRepository extends Repository
|
||||
$this->set($user->uid, $user);
|
||||
return $user;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return Arr::get($this->items, $identification, null);
|
||||
$result = Arr::where((array) $this->items, function($key, $value) use ($identification, $type) {
|
||||
if (property_exists($value, $type))
|
||||
return false;
|
||||
|
||||
return ($value->$type == $identification);
|
||||
});
|
||||
|
||||
// return first element
|
||||
reset($result);
|
||||
return current($result);
|
||||
}
|
||||
|
||||
public function getCurrentUser()
|
||||
|
Loading…
Reference in New Issue
Block a user