当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::find方法代码示例

本文整理汇总了PHP中Category::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::find方法的具体用法?PHP Category::find怎么用?PHP Category::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postUpdate

 public function postUpdate($id)
 {
     $category = Category::find($id);
     if ($category->update(Input::all())) {
         return Redirect::to('admin/categories')->with('message', 'Your Category was updated successfully');
     }
 }
开发者ID:tuananhpham94,项目名称:iFixCenter,代码行数:7,代码来源:CategoriesController.php

示例2: details

 public function details($name, $id)
 {
     $domain = Domain::find($id);
     if (!is_object($domain)) {
         return Redirect::route('home');
     }
     if (!Acl::isSuperAdmin()) {
         if (!$domain->status) {
             return Redirect::route('home');
         }
     }
     $pr = DirectoryHelpers::getPagerank($domain->url);
     if ($pr) {
         $domain->page_rank = $pr;
     }
     if (!SiteViewer::viewerExists($id)) {
         $domain->increment('hits');
         $site_viewers = new SiteViewer();
         $site_viewers->domain_id = $id;
         $site_viewers->ip = Request::instance()->getClientIp();
         $site_viewers->save();
     }
     if (!$domain->thumb || empty($domain->thumb)) {
         try {
             $domain->thumb = $domain->thumb ? $domain->thumb : DirectoryHelpers::generateThumb($domain->url);
         } catch (Exception $ex) {
             Log::error($ex->getMessage());
         }
     }
     $domain->save();
     $category = Category::find($domain->category_id);
     return View::make('domains.details')->with(compact('domain', 'category'));
 }
开发者ID:CalinB,项目名称:web-directory,代码行数:33,代码来源:DomainsController.php

示例3: store

 /**
  * Store a newly created appointment in storage.
  *
  * Should have: category, advisor, studentId, startTime, endTime
  *
  * @return Response
  *
  */
 public function store()
 {
     $appointment = new Appointment();
     $input = Input::all();
     //Check Required
     if (!array_key_exists('category', $input)) {
         return Response::json(array('message' => 'Missing category'), 400);
     } elseif (!array_key_exists('advisor', $input)) {
         return Response::json(array('message' => 'Missing advisor'), 400);
     } elseif (!array_key_exists('start', $input)) {
         return Response::json(array('message' => 'Missing startTime'), 400);
     } elseif (!array_key_exists('end', $input)) {
         return Response::json(array('message' => 'Missing endTime'), 400);
     } elseif (!array_key_exists('studentId', $input)) {
         return Response::json(array('message' => 'Missing studentId'), 400);
     }
     $appointment->category_id = $input['category'];
     $appointment->start = $input['start'];
     $appointment->end = $input['end'];
     $appointment->save();
     $user = User::find($input['studentId']);
     $std_appt = $user->appointments()->save($appointment);
     // DOES NOT CURRENTLY SET 'is_advising' correctly ... need to fix
     $advisor = User::find($input['advisor']);
     $adv_appt = $advisor->appointments()->save($appointment);
     // Format the dates better
     $appointment->start = Carbon::parse($appointment->start)->toDayDateTimeString();
     $appointment->end = Carbon::parse($appointment->end)->toDayDateTimeString();
     // Return the advisorid and userid in the created appointment object
     $appointment->user = $user->fname . ' ' . $user->lname;
     $appointment->advisor = $advisor->fname . ' ' . $advisor->lname;
     $appointment->category = Category::find($appointment->category_id)->name;
     return Response::json($appointment);
 }
开发者ID:homeski,项目名称:csc436_sched,代码行数:42,代码来源:AppointmentAPIController.php

示例4: getArrayTree

 static function getArrayTree()
 {
     $category = Category::find('enabled=1')->asArray()->getAll();
     $category = Helper_Array::toTree($category, 'id', 'parent_id', 'childrens');
     $category = Helper_ArrayTree::dumpArrayTree($category, -1);
     return $category;
 }
开发者ID:Debenson,项目名称:openwan,代码行数:7,代码来源:category.php

