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');
     }
 }
 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'));
 }
 /**
  * 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);
 }
Example #4
0
 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;
 }
Example #5
0
 /**
  * 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));
 }
Example #6
0
 public function actionIndex()
 {
     $categories = Category::find()->all();
     //var_dump($category);
     //select('id','name');
     return $this->render('index', ['categories' => $categories]);
 }
Example #7
0
 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);
 }
 /**
  * @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]);
 }
Example #9
0
 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');
 }
Example #10
0
 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'));
 }
Example #11
0
 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('Данные успешно сохранены');
             }
         }
     }
 }
Example #12
0
 /**
  * Создание категории
  */
 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'));
 }
Example #13
0
 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');
 }
 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;
     }
 }
 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);
 }
 public function singleCategory($id)
 {
     $category = Category::find($id);
     if (empty($category)) {
         return '';
     }
     return View::make('categories/single_category', compact('category'));
 }
Example #17
0
 private function getPosts()
 {
     $category = Category::find(Input::get('category'));
     if (is_null($category)) {
         return false;
     }
     return $category->posts()->where('created_at', '>', Input::get('timestamp'))->take($this->count)->get();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $category = Category::find($id);
     if ($category->delete()) {
         return $this->respondNoContent();
     }
     return $this->respondServerError();
 }
Example #19
0
 public function postUpdateCat($id)
 {
     $category = Category::find($id);
     $category->name = Input::get('name');
     $category->description = Input::get('description');
     $category->save();
     return Redirect::to('admin/categories');
 }
Example #20
0
File: Materi.php Project: rizqon/ta
 public function category()
 {
     $category = Category::find($this->category_id);
     if (empty($category)) {
         return 'Unknown';
     }
     return $category->title;
 }
 public function delete($id)
 {
     $category = Category::find($id);
     $category->softDeletes();
     // redirect
     Session::flash('message', 'Successfully deleted the category!');
     return Redirect::to('admin/category');
 }
 public function postDestroy()
 {
     $category = Category::find(Input::get("id"));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('message', "Category deleted");
     }
     return Redirect::to('admin/categories/index')->with('message', "wrong");
 }
 public function deleteCategory($id)
 {
     $category = Category::find($id);
     if ($category->user_id != self::get_user_logged_in()->id) {
         View::make('error.html', array('error' => 'Sinulla ei ole oikeuksia poistaa tätä kategoriaa !'));
     }
     $category->destroy();
     Redirect::to('/');
 }
 public function postDestroy()
 {
     $category = Category::find(Input::get('id'));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('message', 'Categoria apagada');
     }
     return Redirect::to('admin/categories/index')->with('message', 'Alguma coisa está errada, tente outra vez por favor.');
 }
Example #25
0
 /**
  * Gets a category
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function get($request, $params)
 {
     try {
         $category = Category::find(array('id' => $params));
         static::response($category, 200);
     } catch (Exception $e) {
         static::response(array(), 400, $e->getMessage());
     }
 }
 public function postDestroy()
 {
     $category = Category::find(Input::get('id'));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('message', 'Category Deleted');
     }
     return Redirect::to('admin/categories/index')->with('message', 'There was an error while trying to delete the category');
 }
 public function postDestroy()
 {
     $category = Category::find(Input::get('id'));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('errorMessage', 'Category Deleted');
     }
     return Redirect::to('admin/categories/index')->with('errorMessage', 'Something went wrong, please try again');
 }
Example #28
0
 public function postDestroy()
 {
     $category = Category::find(Input::get('id'));
     if ($category) {
         $category->delete();
         return Redirect::to('admin/categories/index')->with('message', 'Category deleted');
     }
     return Redirect::to('admin/categories/index')->with('message', 'Something went wrong.')->withErrors($validator)->withInput();
 }
Example #29
0
 public function getCategoryUrl()
 {
     if ($this->parent_id != null) {
         $parent_cat_details = Category::find($this->parent_id);
         return '/' . $parent_cat_details->curl . '/' . $this->curl;
     } else {
         return '/' . $this->curl;
     }
 }
Example #30
-1
 public function get_index($categoryParent, $categoryChild = null)
 {
     //Load details of the passed category
     $parentCategoryDetails = Category::where('curl', '=', $categoryParent)->first();
     if ($categoryChild == null) {
         $childCategoryDetails = null;
     } else {
         $childCategoryDetails = Category::where('curl', '=', $categoryChild)->first();
     }
     //Gets all articles in the default Sub Category
     if (is_null($parentCategoryDetails)) {
         return Response::error('404');
     }
     if (is_null($childCategoryDetails)) {
         $allarticles = Category::find($parentCategoryDetails->id)->Article()->where("status", '=', '1')->get();
     } else {
         $allarticles = Category::find($childCategoryDetails->id)->Article()->where("status", '=', '1')->get();
     }
     //Pushes all articles within the Sub category of a parent Category
     if (is_null($childCategoryDetails)) {
         $inner_categories = $parentCategoryDetails->InnerCategory()->get();
         foreach ($inner_categories as $innercat) {
             $allarticlesinner = Category::find($innercat->id)->Article()->get();
             foreach ($allarticlesinner as $innercatarticles) {
                 array_push($allarticles, $innercatarticles);
             }
         }
     }
     //A  sort on articles  using the POSTed ID
     usort($allarticles, 'cmsHelper::sortById');
     $allarticles = cmsHelper::bakeArticleForViewers($allarticles);
     //make and return the view
     return View::make('visitor.categorylist', array('allarticles' => $allarticles, 'parentCategoryDetails' => $parentCategoryDetails, 'childCategoryDetails' => $childCategoryDetails));
 }