Inheritance: extends Illuminate\Database\Eloquent\Model
Exemplo n.º 1
0
 /**
  *
  *
  */
 public function welcome()
 {
     $topic = new \App\Topic();
     $topics = $topic->recentlyCreated();
     $categories = new \App\Categories();
     $categories = $categories->all();
     //If user then check if they have confirmed email and username
     if (Auth::user()) {
         //if email is not confirm
         if (Auth::user()->confirmed == 0) {
             return redirect('/verification');
         }
         //if displayname is not set
         if (empty(Auth::user()->displayname)) {
             return redirect()->action('ProfileController@createName');
         }
     }
     $storage = Redis::connection();
     $mostView = $storage->zRevRange('postViews', 0, 1);
     foreach ($mostView as $value) {
         $id = str_replace('post:', '', $value);
         //            echo "<br> post". $id;
     }
     return view('welcome', compact('topics', 'categories'));
 }
Exemplo n.º 2
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct(Topic $Topic)
 {
     $this->middleware('auth', ['except' => ['index', 'show']]);
     $this->middleware('admin', ['only' => ['edit', 'update', 'destroy']]);
     $this->Topic = $Topic;
     $this->Topics = $Topic->topics();
 }
Exemplo n.º 3
0
 /**
  * Get Topic models Pager
  *
  * @param int $limit Per page limit
  * @return \Illuminate\Pagination\LengthAwarePaginator
  */
 public static function getTopic($limit = 15)
 {
     $Topic = new Topic();
     $Topic->builder = $Topic->query();
     $Topic->selectCategory();
     $Topic->applyFilter();
     return $Topic->builder->paginate($limit);
 }
Exemplo n.º 4
0
 public function newAppendNotify(User $fromUser, Topic $topic, Append $append)
 {
     $users = $topic->replies()->with('user')->get()->lists('user');
     // Notify commented user
     Notification::batchNotify('comment_append', $fromUser, $this->removeDuplication($users), $topic, null, $append->content);
     // Notify attented users
     Notification::batchNotify('attention_append', $fromUser, $this->removeDuplication($topic->attentedBy), $topic, null, $append->content);
 }
Exemplo n.º 5
0
 public function add()
 {
     $user = new Topic();
     $user->user_id = '123';
     $user->save();
     //$results = DB::table('topic')->get();
     // $results = Topic::create(['u_id'=>'103621']);
     // return view('m_wc.index');
 }
Exemplo n.º 6
0
 /**
  * Create a new event instance.
  *
  * @return void
  *
  * $flg -> increment or decrement
  */
 public function __construct($notify_user, $topics_uuid, $is_upvote)
 {
     $this->user = $notify_user;
     $notification = new Notification();
     $this->count = $notification->countNotification($notify_user);
     $this->is_upvote = $is_upvote;
     //Get the most upvote count*/
     $tp = new Topic();
     $this->upv_cnt = $tp->upvoteTopic($topics_uuid, $is_upvote);
     $this->topic = $topics_uuid;
 }
Exemplo n.º 7
0
 /**
  * Register bindings in the container.
  *
  * @return void
  */
 public function boot(Guard $guard)
 {
     $topics = [];
     if ($guard->check()) {
         $topics = Topic::whereHas('followers', function ($q) use($guard) {
             $q->where('user_id', $guard->user()->id);
         })->get();
     }
     view()->composer('common.notifications', function ($view) use($topics) {
         $view->with('notifications', []);
     });
     view()->composer('posts.index', function ($view) {
         if (Input::get('order') && Input::get('order') == 'popular') {
             $order = 'popular';
         } else {
             $order = 'recent';
         }
         $view->with('order', $order);
     });
     view()->composer('posts.index', function ($view) {
         if (Input::get('view') && Input::get('view') == 'grid') {
             $v = 'grid';
         } else {
             $v = 'list';
         }
         $view->with('view', $v);
     });
 }
Exemplo n.º 8
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');
 }
Exemplo n.º 9
0
 /**
  * Show the website home page
  *
  * @return Response
  */
 public function welcome()
 {
     $topics = App\Topic::news()->orderBy('updated_at', 'desc')->limit(5)->get();
     $authme = App\Authme::with('money')->get();
     // dd($authme);
     return view('home', ['topics' => $topics, 'authme' => $authme]);
 }
