本文整理汇总了PHP中app\Message::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::findOrFail方法的具体用法?PHP Message::findOrFail怎么用?PHP Message::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::findOrFail方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id)
{
$message = Message::findOrFail($id);
MessageReply::where('sender', '<>', \Auth::user()->id)->where('msg_id', $id)->where('is_read', 0)->update(['is_read' => 1]);
$dataView = ['message' => $message];
return view('mr.inbox.show', $dataView);
}
示例2: delete
public function delete($id)
{
$message = Message::findOrFail($id);
$message->delete();
// redirect
\Session::flash('flash_message', 'Successfully deleted the message');
return redirect('admin');
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$message = Message::findOrFail($id);
$message->delete();
$message = trans('messages.message_successfully_deleted');
Flash::error($message);
return redirect()->route('admin.messages.index');
}
示例4: readMessage
public function readMessage(Request $request)
{
$id = $request->input('id');
//dd($id);
$message = Message::findOrFail($id);
//dd($messages);
return view('admin.readmessage')->with('message', $message);
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$m = App\Message::findOrFail($id);
if (Auth::id() != $m->user_id) {
throw new Exception('Access denied');
}
$m->forceDelete();
return ['deleted' => true];
}
示例6: update
public function update(Request $request, $id)
{
$validator = Validator::make($request->all(), ['creator' => 'required', 'email' => 'required', 'body' => 'required']);
if ($validator->fails()) {
return response()->json($validator->errors()->all(), 422);
}
$message = Message::find($id);
if (count($message) > 0) {
Message::findOrFail($id)->update($request->all());
return response()->json($request->all());
}
abort(204);
}
示例7: show
public function show($id)
{
$message = Message::findOrFail($id);
$answers = Answer::paginate(10);
if ($message->to_user_id == \Auth::id() || $message->user_id == \Auth::id()) {
if ($message->to_user_id == \Auth::id()) {
Message::where('id', $id)->update(['read' => 1]);
}
return view('message.show', compact('message', 'answers'));
} else {
return back();
}
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function destroy($id, Request $request)
{
$message = Message::findOrFail($id);
if ($request->user()->can('delete', $message)) {
$message->delete();
return back()->withNotification("Message Deleted")->withType('success');
}
return back()->withNotification("Sorry! You are not authorized.")->withType('danger');
}
示例9: reply
public function reply($id)
{
$message = Message::findOrFail($id);
return view('message.compose', compact('message'));
}
示例10: readMessage
public function readMessage(Request $request)
{
$message = Message::findOrFail($request->get('id'));
$r = $message->update(array('isread' => 1));
}
示例11: markAsRead
public function markAsRead(Request $request)
{
if (Auth::check()) {
$user = Auth::user();
$id = $request->input("message_id");
$msg = Message::findOrFail($id);
$msg->read = '0';
$msg->save();
$message = Message::where(["read" => '1', "reader" => $user->id])->get();
# get the unread messages for current user
$result = [];
foreach ($message as $msg) {
$temp = [];
$temp['id'] = $msg->id;
$temp['read'] = $msg->read;
$temp['reader'] = $msg->reader;
$result[] = $temp;
}
return $result;
} else {
Auth::logout();
return redirect()->route('home');
}
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$messageObj = Message::findOrFail($id);
return view('message.reply', compact('messageObj'));
}
示例13: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$message = Message::findOrFail($id);
$message->delete();
return view('pages.home')->with('status', '文章删除成功');
}
示例14: update
/**
* Update the specified resource in storage after.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(messageRequest $request, $id)
{
// $input = $request->get('content');
$input = $request->input('content');
$messages = Message::findOrFail($id);
$messages->content = $input;
$messages->save();
//notification
\Session::flash('flash_edit', 'Your message has been edited.');
return redirect('main');
}