示例5: upload

 /**
  * Upload un torrent
  * 
  * @access public
  * @return View torrent.upload
  *
  */
 public function upload()
 {
     $user = Auth::user();
     // Post et fichier upload
     if (Request::isMethod('post')) {
         // No torrent file uploaded OR an Error has occurred
         if (Input::hasFile('torrent') == false) {
             Session::put('message', 'You must provide a torrent for the upload');
             return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
         } else {
             if (Input::file('torrent')->getError() != 0 && Input::file('torrent')->getClientOriginalExtension() != 'torrent') {
                 Session::put('message', 'An error has occurred');
                 return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
             }
         }
         // Deplace et decode le torrent temporairement
         TorrentTools::moveAndDecode(Input::file('torrent'));
         // Array from decoded from torrent
         $decodedTorrent = TorrentTools::$decodedTorrent;
         // Tmp filename
         $fileName = TorrentTools::$fileName;
         // Info sur le torrent
         $info = Bencode::bdecode_getinfo(getcwd() . '/files/torrents/' . $fileName, true);
         // Si l'announce est invalide ou si le tracker et privée
         if ($decodedTorrent['announce'] != route('announce', ['passkey' => $user->passkey]) && Config::get('other.freeleech') == true) {
             Session::put('message', 'Your announce URL is invalid');
             return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
         }
         // Find the right category
         $category = Category::find(Input::get('category_id'));
         // Create the torrent (DB)
         $torrent = new Torrent(['name' => Input::get('name'), 'slug' => Str::slug(Input::get('name')), 'description' => Input::get('description'), 'info_hash' => $info['info_hash'], 'file_name' => $fileName, 'num_file' => $info['info']['filecount'], 'announce' => $decodedTorrent['announce'], 'size' => $info['info']['size'], 'nfo' => Input::hasFile('nfo') ? TorrentTools::getNfo(Input::file('nfo')) : '', 'category_id' => $category->id, 'user_id' => $user->id]);
         // Validation
         $v = Validator::make($torrent->toArray(), $torrent->rules);
         if ($v->fails()) {
             if (file_exists(getcwd() . '/files/torrents/' . $fileName)) {
                 unlink(getcwd() . '/files/torrents/' . $fileName);
             }
             Session::put('message', 'An error has occured may bee this file is already online ?');
         } else {
             // Savegarde le torrent
             $torrent->save();
             // Compte et sauvegarde le nombre de torrent dans  cette catégorie
             $category->num_torrent = Torrent::where('category_id', '=', $category->id)->count();
             $category->save();
             // Sauvegarde les fichiers que contient le torrent
             $fileList = TorrentTools::getTorrentFiles($decodedTorrent);
             foreach ($fileList as $file) {
                 $f = new TorrentFile();
                 $f->name = $file['name'];
                 $f->size = $file['size'];
                 $f->torrent_id = $torrent->id;
                 $f->save();
                 unset($f);
             }
             return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', trans('torrent.your_torrent_is_now_seeding'));
         }
     }
     return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
 }
开发者ID:boozaa,项目名称:swatt,代码行数:67,代码来源:TorrentController.php

示例6: actionIndex

 public function actionIndex()
 {
     $categories = Category::find()->all();
     //var_dump($category);
     //select('id','name');
     return $this->render('index', ['categories' => $categories]);
 }
开发者ID:slam-mt,项目名称:yii2-shop,代码行数:7,代码来源:FrontendController.php

示例7: showChildAction

 public function showChildAction($id)
 {
     $Category = Category::find("parentId=" . $id . " and status=1");
     $parent = Category::findfirst("id=" . $id);
     $this->view->setVar("parent", $parent);
     $this->view->setVar("category", $Category);
 }
开发者ID:sayi21cn,项目名称:haitao,代码行数:7,代码来源:CategoryController.php

示例8: actionHlxml

 /**
  * @return mixed
  */
 public function actionHlxml()
 {
     Yii::$app->response->format = Response::FORMAT_RAW;
     $headers = Yii::$app->response->headers;
     $headers->add('Content-Type', 'text/xml; charset=UTF-8');
     return $this->renderPartial('hlxml', ['categories' => Category::find()->all(), 'products' => Product::findAll(['export' => true]), 'date' => ProductTranslation::find()->orderBy(['update_time' => SORT_DESC])->one()->update_time]);
 }
开发者ID:black-lamp,项目名称:blcms-shop,代码行数:10,代码来源:ProductController.php

示例9: get_category

 public function get_category($category_id)
 {
     if ($category = Category::find($category_id)) {
         return view('content.category')->with('page_title', $category->category)->with('titles', Page::each($category_id));
     }
     return Response::error('404');
 }
开发者ID:bankorh,项目名称:ecom1_laravel,代码行数:7,代码来源:content.php

示例10: attemptDetails

 public function attemptDetails($id)
 {
     $attempt = Attempt::find($id);
     $category = Category::find($attempt->category_id) ? Category::find($attempt->category_id)->name : 'N/A';
     $similar_domains = Domain::where('url', 'LIKE', '%' . $attempt->url . '%')->get();
     return View::make('admin.attempt_details')->with(compact('attempt', 'category', 'similar_domains'));
 }
开发者ID:CalinB,项目名称:web-directory,代码行数:7,代码来源:AdminController.php

