示例#1
0
 public function index()
 {
     $logger = new \framework\core\Log('haohongtest.log');
     $logger->info("haha");
     $postModel = new PostModel();
     $posts = $postModel->find(['userId' => 333]);
     dd($posts);
     // $this->view->setLayout('layouts/default');
     // $this->view->render('index/index', ['name' => 'haohong']);
 }
示例#2
0
 public function index(Request $request)
 {
     $searchQuery = $request->get('q');
     $data['searchQuery'] = $searchQuery;
     $data['posts'] = PostModel::where('title', 'like', '%' . $searchQuery . '%')->orWhere('content', 'like', '%' . $searchQuery . '%')->where('is_publish', 1)->orderBy('updated_at', 'DESC')->paginate($this->pageNum);
     return $this->loadView('search', $data);
 }
 protected function loadView($view, $appendData)
 {
     $data = $appendData;
     $data['date'] = new Date();
     $data['categories'] = new CategoryModel();
     $data['recentPosts'] = PostModel::where('is_publish', '1')->orderBy('updated_at', 'DESC')->limit(10)->get();
     $data['tags'] = TagModel::all();
     $data['webSettings'] = new \stdClass();
     foreach (WebSettingModel::all() as $webSetting) {
         $data['webSettings']->{$webSetting->attr} = $webSetting->value;
     }
     return view('frontend.' . $view, $data);
 }
示例#4
0
 public function storeComment($postId)
 {
     // $rules = array('name' => 'required', 'content' => 'required');
     // $input = Input::all();
     // $validation = Validator::make($input, $rules);
     $rules = array('title' => 'required', 'slug' => 'required');
     $validation = Validator::make(Input::all(), $rules);
     $input = Input::except('enable_preview_content', 'tags');
     if ($validation) {
         $comment = PostModel::find($postId)->comment()->create($input);
         return redirect()->route('blog.show', $comment->post->slug);
     } else {
         //return redirect()->route('blog.show', $comment->post->slug);
         echo 'tambah komentar gagal';
     }
 }
示例#5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     PostModel::find($id)->delete();
     return redirect()->route('admin.post.index')->with('success_msg', 'Succesfully deleted post');
 }
示例#6
0
 public function index()
 {
     $data['posts'] = PostModel::where('is_publish', 1)->where('show_in_home', 1)->orderBy('created_at', 'DESC')->paginate(15);
     return $this->loadView('index', $data);
 }