本文整理汇总了PHP中app\Comment::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::select方法的具体用法?PHP Comment::select怎么用?PHP Comment::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::select方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comments
public function comments(Request $request)
{
$comments = Comment::select('comment_body', 'post_id', 'created_at')->orderBy('post_id')->get();
$posts = [];
foreach ($comments as $i => $comment) {
$associated_posts = Post::select('post_title')->where('id', $comment->post_id)->value('post_title');
$posts[$comment->post_id]["post_title"] = $associated_posts;
$posts[$comment->post_id]["comments"][] = ["created_at" => $comment->created_at, "body" => $comment->comment_body];
}
return view('admin.comments', ['posts' => $posts]);
}
示例2: index
public function index()
{
$latestArticles = Article::latest()->take(6)->get();
$latestPosts = Post::latest()->take(6)->get();
$latestProblems = Problem::latest()->take(6)->get();
$latestGroups = Group::latest()->take(6)->get();
$latestUsers = User::latest()->take(6)->get();
$ratedUsers = User::orderBy('rate', 'desc')->take(6)->get();
$chartDatas = Comment::select([DB::raw('DATE(created_at) AS date'), DB::raw('COUNT(id) AS count')])->groupBy('date')->orderBy('date', 'ASC')->get()->toArray();
return view('admin.dashboard.index', compact('latestArticles', 'latestPosts', 'latestProblems', 'latestGroups', 'latestUsers', 'ratedUsers', 'chartDatas'))->with(['title' => 'Admin Dashboard Panel']);
}
示例3: contributionList
/**
* 贡献记录
*
* @param Request $request
* @return Response
*/
public function contributionList(Request $request)
{
// get params
$isFlush = $request::get('flush');
// cache it
$cacheKey = Comment::CONTRIBUTION_CACHE_KEY;
$archive = Cache::get($cacheKey);
if ($isFlush or empty($archive)) {
$comments = Comment::select('meta', 'date', 'ext_program_date')->agreed()->orderBy('id', 'DESC')->get();
$archive = (string) View::make('about.contribution.archive')->with('title', '贡献记录')->with('comments', $comments);
Cache::forever($cacheKey, $archive);
}
// render page
return View::make('about.contribution.frame')->with('archive', $archive);
}
示例4: index
public function index()
{
$date1 = date('Y/m/d ') . ' 00:00:00';
$date2 = date('Y/m/d ') . ' 23:59:59';
$idComments = Comment::all()->lists('id');
$comment5 = Comment::select()->orderBy('created_at', 'desc')->limit(5)->get();
$commentsToday = Comment::select()->where('type', '<>', 'Error')->whereBetween('created_at', [$date1, $date2])->get();
$commentWithAnswer = Comment::select()->where('type', '=', 'Error')->get();
$commentWithAnswerToday = AnswerComment::select()->whereBetween('created_at', [$date1, $date2])->get();
$totalComments = sizeof($idComments);
$totalcWa = sizeof($commentWithAnswer);
$totalcWNa = $totalComments - $totalcWa;
$totalCommentsToday = sizeof($commentsToday);
$totalCommentsWithAnswerToday = sizeof($commentWithAnswerToday);
return view('index', compact('totalcWa', 'totalcWNa', 'comment5', 'totalCommentsToday', 'totalCommentsWithAnswerToday'));
}
示例5: thread
/**
* スレッド詳細表示アクション
* @return Ambigous <\Illuminate\Http\RedirectResponse, \Illuminate\Http\RedirectResponse>|Ambigous <\Illuminate\View\View, mixed, \Illuminate\Container\static>
*/
public function thread()
{
//スレッドIDを取得
if (Input::has('id')) {
$thread_id = Input::get('id');
} else {
return redirect('/')->with('err_msg', 'スレッドが選択されていません');
}
//スレッドID→スレッド名
$thread = Thread::getThreadName($thread_id);
//スレッドID→投稿一覧
$comments = Comment::select('id', 'user', 'content', 'date', 'number', 'response', 'file')->where('thread_id', '=', $thread_id)->orderBy('response', 'ASC')->get();
//飲み屋取得
$shops = Tavern::getTarern($thread_id);
return view('board.thread', compact('thread_id', 'thread', 'comments', 'shops'));
}
示例6: insertComment
/**
* スレッド内コメント情報の登録
* @param int $threadID
* @param string $user
* @param string $content
* @param int $response
* @return boolean
*/
public static function insertComment($threadID, $user, $content, $response, $file = NULL)
{
$comment = new Comment();
//コメント数の取得
$count = Comment::select('id')->count();
//コメント情報をデータベースへ登録
$comment->thread_id = $threadID;
$comment->user = $user;
$comment->content = $content;
$comment->file = $file;
//一番最後の番号を取得
$number = $comment->select('number')->where('thread_id', '=', $threadID)->orderBy('number', 'DESC')->take(1)->get();
$comment->number = isset($number[0]) ? $number[0]['number'] + 1 : 1;
//レスポンス対象がなければnumber=response
$comment->response = $response == '' || $response > $comment->number ? $comment->number : $response;
return $comment->save();
}
示例7: delete
public function delete()
{
if (Input::has('id')) {
$thread_id = Input::get('id');
//アップロードされている画像のパスを取得
$paths = Comment::select('file')->where('thread_id', '=', $thread_id)->get();
//画像ファイルの削除
foreach ($paths as $path) {
if (!$path == null) {
continue;
}
unlink($path['file']);
}
//スレッドの削除
Thread::where('id', '=', $thread_id)->delete();
}
return redirect('/dashboard');
}
示例8: getTarern
/**
* 飲み屋取得メソッド
* @param unknown $threadID
* @return boolean|multitype:multitype:
*/
public static function getTarern($threadID)
{
//APIキーとベースURL
$api_key = '089f2fb5ad111afc8ee53edaabf2369b993f7da4b83a3327dafd02fc5f599a93';
$base_uri = 'http://webapi.suntory.co.jp/barnavi/v2/shops';
//取得数定義
$MAX = 3;
//BAR-NAV WebAPI URL
$url = $base_uri . '?key=' . $api_key . '&pattern=0';
//heartrails GeoAPI
$HEARTRAILS = 'http://geoapi.heartrails.com/api/xml?method=getTowns&city=';
//投稿の取得
$contents = Comment::select('id', 'user', 'content', 'date', 'number', 'response', 'file')->where('thread_id', '=', $threadID)->orderBy('response', 'ASC')->get();
$comment = array();
//投稿IDの配列化
foreach ($contents as $key => $content) {
$comment[$key] = $content['content'];
}
//コメントから飲み屋を検索
$tmp = array();
$j = 0;
for ($i = 0; $i < count($comment); $i++) {
$tmp[$j] = self::searchParam($comment[$i]);
if (is_array($tmp[$j])) {
$j++;
}
}
//検索するパターンをランダムで選択
$rand = rand(0, count($tmp) - 1);
$patterns[0] = $tmp[$rand];
if (isset($patterns[0]['param']) && $patterns[0]['param'] != 'pref' && $patterns[0]['param'] != 'access' && $patterns[0]['param'] != 'address') {
$patterns[1] = array('param' => 'pref', 'id' => 12, 'value' => '東京');
} elseif (isset($patterns[0]['param']) && ($patterns[0]['param'] != 'access' || $patterns[0]['param'] != 'address')) {
//市町村区、駅名⇒県名(飲み屋取得APIが県名が必要パラメータであるため)
$pref = simplexml_load_file($HEARTRAILS . $patterns[0]['value']);
$pref = get_object_vars($pref);
if (isset($pref['location'][0])) {
$pref = get_object_vars($pref['location'][0]);
$patterns[1] = self::searchParam($pref['prefecture']);
} else {
$patterns[0]['param'] = false;
}
}
if (!$patterns[0]['param']) {
//パターンが一つもなければ恵比寿のお店
$patterns = array(0 => array('param' => 'pref', 'id' => 12, 'value' => '東京'), 1 => array('param' => 'address', 'id' => null, 'value' => '渋谷区恵比寿'));
}
$param = '';
//パラメータを一行化
foreach ($patterns as $key => $pattern) {
switch ($pattern['param']) {
case 'pref':
$pattern['id'] += 1;
$pattern['id'] = $pattern['id'] < 10 ? '0' . $pattern['id'] : $pattern['id'];
$param .= '&' . $pattern['param'] . '=' . $pattern['id'];
break;
case 'address':
$param .= '&' . $pattern['param'] . '=' . $pattern['value'];
break;
case 'access':
$param .= '&' . $pattern['param'] . '=' . $pattern['value'];
break;
case 'type':
$param .= '&' . $pattern['param'] . '=' . $pattern['id'];
break;
case 'budget':
if ($pattern['value'] < 2000) {
$id = '01';
} elseif (2000 <= $pattern['value'] && $pattern['value'] < 3000) {
$id = '02';
} elseif (3000 <= $pattern['value'] && $pattern['value'] < 5000) {
$id = '03';
} elseif (5000 <= $pattern['value'] && $pattern['value'] < 7000) {
$id = '04';
} elseif (7000 <= $pattern['value'] && $pattern['value'] < 10000) {
$id = '05';
} else {
$id = '06';
}
$param .= '&' . $pattern['param'] . '=' . $id;
break;
case 'private_room':
$param .= '&' . $pattern['param'] . '=1';
break;
case 'capacity':
$param .= '&' . $pattern['param'] . '=' . $pattern['value'];
break;
default:
return false;
}
}
//件数検索用パラメータの確定
$sub_param = '&url=' . $_SERVER['SERVER_ADDR'];
//xml取得⇒配列へ変換
$tavern = simplexml_load_file($url . $param . $sub_param);
//.........这里部分代码省略.........
示例9: index
public function index()
{
if (!Request::all()) {
return view('search.index');
}
//バリデーションの設定
$validation = Validator::make(['search' => Input::get('search'), 'user' => Input::get('user'), 'thread' => Input::get('thread'), 'keyword' => Input::get('keyword'), 'content' => Input::get('content')], ['search' => 'required', 'user' => 'required_with:search|accepted', 'thread' => 'required_with:search|accepted', 'keyword' => 'required_with:search|accepted', 'content' => 'required_with:search|accepted'], ['required' => '検索語句を入力してください', 'required_with' => '検索条件が設定されていません', 'accepted' => '検索フォームから検索してください']);
//バリデーション失敗時
if ($validation->fails()) {
return redirect()->back()->withErrors($validation->errors());
}
$scope = array('keyword' => 0, 'thread' => 0, 'user' => 0, 'content' => 0);
foreach ($scope as $key => $val) {
$scope[$key] = Input::has($key) ? 1 : $val;
}
$words = Input::get('search');
$words = trim($words);
$words = str_replace(" ", " ", $words);
if (stristr($words, " ")) {
$words = explode(" ", $words);
} else {
$words = array($words);
}
//検索結果格納配列の初期化
$result = array();
//検索方法ごとに検索ワードを検索
foreach ($scope as $key => $val) {
if (!$val) {
continue;
}
switch ($key) {
case 'keyword':
foreach ($words as $word) {
$result[$key][$word] = Comment::select('thread_view.id', 'thread', 'content', 'comments.user as commentator', 'amount', 'thread_view.user')->join('thread_view', 'thread_view.id', '=', 'comments.thread_id')->where('thread', 'Like', "%{$word}%")->orWhere('content', 'Like', "%{$word}%")->orWhere('comments.user', 'Like', "%{$word}%")->groupBy('thread')->groupBy('content')->groupBy('comments.user')->get();
if (!isset($result[$key][$word][0])) {
continue;
}
//ヒット個所の強調
foreach ($result[$key][$word] as $row) {
$row['thread'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['thread']);
$row['commentator'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['commentator']);
$row['content'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['content']);
}
}
break;
case 'thread':
foreach ($words as $word) {
$result[$key][$word] = ThreadView::select('id', 'thread', 'thread_view.user', 'amount')->where('thread', 'like', "%{$word}%")->groupBy('thread')->get();
if (!isset($result[$key][$word][0])) {
continue;
}
//ヒット個所の強調
foreach ($result[$key][$word] as $row) {
//ヒット個所の強調
$row['thread'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['thread']);
}
}
break;
case 'user':
foreach ($words as $word) {
$result[$key][$word] = Comment::select('thread_view.id', 'thread', 'comments.user as commentator', 'thread_view.user', 'amount')->join('thread_view', 'thread_view.id', '=', 'comments.thread_id')->where('comments.user', 'Like', "%{$word}%")->groupBy('comments.user')->get();
if (!isset($result[$key][$word][0])) {
continue;
}
//ヒット個所の強調
foreach ($result[$key][$word] as $row) {
$row['commentator'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['commentator']);
}
}
break;
case 'content':
foreach ($words as $word) {
$result[$key][$word] = Comment::select('thread_view.id', 'thread', 'content', 'thread_view.user', 'amount')->join('thread_view', 'thread_view.id', '=', 'comments.thread_id')->where('content', 'Like', "%{$word}%")->groupBy('content')->get();
if (!isset($result[$key][$word][0])) {
continue;
}
//ヒット個所の強調
foreach ($result[$key][$word] as $row) {
$row['content'] = preg_replace('/' . $word . '/', '~~~~' . $word . '####', $row['content']);
}
}
break;
}
}
return view('search.index')->with('threads', $result);
}
示例10: getCommentsByPost
public function getCommentsByPost($id)
{
return Comment::select('*')->where('post_id', '=', $id)->get();
}