本文整理汇总了PHP中Topic::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::where方法的具体用法?PHP Topic::where怎么用?PHP Topic::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showWelcome
public function showWelcome()
{
$posters = Poster::where('daily_id', '=', 0)->get();
$topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get();
$daily = poster::where('daily_id', '=', 1)->get();
foreach ($daily as $recommend) {
$gift = Gift::find($recommend->info_url);
$recommend->content = $gift->content;
$recommend->scan_num = $gift->scan_num;
$recommend->focus_num = $gift->focus_num;
}
foreach ($posters as $poster) {
$poster->photo_url = StaticController::imageWH($poster->photo_url);
}
foreach ($topics as $topic) {
$topic->topic_url = StaticController::imageWH($topic->topic_url);
}
foreach ($daily as $day) {
$day->photo_url = StaticController::imageWH($day->photo_url);
}
if (Request::wantsJson()) {
return Response::json(array('errCode' => 0, 'message' => '返回首页首页数据', 'posters' => $posters, 'topics' => $topics, 'recommendations' => $daily));
}
return View::make('index.home')->with(array('posters' => $posters, 'topics' => $topics, 'recommendations' => $daily));
}
示例2: home
public function home()
{
$scroll_imgs = ScrollImg::all();
//话题
$topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get();
$topics = StaticController::page(12, 1, $topics);
//每日推荐
$daily = Poster::where('daily_id', '=', 1)->get();
//每日推
$daily = StaticController::page(16, 1, $daily);
// $user = Sentry::findUserById(4);
// Sentry::login($user,false);
// Sentry::logout();
if (Sentry::check()) {
foreach ($daily as $recommend) {
$gift = Gift::find($recommend->info_url);
$recommend->title = $gift->title;
$recommend->price = $gift->price;
$recommend->taobao_url = $gift->taobao_url;
$gift_focus = GiftFocus::where('gift_id', '=', $recommend->info_url)->where('user_id', '=', Sentry::getUser()->id)->first();
/* 2015-09-16 hyy fix */
if (isset($gift_focus)) {
$recommend->focus = 1;
} else {
$recommend->focus = 0;
}
}
} else {
foreach ($daily as $recommend) {
$gift = Gift::find($recommend->info_url);
$recommend->title = $gift->title;
$recommend->price = $gift->price;
$recommend->taobao_url = $gift->taobao_url;
$recommend->focus = 0;
}
}
//精选话题
$articles = DB::table('articles')->orderBy('focus_num', 'desc')->get();
$articles = StaticController::page(12, 1, $articles);
if ($articles) {
foreach ($articles as $article) {
$article_url = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'url')->first();
// dd($article_url->content);
if (isset($article)) {
$article->url = $article_url->content;
} else {
$article->url = null;
}
}
}
return View::make('pc.home')->with(array('topics' => $topics, 'gifts' => $daily, 'articles' => $articles, 'scroll_imgs' => $scroll_imgs));
}
示例3: spaceHome
public function spaceHome()
{
$user_id = Input::get('user_id');
if ($user_id != null) {
$user = User::find($user_id);
} else {
if (!Auth::check()) {
return Redirect::back();
}
$user = Auth::user();
}
// dd($user_id);
$albums = $user->hasManyAlbums()->get();
$topics = $user->hasManyTopics()->get();
// dd($albums);
$pictureCount = array();
$picture = array();
$topicCommentCount = array();
if ($albums != null) {
foreach ($albums as $album) {
$pictures = $album->hasManyPictures()->get();
$pictureCount[$album['id']] = $pictures->count();
$p = $pictures->toArray();
if ($p != null) {
$picture[$album['id']] = $p[0]['picture'];
} else {
$picture[$album['id']] = "http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png";
}
}
}
if (count($topics) != 0) {
foreach ($topics as $topic) {
$topicCommentCount[$topic['id']] = $topic->hasManyTopicComments()->count();
}
}
$albums = Album::where('user_id', '=', $user->id)->paginate(2);
$topics = Topic::where('user_id', '=', $user->id)->paginate(2);
$result = array('user' => $user, 'albums' => $albums, 'topics' => $topics, 'pictureCount' => $pictureCount, 'picture' => $picture, 'topicCommentCount' => $topicCommentCount, 'links' => $this->link());
return View::make('userCenter.zone')->with($result);
}
示例4: forumId
public function forumId($id)
{
if (Topic::where('id', '=', $id)->count() > 0) {
$topic = Topic::find($id);
$topic->view = $topic->view + 1;
$topic->save();
if (Commit::where('topic_id', '=', $id)->count() > 0) {
$commit = Commit::where('topic_id', '=', $id)->get();
} else {
$commit = array("無留言");
}
$writer = Student::find($topic->stu_id);
$export[] = array("title" => urlencode(str_replace("\\'", "'", addslashes($topic->title))), "writer" => urlencode(str_replace("\\'", "'", addslashes($writer->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($topic->body))), "file" => urlencode(str_replace("\\'", "'", addslashes($topic->file))), "date" => $topic->day, "view" => $topic->view);
if ($commit[0] != "無留言") {
for ($i = 0; $i < count($commit); $i++) {
$export[] = array("title" => "", "writer" => urlencode(str_replace("\\'", "'", addslashes(Student::find($commit[$i]->stu_id)->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($commit[$i]->body))), "file" => " ", "date" => $commit[$i]->day);
}
}
} else {
$export[] = array("title" => " ", "writer" => " ", "body" => " ", "file" => " ", "day" => " ");
}
return urldecode(json_encode($export));
}
示例5: getSameNodeTopics
/**
* 边栏同一节点下的话题列表
*/
public function getSameNodeTopics($limit = 8)
{
return Topic::where('node_id', '=', $this->node_id)->recent()->take($limit)->remember(10)->get();
}
示例6: getTopicCount
/**
* Compte le nombre de topic dans le forum
*
*/
public function getTopicCount($forumId)
{
$forum = Forum::find($forumId);
return Topic::where('forum_id', '=', $forum->id)->count();
}