/** * Show the form for creating a new post * */ public function create() { $user_id = Auth::user()->id; $categories = DB::table('categories')->lists('name', 'id'); $default_category_id = Category::first()->id; $tags = DB::table('tags')->get(['id', 'name']); $default_tag_id = [Tag::first()->id]; return View::make('posts.create', compact('user_id', 'categories', 'default_category_id', 'default_tag_id', 'tags')); }
public function categories($slug) { if (!$slug) { redirect('web'); } // $join = 'LEFT JOIN post_to_categories a ON(posts.id = a.post_id) WHERE category_id = '.$id; $join = " LEFT JOIN post_to_categories a " . "ON(posts.id = a.post_id) " . "WHERE a.category_id = " . Category::first(array('slug' => $slug))->id . " " . "AND post_type = 'post' ORDER BY id DESC"; $data['posts'] = Post::all(array('joins' => $join)); $data['navs'] = Post::all(array('post_type' => 'page')); if (!$data['posts']) { redirect('web/error/404/NotFound'); } $this->theme->view('categories', $data); }
return \Redirect::guest('admin')->with('error', 'Please Login to enter Dashboard'); } else { if (!\Auth::user()->can('login')) { \Notification::error('You can not access here'); return \Redirect::back()->with('error', 'You can not access here'); } } }); Route::filter('checkLogined', function () { if (\Auth::check()) { if (!\Auth::user()->can('login')) { \Notification::error('You can not access here'); return \Redirect::route('getLogin')->with('error', 'You can not access here'); } else { \Notification::success('You are logined !'); return \Redirect::route('dashboard')->with('success', 'You are logined !'); } } }); Route::filter('issetAlbum', function () { if (!\Album::first()) { \Notification::error('Please create album first !'); return \Redirect::route('admin.album.index'); } }); Route::filter('issetCate', function () { if (!\Category::first()) { \Notification::error('Please create Category first !'); return \Redirect::route('admin.category.index'); } });
<?php while ($segment <= $total) { ?> <?php echo '<li><a href="' . $base . '/' . $this->uri->segment($segment) . '">' . $this->uri->segment($segment) . '</a></li>'; ?> <?php $base = $base . '/' . $this->uri->segment($segment); ?> <?php $segment++; } echo '</ol>'; ?> <div class="well"><h4><small>Search for archive :</small> <?php echo Category::first(array('slug' => $this->uri->segment(3)))->title; ?> </h4></div> <?php if ($posts) { ?> <?php foreach ($posts as $post) { ?> <?php if ($post) { ?> <!-- Posting Loops --> <div class="posting"> <div class="panel panel-default post">
/** * @before _secure * @after _cleanUp */ public function categories($id = null) { $view = $this->getActionView(); $fields = ['_id', 'name']; $type = RequestMethods::type(); $org = $this->_org; $categories = Category::all(['org_id' => $org->_id], $fields); switch ($type) { case 'GET': $data = ['categories' => Category::objectArr($categories, $fields)]; $view->set('data', $data); break; case 'POST': $updated = Category::addNew($categories, $org); $data = ['categories' => Category::objectArr($updated, $fields)]; $view->set('data', $data); break; case 'DELETE': $cat = Category::first(['_id' => $id, 'org_id' => $org->_id]); if (!$id || !$cat) { return $this->failure('30'); } if (!$cat->inUse()) { $cat->delete(); $view->set('message', 'Category deleted!!'); } else { $view->set('message', 'Failed to delete category because it is in use'); } unset($categories[$id]); $data = ['categories' => Category::objectArr($categories, $fields)]; $view->set('data', $data); break; } }