当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::findOrFail方法代码示例

本文整理汇总了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);
 }
开发者ID:m-gamal,项目名称:crm,代码行数:7,代码来源:InboxController.php

示例2: delete

 public function delete($id)
 {
     $message = Message::findOrFail($id);
     $message->delete();
     // redirect
     \Session::flash('flash_message', 'Successfully deleted the message');
     return redirect('admin');
 }
开发者ID:slaleye,项目名称:securechat,代码行数:8,代码来源:AdminMessageController.php

示例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');
 }
开发者ID:jrafaelca,项目名称:infrea,代码行数:14,代码来源:MessagesController.php

示例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);
 }
开发者ID:mucyomiller,项目名称:market,代码行数:8,代码来源:AdminController.php

示例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];
 }
开发者ID:acidron,项目名称:reactjs_demo,代码行数:15,代码来源:MessageCtrl.php

示例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);
 }
开发者ID:blrik,项目名称:CRUD-Vue-JS,代码行数:13,代码来源:ApiMessageController.php

示例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();
     }
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:13,代码来源:MessageController.php

示例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');
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:16,代码来源:MessagesController.php

示例9: reply

 public function reply($id)
 {
     $message = Message::findOrFail($id);
     return view('message.compose', compact('message'));
 }
开发者ID:kobeuu,项目名称:bpb-sf,代码行数:5,代码来源:MessagesController.php

示例10: readMessage

 public function readMessage(Request $request)
 {
     $message = Message::findOrFail($request->get('id'));
     $r = $message->update(array('isread' => 1));
 }
开发者ID:Panfen,项目名称:mango,代码行数:5,代码来源:HomeController.php

示例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');
     }
 }
开发者ID:PrakharSrivastav,项目名称:bookbarterclub,代码行数:24,代码来源:MessageController.php

示例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'));
 }
开发者ID:andreea-bucur,项目名称:GuestBook,代码行数:11,代码来源:MessageController.php

示例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', '文章删除成功');
 }
开发者ID:kuzoncby,项目名称:CRUD-Laravel-5-Message-Board,代码行数:12,代码来源:MessageController.php

示例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');
 }
开发者ID:johnny102403,项目名称:SD_Teamwork3,代码行数:18,代码来源:MainController.php


注:本文中的app\Message::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。