function show() { // dd(Page::all()->toArray()); $page = Page::orWhere(function ($query) { $query->where('url', '=', Request::path()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::path()); })->orWhere(function ($query) { $query->where('url', '=', Request::url()); })->orWhere(function ($query) { $query->where('url', '=', Request::route()->getPath()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::route()->getPath()); })->get()->first(); $ps = Post::where('page_id', '=', $page->id)->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get(); $posts = []; foreach ($page->template()->first()->sections() as $sec) { $posts[$sec->name] = []; } foreach ($ps as $p) { $posts[$p->section()->first()->name][] = $p; } $pages = []; foreach (Page::all() as $pi) { $pages[$pi->name] = $pi; } $fn = str_replace('.blade.php', '', $page->template()->first()->filename); return View::make("aui/templates/" . $fn)->with('posts', $posts)->with('pages', $pages)->with('page', $page); }
function dataAll() { return $this->table->whereIn("post_id", Post::where('page_id', '=', Request::route("id" . ($this->level - 1)))->lists('id'))->with('post')->with('itemType')->get(); }
function countPosts($name) { return Post::where('page_id', '=', $this->id)->whereIn('section_id', Section::where('name', '=', $name)->lists('id'))->count(); }
function get() { return ViewUtils::page([ViewUtils::box('Sort Posts', [\View::make('punto-cms::sort')->with('actionUrl', '/admin/manage-pages/' . Request::route('id1') . '/section/' . Request::route('id2') . '/sort')->with('items', Post::where('page_id', '=', Request::route('id1'))->where('section_id', '=', Request::route('id2'))->orderBy('sort', 'ASC')->orderBy('id', 'ASC')->get())->with('key', 'name_formatted')])]); }
function show() { $puntoFeed = Feed::orWhere(function ($query) { $query->where('url', '=', Request::path()); })->orWhere(function ($query) { $query->where('url', '=', '/' . Request::path()); })->orWhere(function ($query) { $query->where('url', '=', Request::url()); })->get()->first(); $feed = \Feed::make(); $feed->setTextLimit(10000); $feed->setView('punto-cms::rss'); // cache the feed for 60 minutes (second parameter is optional) if ($this->useCache) { $feed->setCache(0, $puntoFeed->name); } // check if there is cached feed and build new only if is not if (!$this->useCache || !$feed->isCached()) { // creating rss feed with our most recent 20 posts $posts = Post::where('page_id', '=', $puntoFeed->page_id)->where('section_id', '=', $puntoFeed->section_id)->orderBy('created_at', 'desc')->get(); // set your feed's title, description, link, pubdate and language $feed->title = $puntoFeed->name; $feed->description = ''; // $feed->logo = 'http://yoursite.tld/logo.jpg'; $feed->link = Request::url(); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' if (isset($posts[0])) { $feed->pubdate = $posts[0]->created_at; } $feed->lang = 'en'; $feed->setShortening(true); // true or false // $feed->setTextLimit(100); // maximum length of description text foreach ($posts as $post) { // set item's title, author, url, pubdate, description and content $desc = null; $title = null; if ($post->hasContent("Description")) { $desc = $post->findContent("Description")->value; } else { if ($post->hasContent("Title")) { $desc = $post->findContent("Title")->value; } else { if ($post->hasContent("Name")) { $desc = $post->findContent("Name")->value; } } } if ($post->hasContent("Title")) { $title = $post->findContent("Title")->value; } else { if ($post->hasContent("Name")) { $title = $post->findContent("Name")->value; } else { if ($post->hasContent("Description")) { $title = $post->findContent("Description")->value; } } } if ($desc !== null) { $feed->add($title, null, null, $post->created_at, $desc, null); } } } else { } // first param is the feed format // optional: second param is cache duration (value of 0 turns off caching) // optional: you can set custom cache key with 3rd param as string return $feed->render('rss'); }