本文整理汇总了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'));
}
示例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());
}
示例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);
}
}
}
示例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);
}
示例5: destroy
public function destroy($id)
{
$topic = Topic::findOrFail($id);
$topic->delete();
Flash::success(lang('Operation succeeded.'));
return Redirect::route('topics.index');
}
示例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');
}
示例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';
}
示例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);
}
示例9: find
public function find($id)
{
return Topic::findOrFail($id);
}
示例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');
}
}