Exemplo n.º 10
0
 public function patch($id, Request $request)
 {
     $topic = Topic::findOrFail($id);
     $this->authorize('update-topic', $topic);
     $topic->patch($request->all());
     return response('', 200);
 }
 /**
  * Display a conversation and replies
  *
  * @param $slug
  * @return \Illuminate\View\View
  */
 public function show($slug)
 {
     $conversation = $this->conversationRepo->findBySlug($slug);
     $topic = Topic::all();
     $replies = $conversation->replies()->orderBy('created_at', 'DESC')->paginate(4);
     return view('Forum::Conversations.show', compact('conversation', 'replies', 'topic'));
 }
Exemplo n.º 12
0
 public function topicDownVote(Topic $topic)
 {
     if ($topic->votes()->ByWhom(auth()->id())->WithType('downvote')->count()) {
         // click second time for remove downvote
         $topic->votes()->ByWhom(auth()->id())->WithType('downvote')->delete();
         $topic->increment('vote_count', 1);
     } elseif ($topic->votes()->ByWhom(auth()->id())->WithType('upvote')->count()) {
         // user already clicked upvote once
         $topic->votes()->ByWhom(auth()->id())->WithType('upvote')->delete();
         $topic->votes()->create(['user_id' => auth()->id(), 'is' => 'downvote']);
         $topic->decrement('vote_count', 2);
     } else {
         // click first time
         $topic->votes()->create(['user_id' => auth()->id(), 'is' => 'downvote']);
         $topic->decrement('vote_count', 1);
     }
 }
Exemplo n.º 13
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 . '');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $topics = ['Idea Generation', 'Naming', 'Domain names', 'Hosting', 'Market research', 'Forms and Surveys', 'Mockups and Wireframing', 'Design', 'Development', 'Bootcamps', 'Incubaters and Accelerators', 'Deployment', 'Social tools', 'MVP', 'Marketing', 'Early Users', 'Presentations', 'Product Demo', 'Launching', 'Analytics', 'Mobile Analytics', 'Customer Support', 'Project Management', 'Collaboration and Communication', 'Productivity', 'Bugtracking and Feedback', 'Shop', 'Payments', 'Outsourcing', 'Raising Capital', 'Investors', 'Sales', 'CRM', 'Legal', 'Finance', 'HR', 'Learning', 'Books', 'Videos', 'Articles', 'Blogs', 'Newsletters'];
     foreach ($topics as $topic) {
         $t = new Topic();
         if ($t->validate(['name' => $topic])) {
             $t->name = $topic;
             if ($t->save()) {
                 $this->command->info("Added topic: {$topic}");
             }
         } else {
             $this->command->info($t->errors());
         }
         // Topic::create(["name" => $topic]);
     }
 }
Exemplo n.º 15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('topics')->delete();
     $topics = array(['title' => '柠檬香茅火锅仓山万达店', 'body' => '首先,服务态度真的是太好了;其次,分量非常足;然后,上菜也相当的快;最后,老板还推荐用最优惠的付款方式。', 'user_id' => 1], ['title' => '逆风网咖', 'body' => '福州第一家网咖,也是将网咖精神执行的最好的一家网咖,无烟无污染,全戴尔显示器机械键盘,请的服务生也都是学生妹。', 'user_id' => 2], ['title' => 'EmailCoffee', 'body' => '坐落正祥广场的一家咖啡管,装修风格独特,咖啡正宗,人少不吵杂,很多人都是一坐一个下午,服务生也是很漂亮。', 'user_id' => 3], ['title' => '重庆小面万达店', 'body' => '这家面馆在万达4号门,人进人出,生意很不错,味道也很好虽然有点辣', 'user_id' => 4], ['title' => '欢乐园网咖', 'body' => '福建第一家网咖连锁店,算得上常山地区真正意义上的网咖的,环境优雅,配置齐全高端', 'user_id' => 5], ['title' => '万达影院', 'body' => '每个周末都有特价电影票,偶尔遇上什么大片做特价就去看看吧,绝对是享受', 'user_id' => 6], ['title' => '高更牛排', 'body' => '一家专门做牛排西餐的店铺,价格比经典牛排优惠许多,但料一点没有减少', 'user_id' => 7], ['title' => '表哥茶餐厅', 'body' => '正宗香港品牌,致力于推广香港饮食文化,不过价格是有点偏贵', 'user_id' => 8], ['title' => '鼓岭', 'body' => '位置位于鼓山旁边,但空气比鼓山上的更清新环境比鼓山更好游客少', 'user_id' => 9]);
     foreach ($topics as $topic) {
         Topic::create($topic);
     }
 }
