本文整理汇总了PHP中Category::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::get方法的具体用法?PHP Category::get怎么用?PHP Category::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of categories
*
* @return Response
*/
public function index()
{
$data = Input::all();
$categories = Category::where(function ($query) {
if (Input::has('owner_type')) {
$query->where('owner_type', Input::get('owner_type'));
}
if (Input::has('query')) {
$query->where('name', 'like', '%' . Input::get('query') . '%');
}
});
$types = Category::get(['owner_type']);
$types = $types->groupBy(function ($category) {
return $category->owner_type;
})->toArray();
if (Request::ajax()) {
// SUGGESTIONS FOR AUTOCOMPLETE
$categories = $categories->get();
if (Input::has('query')) {
$suggestions = array();
foreach ($categories as $category) {
$suggestions[] = array("value" => $category->name, "data" => array('owner_type' => $category->owner_type));
}
$categories = array('suggestions' => $suggestions);
return Response::json($categories);
}
// RETURN INDEX PANEL
return View::make('categories.panels.index', compact('categories', 'types'));
} else {
$categories = $categories->paginate(Input::get('paginate', 10));
return View::make('categories.index', compact('categories', 'types'));
}
}
示例2: generateSitemap
public static function generateSitemap($reGenerate = false)
{
// create new sitemap object
$sitemap = App::make("sitemap");
$sitemap->setCache('laravel.sitemap', 3600);
if ($reGenerate) {
Cache::forget($sitemap->model->getCacheKey());
}
// check if there is cached sitemap and build new only if is not
if (!$sitemap->isCached()) {
// add item to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to('/'), null, '1.0', 'daily');
$categories = Category::get();
foreach ($categories as $category) {
$sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
}
// get all lists from db
$lists = ViralList::orderBy('created_at', 'desc')->get();
// add every post to the sitemap
foreach ($lists as $list) {
$sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
}
}
// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
return $sitemap->render('xml');
}
示例3: total_categories
/**
* Theme functions for categories
*/
function total_categories()
{
if (!($categories = Registry::get('categories'))) {
$categories = Category::get();
$categories = new Items($categories);
Registry::set('categories', $categories);
}
return $categories->length();
}
示例4: __construct
function __construct($pth)
{
if (!is_example_path($pth) or !is_example_exists($pth)) {
throw new Exception("Example {$pth} not exists");
}
$this->pth = $pth;
$this->file_id = last(explode('/', $pth));
$category_path = implode('/', but_last(explode('/', $pth)));
$this->id = find_position($this->file_id, $category_path);
$this->category = Category::get($category_path);
}
示例5: example_title
function example_title($example)
{
$cats = array();
foreach (bu::path() as $v) {
if (preg_match('/^[0-9]+$/', $v)) {
break;
}
$cats[] = Category::get($v)->name();
}
return 'Пример: ' . implode('/', $cats) . ' #' . $example->id();
}
示例6: getRoot
public function getRoot()
{
$treePath = array_values(array_filter(explode('/', $this->tree_path)));
if (!empty($treePath[0])) {
$category = Category::get($treePath[0]);
if ($category) {
return $category;
}
}
return $this;
}
示例7: index
public function index()
{
switch ($this->type) {
case 'categories':
$list = Category::get(array('id', 'name', 'slug'));
break;
default:
$list = Product::get(array('id', 'name', 'slug', 'pricing', 'in_stock', 'published'));
break;
}
$this->layout->content = View::make('admin.control_panel.list', array('type' => $this->type, 'list' => $list));
}
示例8: getSub
public static function getSub($path = '')
{
if ($path) {
$path .= '/';
}
$dirs = glob(self::PREFIX . $path . '*', GLOB_ONLYDIR);
if (!$dirs) {
return array();
}
foreach ($dirs as $k => $v) {
$v = str_replace(self::PREFIX, '', $v);
$dirs[$k] = Category::get($v);
}
return sortByName($dirs);
}
示例9: get_update
public function get_update()
{
$post = Post::Find($this->post_id);
$user = Auth::user();
$categories = Category::get();
$organisations = Organisation::get();
$selected = array();
foreach ($post->categories as $c) {
$selected[] = $c->id;
}
$selected_org = array();
foreach ($post->organisations as $o) {
$selected_org[] = $o->id;
}
return View::Make('user.posts.update')->with('post', $post)->with('user', $user)->with('categories', $categories)->with('selected', $selected)->with('organisations', $organisations)->with('selected_org', $selected_org);
}
示例10: generate_admin
public function generate_admin()
{
$post_count = $this->block->data('post_count');
$alphabetical_order = $this->block->data('alphabetical_order');
$category = $this->block->data('category');
$count = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "all" => "All");
$option = array("yes" => "Yes", "no" => "No");
$category_option = array("all" => "All");
$categores = new Category();
$all_category = $categores->get();
foreach ($all_category->all as $key => $value) {
$category_option[$value->id] = $value->name;
}
$this->admin_select('post_count', $count, 'Post Count: ', $post_count);
$this->admin_select('alphabetical_order', $option, 'Alphabetical Order (a-z): ', $alphabetical_order);
$this->admin_select('category', $category_option, 'Category: ', $category);
}
示例11: actionDetail
/**
* View group detail
* @param $groupId
*/
public function actionDetail($groupId)
{
$group = Group::get($groupId);
RAssert::not_null($group);
$group->category = Category::get($group->categoryId);
$group->groupCreator = User::get($group->creator);
$counter = $group->increaseCounter();
// get latest 20 posts in the group
$posts = Topic::find("groupId", $groupId)->join("user")->order_desc("createdTime")->range(0, 20);
$data = ['group' => $group, 'counter' => $counter->totalCount, 'latestPosts' => $posts];
$isLogin = Rays::isLogin();
$data['hasJoined'] = $isLogin && GroupUser::isUserInGroup(Rays::user()->id, $group->id);
$data['isManager'] = $isLogin && $group->creator == Rays::user()->id;
$this->setHeaderTitle($group->name);
$this->addCss("/public/css/post.css");
$this->render('detail', $data, false);
}
示例12: actionAdmin
/**
* Category administration
*/
public function actionAdmin()
{
$data = array();
if (Rays::isPost()) {
if (isset($_POST['sub_items'])) {
$items = $_POST['sub_items'];
if (is_array($items)) {
foreach ($items as $item) {
if (!is_numeric($item)) {
return;
} else {
$cat = Category::get($item);
if ($cat->pid == 0) {
continue;
}
$cat->delete();
}
}
}
}
if (isset($_POST['cat-name']) && isset($_POST['parent-id'])) {
$name = trim($_POST['cat-name']);
$pid = $_POST['parent-id'];
if (is_numeric($pid)) {
if ($name == '') {
$this->flash('error', 'Category name cannot be blank.');
} else {
$result = Category::get($pid);
if ($result != null) {
$newCat = new Category();
$newCat->name = RHtml::encode(trim($name));
$newCat->pid = $pid;
$newCat->save();
$this->flash('message', 'Category ' . $name . " was created successfully.");
} else {
$this->flash('error', 'Parent category not exists.');
}
}
}
}
}
$data['categories'] = Category::find()->all();
$this->layout = 'admin';
$this->setHeaderTitle('Category administration');
$this->render('admin', $data, false);
}
示例13: generate_admin
public function generate_admin()
{
$post_count = $this->block->data('post_count');
$alphabetical_order = $this->block->data('alphabetical_order');
$category = $this->block->data('category');
$count = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "all" => "All");
$option = array("az" => "Alphabetical from A to Z", "za" => "Alphabetical from Z to A", "latest" => "Latest posts", "oldest" => "Oldest posts", "updated" => "Updated posts", "most_visited" => "Most visited", "less_visited" => "Less visited");
$category_option = array("all" => "All");
$categores = new Category();
$all_category = $categores->get();
foreach ($all_category->all as $key => $value) {
$category_option[$value->id] = $value->name;
}
$this->admin_select('post_count', $count, 'Post Count: ', $post_count);
$this->admin_select('alphabetical_order', $option, 'Posts order: ', $alphabetical_order);
$this->admin_select('category', $category_option, 'Category: ', $category);
}
示例14: register
public static function register()
{
// register home page
Registry::set('home_page', Page::home());
// register posts page
Registry::set('posts_page', Page::posts());
if (!is_admin()) {
// register categories
foreach (Category::get() as $itm) {
$categories[$itm->id] = $itm;
}
Registry::set('all_categories', $categories);
// register menu items
$pages = Page::where('status', '=', 'published')->where('show_in_menu', '=', '1')->sort('menu_order')->get();
$pages = new Items($pages);
Registry::set('menu', $pages);
Registry::set('total_menu_items', $pages->length());
}
}
示例15: getGroupsOfCategory
public static function getGroupsOfCategory($categoryId, $start = 0, $limit = 0, $withSubCategory = true)
{
$category = Category::get($categoryId);
if ($category == null) {
return array();
}
$query = Group::find()->order_desc('id');
if ($withSubCategory) {
$subs = $category->children();
$where = "[categoryId] in (?";
$args = [$categoryId];
for ($i = 0, $count = count($subs); $i < $count; $i++) {
$where .= ",?";
$args[] = $subs[$i]->id;
}
$where .= ')';
$query->where($where, $args);
unset($subs);
}
$groups = $start != 0 || $limit != 0 ? $query->range($start, $limit) : $query->all();
return $groups;
}