本文整理汇总了PHP中app\Topic::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::where方法的具体用法?PHP Topic::where怎么用?PHP Topic::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Topic
的用法示例。
在下文中一共展示了Topic::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
//$results = DB::table('topic')->get();
$results = Topic::where('u_id', '103621')->get();
print_r($results);
return view('m_wc.index');
}
示例2: indexByStatus
private function indexByStatus($status)
{
$this->validateStatus($status);
return Topic::where('status', $status)->active()->get()->map(function ($topic) {
return new ApiTopic($topic);
});
}
示例3: showSection
public function showSection($nameHead, $nameSection)
{
$headForum = forumHead::where('link_route', $nameHead)->firstOrFail();
$sectionForum = forumSection::where('link_section_route', $nameSection)->firstOrFail();
$topics = Topic::where('important', 0)->latest('updated_at')->paginate(20);
if (!\Auth::guest() && \Auth::user()->isAdmin() || !\Auth::guest() && \Auth::user()->isMod()) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} else {
if ($sectionForum->forumHead['forOrg'] == 0 && $sectionForum->forumHead['forBiz'] == 0) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} else {
if (!\Auth::guest() && $sectionForum->forumHead['forOrg'] == \Auth::user()->queryLeaderHeads()) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} elseif (!\Auth::guest() && $sectionForum->forumHead['forOrg'] == \Auth::user()->queryMemberHeads()) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} elseif (!\Auth::guest() && $sectionForum->forumHead['forBiz'] == \Auth::user()->queryBmemberHeads()) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} elseif (!\Auth::guest() && $sectionForum->forumHead['forBiz'] == \Auth::user()->queryBleaderHeads()) {
return view('forum.showSection', compact('sectionForum', 'topics'));
} else {
flash()->error('Nie masz dostępu do tego działu!');
return redirect('/forum');
}
}
}
}
示例4: storeAnswer
public function storeAnswer($id, StoreTopicAnswerRequest $request)
{
\Auth::user()->reply()->create(['body' => strip_tags($request->input('reply_body'), "<b>, <u>, <p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <font>, <span>, <ul>, <li>, <br>, <blockquote>, <ol>, <div>, <table>, <tbody>, <tr>, <td>, <iframe>, <a>, <img>"), 'topic_id' => $id]);
Readtopic::where('topic_id', $id)->delete();
Topic::where('id', $id)->update([]);
flash()->success('Udało Ci się dodać odpowiedź do tematu!');
return redirect('/forum/topic/' . $id . '');
}
示例5: show
public function show($topicName, $questionNumber)
{
$topic = Topic::where('name', '=', $topicName)->first();
// may needs to be refactored, may check sql queries
$question = Question::getByTopicAndQuestionNumber($topic, $questionNumber);
$answers = $question->answers()->get();
$nextQuestionLink = $question->nextQuestionLink($topic, $questionNumber);
return view('quiz.show')->with(['questionNumber' => $questionNumber, 'topic' => $topic, 'question' => $question, 'answers' => $answers, 'next' => $nextQuestionLink]);
}
示例6: deleteTopic
public function deleteTopic()
{
Input::merge(array_map('trim', Input::all()));
$id = (int) Input::get('id');
$topic = Topic::where('parent', $id);
if (!$topic->exists()) {
Topic::destroy($id);
}
return 1;
}
示例7: getOldArticles
public function getOldArticles(Request $request)
{
$input = $request->get('keyword');
$query = Topic::where('name', $input)->first();
if ($query == null) {
return response()->json([]);
} else {
return response()->json(Topic::where('name', $input)->first()->with('article')->get());
}
}
示例8: showByUnit
public function showByUnit($code, $unit_no)
{
$validator = Validator::make(array('code' => $code, 'unit_no' => $unit_no), array('code' => array('regex:/(?i)[a-z]+-?[0-9]+/'), 'unit_no' => array('regex:/[0-9]+/')));
if ($validator->fails()) {
return response()->json(['error' => true, 'message' => $validator->messages()]);
}
$topic = Topic::where('subject_code', $code)->where('unit', $unit_no)->get();
if ($topic->isEmpty()) {
return response()->json(['error' => true, 'topic' => 'subject code or unit no is wrong!!!']);
}
return response()->json(['error' => false, 'topic' => $topic]);
}
示例9: getEnableAttribute
function getEnableAttribute()
{
$enable = 0;
$previousTopicID = Topic::where('id', '<', $this->id)->max('id');
if (is_null($previousTopicID)) {
$enable = 1;
} else {
Log::info('111 $this->id: ' . $this->id . ' $previousTopicID: ' . $previousTopicID);
$easyKUofPreviousTopic = KnowledgeUnit::where('topic_id', '=', $previousTopicID)->where('difficulty_level', '=', '1')->pluck('id');
$is_done_query = DB::table('users_knowledgeunits')->where('user_id', '=', Auth::user()->id)->where('knowledgeunit_id', '=', $easyKUofPreviousTopic)->first();
if (!is_null($is_done_query)) {
$enable = 1;
}
}
return $enable;
}
示例10: map
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function ($router) {
require app_path('Http/routes.php');
});
$router->bind('topics', function ($slug) {
return Topic::where('slug', $slug)->firstOrFail();
});
$router->bind('users', function ($slug) {
return User::where('username', $slug)->firstOrFail();
});
$router->bind('posts', function ($slug) {
return Post::where('slug', $slug)->with(['user', 'votes', 'comments'])->firstOrFail();
});
$router->bind('comments', function ($id) {
return Comment::find($id);
});
}
示例11: index
public function index()
{
$pageRow = Request::input('rows', 15);
if (Request::ajax()) {
$data = Request::all();
$where = array();
if (!empty($data['title'])) {
$where['title'] = array('like', '%' . $data['title'] . '%');
}
if (!empty($data['user_id'])) {
$where['user_id'] = $data['user_id'];
}
if (!empty($data['admin_id'])) {
$where['admin_id'] = $data['admin_id'];
}
$topic = Topic::where($where)->with('type', 'admin', 'user')->paginate($pageRow);
$result['total'] = $topic->total();
$result['rows'] = $topic->items();
return response()->json($result);
}
return View::make('pc_cms.topic.index');
}
示例12: getSameNodeTopics
public function getSameNodeTopics($limit = 8)
{
return Topic::where('node_id', '=', $this->node_id)->recent()->take($limit)->get();
}
示例13: show
/**
*
*/
public function show($id)
{
$board = Board::find($id);
$topics = Topic::where('board_id', '=', $id)->paginate(15);
return view('forum.show', compact(['board', 'topics']));
}
示例14: sync_cats
public function sync_cats($cat)
{
$this->topics()->sync([Topic::where('name', '=', $cat)->first()->id]);
}
示例15: show
/**
* Show all topic in category
*
* @param Request $request
* @param Int @id
* @return Response
*/
public function show(Request $request, $id)
{
$topics = App\Topic::where('category_id', $id)->orderBy('updated_at', 'desc')->get();
$category = App\Category::all();
return view('topic.index', ['topics' => $topics, 'category' => $category]);
}