Exemplo n.º 16
0
 public function showTopic($id)
 {
     $topic = Topic::findOrFail($id);
     $replys = Reply::where('topic_id', $id)->paginate(20);
     if (!\Auth::guest() && \Auth::user()->isAdmin() || !\Auth::guest() && \Auth::user()->isMod()) {
         if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
             return view('forum.showTopic', compact('topic', 'replys'));
         } else {
             \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
             return view('forum.showTopic', compact('topic', 'replys'));
         }
     } else {
         if ($topic->forumSection->forumHead['forOrg'] == 0 && $topic->forumSection->forumHead['forBiz'] == 0) {
             if (\Auth::guest()) {
                 return view('forum.showTopic', compact('topic', 'replys'));
             }
             if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                 return view('forum.showTopic', compact('topic', 'replys'));
             } else {
                 \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                 return view('forum.showTopic', compact('topic', 'replys'));
             }
         } else {
             if (!\Auth::guest() && $topic->forumSection->forumHead['forOrg'] == \Auth::user()->queryLeaderHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forOrg'] == \Auth::user()->queryMemberHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forBiz'] == \Auth::user()->queryBmemberHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } elseif (!\Auth::guest() && $topic->forumSection->forumHead['forBiz'] == \Auth::user()->queryBleaderHeads()) {
                 if (!\Auth::guest() && \Auth::user()->queryExists($id)) {
                     return view('forum.showTopic', compact('topic', 'replys'));
                 } else {
                     \Auth::user()->readtopic()->create(['topic_id' => $id, 'was_read' => 1, 'last_read' => Carbon::now()]);
                     return view('forum.showTopic', compact('topic', 'replys'));
                 }
             } else {
                 flash()->error('Nie masz dostępu do tego tematu!');
                 return redirect('/forum');
             }
         }
     }
 }
Exemplo n.º 17
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::lists('id')->all();
     $topics = Topic::lists('id')->all();
     foreach (range(1, 500) as $index) {
         factory(App\Reply::class)->create(['user_id' => $faker->randomElement($users), 'topic_id' => $faker->randomElement($topics)]);
     }
 }
Exemplo n.º 18
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::lists('id')->toArray();
     $nodes = Category::where('type_id', '=', Category::TYPE_TOPIC)->lists('id')->toArray();
     $faker = Faker\Factory::create();
     foreach (range(1, 18) as $index) {
         Topic::create(['title' => 'topic ' . $faker->sentence(), 'body' => implode('<br>', $faker->paragraphs(8)), 'user_id' => $faker->randomElement($users), 'type_id' => Topic::TYPE_TOPIC, 'category_id' => $faker->randomElement($nodes), 'last_comment_user_id' => $faker->randomElement($users)]);
     }
 }
 public function store($episodeId, Request $request)
 {
     if (!Auth::user()->isAdmin()) {
         abort(403);
     }
     $episode = Episode::findOrFail($episodeId);
     $topic = Topic::findOrFail($request->get('topic_id'));
     $episode->topics()->save($topic);
 }
Exemplo n.º 20
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]);
 }
