本文整理匯總了PHP中Reply::getRepliableCate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reply::getRepliableCate方法的具體用法?PHP Reply::getRepliableCate怎麽用?PHP Reply::getRepliableCate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Reply
的用法示例。
在下文中一共展示了Reply::getRepliableCate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getRelatedRelpies
public function getRelatedRelpies()
{
$cate = Input::get('cate', '');
$id = Input::get('id', 0);
$last_id = Input::get('last_id', 0);
$per_page = Input::get('per_page', 30);
$mapping = Reply::getRepliableCate();
try {
if (array_key_exists($cate, $mapping)) {
$cate = $mapping[$cate];
} else {
throw new Exception("需要傳入有效的評論分類", 2001);
}
$query = Reply::with(['user'])->select('replies.*')->where('replies.status', '=', 1);
if ($last_id) {
$query = $query->where('replies.id', '<', $last_id);
}
$query = $query->join('repliables', function ($q) use($cate, $id) {
$q->on('repliables.reply_id', '=', 'replies.id')->where('repliables.repliable_type', '=', $cate)->where('repliables.repliable_id', '=', $id);
});
$list = $query->orderBy('replies.id', 'DESC')->paginate($per_page);
$data = [];
foreach ($list as $key => $reply) {
$data[] = $reply->showInList();
}
$re = Tools::reTrue('獲取評論成功', $data);
} catch (Exception $e) {
$re = Tools::reFalse($e->getCode(), '獲取評論失敗:' . $e->getMessage());
}
return Response::json($re);
}