예제 #1
0
 /**
  * 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
0
 private function indexByStatus($status)
 {
     $this->validateStatus($status);
     return Topic::where('status', $status)->active()->get()->map(function ($topic) {
         return new ApiTopic($topic);
     });
 }
예제 #3
0
 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
0
 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
0
 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
0
 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
0
 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
0
 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
0
 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
0
 /**
  * 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
0
 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
0
 public function getSameNodeTopics($limit = 8)
 {
     return Topic::where('node_id', '=', $this->node_id)->recent()->take($limit)->get();
 }
예제 #13
0
 /**
  *
  */
 public function show($id)
 {
     $board = Board::find($id);
     $topics = Topic::where('board_id', '=', $id)->paginate(15);
     return view('forum.show', compact(['board', 'topics']));
 }
예제 #14
0
 public function sync_cats($cat)
 {
     $this->topics()->sync([Topic::where('name', '=', $cat)->first()->id]);
 }
예제 #15
0
 /**
  * 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]);
 }
예제 #16
0
파일: Post.php 프로젝트: enhive/vev
    }
    public function favored()
    {
        return $this->belongsToMany(User::class);
    }
    public function votes()
    {
        return $this->hasMany(Vote::class);
    }
    public function isVoted()
    {
        return in_array(Auth::user()->id, array_pluck($this->votes, 'user_id'));
    }
    public function isFavorite()
    {
        if ($this->favored->find(Auth::user()->id)) {
            return true;
        }
        return false;
    }
}
Post::saving(function ($model) {
    $model->slug = Str::slug($model->title);
    $model->user_id = Auth::user()->id;
    $topic = Topic::where('title', $model->topic)->first();
    if (!$topic) {
        return false;
    }
    unset($model->topic);
    $model->topic_id = $topic->id;
});
예제 #17
0
 public function index($channelNameID)
 {
     $channel_id = id_from_name($channelNameID);
     return view('webboard', ['selected_channel' => $channel_id, 'channels' => Channel::all(), 'user' => Auth::user(), 'topics' => Topic::where('category_id', id_from_name($channel_id))->paginate(config('app.frontEnd.topic.per_page'))]);
 }