當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。