示例11: addAction

 public function addAction()
 {
     $this->tag->setTitle('Каталог | Добавить недвижимость');
     parent::initialize();
     $auth = $this->session->get('auth');
     if ($auth['id'] == '') {
         $this->flash->error("Для добавления товара пожалуйста зарегистрируйтесь!");
         $this->view->user = false;
     } else {
         $this->view->user = true;
         $categorys = Category::find();
         $this->view->categorys = $categorys;
         if ($this->request->isPost()) {
             $real = new Real();
             $real->user_id = $auth['id'];
             $real->name = $this->request->getPost('name');
             $real->price = $this->request->getPost('price');
             $real->cover = $this->request->getPost('cover');
             $real->description = $this->request->getPost('description');
             $real->category = $this->request->getPost('categorys');
             $real->reserve = 0;
             $real->img1 = $this->request->getPost('img1');
             $real->img2 = $this->request->getPost('img2');
             $real->img3 = $this->request->getPost('img3');
             if ($real->save() == false) {
                 foreach ($real->getMessages() as $message) {
                     $this->flash->error((string) $message);
                 }
             } else {
                 $this->flash->success('Данные успешно сохранены');
             }
         }
     }
 }
开发者ID:Altairko,项目名称:REA,代码行数:34,代码来源:CatalogController.php

示例12: create

 /**
  * Создание категории
  */
 public function create()
 {
     if (!User::isAdmin()) {
         App::abort('403');
     }
     $category = new Category();
     if (Request::isMethod('post')) {
         $category->token = Request::input('token', true);
         $category->parent_id = Request::input('parent_id');
         $category->name = Request::input('name');
         $category->slug = Request::input('slug');
         $category->description = Request::input('description');
         $category->sort = Request::input('sort');
         if ($category->save()) {
             App::setFlash('success', 'Категория успешно создана!');
             App::redirect('/category');
         } else {
             App::setFlash('danger', $category->getErrors());
             App::setInput($_POST);
         }
     }
     $maxSort = Category::find(['select' => 'max(sort) max']);
     $maxSort = $maxSort->max + 1;
     $categories = Category::getAll();
     App::view('categories.create', compact('category', 'categories', 'maxSort'));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:29,代码来源:CategoryController.php

示例13: product_list

 public function product_list($category_id = NULL, $page = 1)
 {
     //set the title of the page
     $this->template->title(lang('web_list_product'));
     //set the pagination configuration array and initialize the pagination
     $config = $this->set_paginate_options('product_list', $category_id);
     //Initialize the pagination class
     $this->pagination->initialize($config);
     //control of number page
     $page = $this->uri->segment(5) ? $this->uri->segment(5) : 1;
     //find all the categories with paginate and save it in array to past to the view
     $this->template->set("products", Product::paginate($category_id, $config["per_page"], $page));
     $this->template->set('category_id', $category_id);
     $this->template->set('page', $page);
     $this->template->set('control', TRUE);
     if (!is_null(Category::find($category_id)->category)) {
         $this->template->set('parent_category', Category::find($category_id)->category->id);
     } else {
         $this->template->set('parent_category', "");
     }
     //create paginate´s links
     $this->template->set("links", $this->pagination->create_links());
     //load the view
     $this->template->build('products/list');
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:25,代码来源:products.php

示例14: categories

 public function categories($option = 'all')
 {
     if (!($categories = Cache::read('receivable_categories_' . $this->key, 'expenses'))) {
         $category = new Category();
         $categories = $category->find('all', array('conditions' => array('or' => array('Category.user_id' => $this->Authorization->User->id(), 'Category.team_id' => $this->Authorization->User->Team->id()), 'Category.parent_id' => null, 'Category.type' => 'receivables'), 'order' => 'Category.order'));
         Cache::write('receivable_categories_' . $this->key, $categories, 'expenses');
     }
     switch ($option) {
         case 'list':
             $list = array();
             foreach ($categories as $category) {
                 $list[$category['Category']['name']] = array();
                 if (sizeof($category['ChildCategory'])) {
                     foreach ($category['ChildCategory'] as $cildCategory) {
                         $list[$category['Category']['name']][$cildCategory['id']] = $cildCategory['name'];
                     }
                 } else {
                     $list[$category['Category']['name']][$category['Category']['id']] = ' ' . $category['Category']['name'];
                 }
             }
             return $list;
             break;
         default:
             return $categories;
     }
 }
开发者ID:riverans,项目名称:manage-expenses,代码行数:26,代码来源:ReceivableComponent.php

示例15: getProducts

 public function getProducts($id)
 {
     $category = Category::find($id);
     $network = Network::where('category_id', '=', $id)->get();
     $product = Product::where('category_id', '=', $id)->paginate(9);
     $phone = Product::where('category_id', '=', $id)->get();
     return View::make('products.index')->with('category', $category)->with('network', $network)->with('product', $product)->with('phone', $phone);
 }
开发者ID:bernardowiredu,项目名称:unlocking-site,代码行数:8,代码来源:CategoryController.php


注:本文中的Category::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。