本文整理汇总了PHP中app\models\User::getUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getUserById方法的具体用法?PHP User::getUserById怎么用?PHP User::getUserById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::getUserById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
$friend_id = $request->input("id");
$result = User::getUserById($friend_id);
$user_id = Auth::user()->user_id;
$pusher = App::make('pusher');
$pusher->trigger(strval($friend_id), 'onShowChatBox', ['user' => Auth::user()]);
$messages = new Message();
$result["message"] = $messages->getConversation($user_id, $friend_id, 5);
return $result;
}
示例2: edit
/**
* Edit profile
*
* @param Request $request
* @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function edit(Request $request)
{
$user = User::getUserById(Auth::user()->id);
if ($request->isMethod('post')) {
$rules = ['first_name' => 'required', 'last_name' => 'required', 'position' => 'required', 'phone' => 'phone:AM', 'username' => 'required|unique:users,username,' . $user->id, 'email' => 'required|email|unique:users,email,' . $user->id, 'pass' => 'min:6|max:12', 'pass_confirmation' => 'min:6|max:12|same:pass', 'image' => 'mimes:jpeg,jpg,png'];
Validator::make($request->all(), $rules)->validate();
$user->first_name = $request->input('first_name');
$user->last_name = $request->input('last_name');
$user->position = $request->input('position');
if ($request->has('phone')) {
$user->phone = $request->input('phone');
}
if (!empty($request->file("image"))) {
if (!empty($user->image)) {
if (Storage::exists('uploads/' . $user->image)) {
Storage::delete('uploads/' . $user->image);
}
}
$generated_string = str_random(32);
$file = $request->file("image")->store('uploads');
$new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension();
Storage::move($file, 'uploads/' . $new_file);
$img = Image::make($request->file('image'));
$img->crop(200, 200);
$img->save(storage_path('app/public/uploads/' . $new_file));
$user->image = $new_file;
}
$user->username = $request->input('username');
$user->email = $request->input('email');
$user->notification = $request->has('notification');
if ($request->has('pass')) {
$user->password = Hash::make($request->input('pass'));
}
$user->save();
return redirect('/');
} else {
return view('site.user.edit', compact('user'));
}
}
示例3: getUserById
public function getUserById($id)
{
return User::getUserById($id);
}
示例4: logout
/**
* User logout
*
* @return \Illuminate\Http\RedirectResponse
*/
public function logout()
{
$user = User::getUserById(Auth::user()->id);
$user->online = 0;
$user->save();
Auth::logout();
return redirect()->route('home');
}
示例5: getUserById
public function getUserById($id)
{
return $this->_userModel->getUserById($id);
}
示例6: __toString
public function __toString()
{
// TODO: Implement __toString() method.
//Form: {{username}} {{action}} {{object}}
//Nhuan likes your post
//Tung follow you
$noti = "";
$action = "";
$username = "";
$type = "";
if ($this["type"] == FOLLOW) {
$action = " follow ";
if ($this["objectType"] == USER) {
$type = " you ";
} else {
$board_title = Board::getBoardById($this->objectID)["board_title"];
$type = " your board " . ' ' . $board_title;
}
} else {
$type = "your post ";
if ($this["type"] == LIKE) {
$action = " liked ";
} else {
if ($this["type"] == COMMENT) {
$action = " comment on ";
} else {
if ($this["type"] == PIN) {
$action = " pinned ";
}
}
}
}
if (isset($this["sender_id"])) {
$username = User::getUserById($this["sender_id"])["name"];
} else {
$username = $this["sender_string"];
}
$noti = $username . $action . $type;
return $noti;
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$user = User::getUserById($id);
$user["name"] = $request->input("name");
$user["description"] = $request->input("description");
$user["username"] = $request->input('username');
$user["email"] = $request->input('email');
if ($request->input("avatar_link") != null) {
$user["avatar_link"] = $request->input("avatar_link");
}
$result = $user->save();
return response()->json(["result" => $result]);
}
示例8: delete
/**
* Delete user
*
* @param Request $request
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function delete(Request $request, $id = 0)
{
if ($request->isMethod('post')) {
foreach ($request->input('users') as $user) {
$user = User::getUserById($user);
if (!empty($user)) {
if (!empty($user->image)) {
if (Storage::exists('uploads/' . $user->image)) {
Storage::delete('uploads/' . $user->image);
}
}
$user->delete();
}
}
} else {
$user = User::getUserById($id);
if (!empty($user)) {
if (!empty($user->image)) {
if (Storage::exists('uploads/' . $user->image)) {
Storage::delete('uploads/' . $user->image);
}
}
$user->delete();
}
return redirect()->back();
}
}