Exemplo n.º 21
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('topics')->truncate();
     Eloquent::unguard();
     $topics = [['id' => 1, 'menu_id' => 6, 'title' => 'Post Liberalisation', 'parent' => 0, 'level' => 0], ['id' => 2, 'menu_id' => 6, 'title' => 'LPG', 'parent' => 1, 'level' => 1], ['id' => 3, 'menu_id' => 6, 'title' => 'Liberalization', 'parent' => 2, 'level' => 2], ['id' => 4, 'menu_id' => 6, 'title' => 'Budget 1992', 'parent' => 3, 'level' => 3], ['id' => 5, 'menu_id' => 6, 'title' => 'World pressure', 'parent' => 3, 'level' => 3], ['id' => 6, 'menu_id' => 6, 'title' => 'Privatization', 'parent' => 2, 'level' => 2], ['id' => 7, 'menu_id' => 6, 'title' => 'Disinvestment', 'parent' => 6, 'level' => 3], ['id' => 8, 'menu_id' => 6, 'title' => 'Globalization', 'parent' => 2, 'level' => 2], ['id' => 9, 'menu_id' => 6, 'title' => 'BRICS', 'parent' => 1, 'level' => 1], ['id' => 10, 'menu_id' => 6, 'title' => 'Pre Liberalisation', 'parent' => 0, 'level' => 0], ['id' => 11, 'menu_id' => 6, 'title' => 'Land reforms', 'parent' => 10, 'level' => 1], ['id' => 12, 'menu_id' => 6, 'title' => 'International', 'parent' => 0, 'level' => 0], ['id' => 13, 'menu_id' => 6, 'title' => 'Summits', 'parent' => 12, 'level' => 1]];
     foreach ($topics as $topic) {
         Topic::create($topic);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $samples_temp = [];
     for ($i = 0; $i < 5; $i++) {
         $samples_temp[] = ['nombre' => $faker->word, 'color' => $faker->hexcolor];
     }
     Topic::insert($samples_temp);
 }
Exemplo n.º 23
0
 public function getRandomTopic()
 {
     $newarray = [];
     for ($i = 0; $i < 10; $i++) {
         $me = Topic::all()->random(1)->toarray();
         array_push($newarray, $me);
     }
     return response()->json(['error' => false, 'topic' => $newarray]);
 }
Exemplo n.º 24
0
 public function getSiteStat()
 {
     return Cache::remember(self::CACHE_KEY, self::CACHE_MINUTES, function () {
         $entity = new StatEntity();
         $entity->topic_count = Topic::count();
         $entity->reply_count = Reply::count();
         $entity->user_count = User::count();
         return $entity;
     });
 }
 public function getNew()
 {
     $resource = new Resource();
     $allTopics = Topic::all()->sortBy('name');
     $topics = [];
     foreach ($allTopics as $topic) {
         $topics += [$topic->id => $topic->name];
     }
     return view('resources.new', ['topics' => $topics, 'resource' => $resource]);
 }
Exemplo n.º 26
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());
     }
 }
Exemplo n.º 27
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $topic = Topic::findOrFail($id);
     $input = array_except($request->input(), '_method');
     if ($topic->update($input)) {
         return $topic;
     } else {
         return $errors;
     }
 }
Exemplo n.º 28
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;
 }
Exemplo n.º 29
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['ip' => 'required|ip', 'content' => 'required', 'user_id' => 'required']);
     if ($comment = Comment::create($request->all())) {
         Topic::find($comment->topic_id)->increment('comments');
         return redirect()->route('bbs.topic.show', [$comment->topic_id]);
     } else {
         return redirect()->back()->withInput()->withErrors('发表回帖失败!');
     }
 }
 /**
  * Feed function
  */
 public function feed()
 {
     $topics = Topic::excellent()->recent()->limit(20)->get();
     $channel = ['title' => 'PHPhub - PHP & Laravel的中文社区', 'description' => 'PHPhub是 PHP 和 Laravel 的中文社区,在这里我们讨论技术, 分享技术。', 'link' => URL::route('feed')];
     $feed = Rss::feed('2.0', 'UTF-8');
     $feed->channel($channel);
     foreach ($topics as $topic) {
         $feed->item(['title' => $topic->title, 'description|cdata' => str_limit($topic->body, 200), 'link' => URL::route('topics.show', $topic->id), 'pubDate' => date('Y-m-d', strtotime($topic->created_at))]);
     }
     return Response::make($feed, 200, array('Content-Type' => 'text/xml'));
 }