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


PHP Topic::findOrFail方法代码示例

本文整理汇总了PHP中Topic::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::findOrFail方法的具体用法?PHP Topic::findOrFail怎么用?PHP Topic::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Topic的用法示例。


在下文中一共展示了Topic::findOrFail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reply_list

 public function reply_list()
 {
     $topic_id = Input::get('topic_id');
     $topic = Topic::findOrFail($topic_id);
     $replies = $topic->getRepliesWithLimit(10);
     $topic_title = $topic->title;
     return View::make('pages.reply_list', compact('replies', 'topic_title'));
 }
开发者ID:azonwan,项目名称:pingju,代码行数:8,代码来源:PagesController.php

示例2: answer

 public function answer($tid = null)
 {
     if (empty($tid)) {
         return Response::json(['error' => true, 'message' => 'No topic id'], 404);
     }
     try {
         $t = Topic::findOrFail($tid);
     } catch (Exception $e) {
         return Response::json(['error' => true, 'message' => 'Topic not found'], 404);
     }
     $data = Input::only(['author', 'message']);
     $new = new TopicAnswer();
     $new->tid = $tid;
     $new->fill($data);
     $new->place = Input::has('api') ? 'api' : 'web';
     $new->save();
     $new->created_at->format('d-m-Y');
     return Response::json($new->toArray());
 }
开发者ID:roffjump,项目名称:forum,代码行数:19,代码来源:TopicController.php

示例3: show

 public function show($tid = 'all')
 {
     if ($tid == 'all') {
         if (Input::has('answers')) {
             $topics = Topic::with('answers')->get()->toArray();
         } else {
             $topics = Topic::all();
         }
         return Response::make(['success' => true, 'data' => $topics]);
     } else {
         try {
             $topic = Topic::findOrFail($tid);
             $topic->answers = $topic->answers->toArray();
             return Response::make(['success' => true, 'data' => $topic]);
         } catch (Exception $e) {
             return Response::make(['error' => true, 'message' => 'Sorry but that topic cannot be found!', 'data' => null], 404);
         }
     }
 }
开发者ID:roffjump,项目名称:forum,代码行数:19,代码来源:TopicRestApiController.php

示例4: create

 public function create()
 {
     foreach ($this->required as $required => $strlen) {
         if (!Input::has('tid')) {
             return Response::make(['error' => 'You must introduce a topic id to answer'], 404);
         }
         if (!Input::has($required) || strlen(Input::get($required)) < $strlen) {
             return Response::make(['error' => 'You must introduce a ' . $required . ' with ' . $strlen . ' of length...'], 404);
         }
     }
     $tid = Input::get('tid');
     try {
         $topic = Topic::findOrFail($tid);
     } catch (Exception $e) {
         return Response::make(['error' => true, 'message' => 'Sorry but that topic cannot be found!', 'data' => null], 404);
     }
     $new = new TopicAnswer();
     $new->tid = $tid;
     $new->fill(Input::only(['author', 'message']));
     $new->place = $this->place;
     $new->save();
     return Response::make(['success' => 'You just created a new answer!', 'answer' => $new->toArray(), 'topic' => $new->topic->toArray()], 404);
 }
开发者ID:roffjump,项目名称:forum,代码行数:23,代码来源:TopicAnswerRestApiController.php

示例5: destroy

 public function destroy($id)
 {
     $topic = Topic::findOrFail($id);
     $topic->delete();
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('topics.index');
 }
开发者ID:azonwan,项目名称:pingju,代码行数:7,代码来源:TopicsController.php

示例6: destroy

 public function destroy($id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $topic->delete();
     Flash::success(lang('Operation succeeded.'));
     return Redirect::route('topics.index');
 }
开发者ID:adminrt,项目名称:phphub,代码行数:8,代码来源:TopicsController.php

示例7: NotifyTest

 public function NotifyTest()
 {
     if (!Auth::check()) {
         return 'login?';
     }
     $user = Auth::user();
     $Myfans = Fanssystem::FindMyFans($user->id);
     $topic = Topic::findOrFail(6);
     App::make('Phphub\\Notification\\Notifier')->newTopicsNotify($user, $topic);
     return 'ok';
 }
开发者ID:fcode520,项目名称:phphub,代码行数:11,代码来源:TopicsController.php

示例8: sink

 public function sink($id)
 {
     $topic = Topic::findOrFail($id);
     $topic->order >= 0 ? $topic->decrement('order', 1) : $topic->increment('order', 1);
     return Redirect::route('topics.show', $topic->id);
 }
开发者ID:damko,项目名称:phphub,代码行数:6,代码来源:TopicsController.php

示例9: find

 public function find($id)
 {
     return Topic::findOrFail($id);
 }
开发者ID:pedrofornaza,项目名称:roundtable,代码行数:4,代码来源:TopicRepository.php

示例10: destroy

 public function destroy($id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     $topic->delete();
     Flash::success(lang('Operation succeeded.'));
     $url = Request::getRequestUri();
     if (stripos($url, 'account') == false) {
         return Redirect::route('topics.index');
     } else {
         return Redirect::route('ac_topices');
     }
 }
开发者ID:xiao-hu00,项目名称:phphub,代码行数:13,代码来源:TopicsController.php


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