Ejemplo n.º 1
1
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     dd('test');
     $vehicleTypes = VehicleTypeRef::all();
     Category::where('id', '>', 58)->whereNull('parent_id')->get()->each(function ($category) use($vehicleTypes) {
         $category->categories->each(function ($subCategory) use($category, $vehicleTypes) {
             //				$vehicleTypes->each(function ($vehicleType) use($category, $subCategory) {
             //					if ($subCategory->title != "{$vehicleType->ru} {$category->name}") {
             $subCategory->description = "Все об {$subCategory->title}";
             //					} else {
             //						 different description
             //					}
             //				});
             if ($subCategory->save()) {
                 $this->line($subCategory->title);
                 $this->line($subCategory->description . PHP_EOL);
             }
         });
     });
     $marks = MarkRef::all();
     Category::where('id', '>', 58)->whereNotNull('parent_id')->get()->each(function ($category) use($vehicleTypes, $marks) {
         $marks->each(function ($mark) use($category, $vehicleTypes) {
             $vehicleTypes->each(function ($vehicleType) use($category, $mark) {
                 if ($category->title == "{$vehicleType->ru} {$mark->name}") {
                     $newTitle = $this->morph($vehicleType) . $mark->name;
                     $this->line("{$category->title} to {$newTitle}");
                     // $category->title = $newTitle;
                     // $category->save();
                 }
             });
         });
     });
 }
Ejemplo n.º 2
1
 /**
  * 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'));
     }
 }
Ejemplo n.º 3
0
 function inc_left()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'knowledges' and parents <> 0")->order_by('orderlist', 'asc')->get();
     $data['count'] = $categories->where("module = 'knowledges' and parents <> 0")->count();
     $data['num'] = ceil($categories->where("module = 'knowledges' and parents <> 0")->count() / 2);
     $this->load->view('inc_index', $data);
 }
 /**
  * Display the specified category.
  *
  * @param  string $slug
  * @return Response
  */
 public function show($slug)
 {
     //return le slug de la categorie
     $categories = Category::where('slug', $slug)->firstOrFail();
     $posts = Post::where('category_id', '=', $categories->id)->orderBy('published_at', 'desc')->paginate(5);
     return View::make('categories.show', compact('categories', 'posts', 'author'));
 }
Ejemplo n.º 5
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/category/{$id}/edit")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Category::find($id);
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->content = Input::get('content');
             $table->parent_id = Input::get('parent_id') ? Input::get('parent_id') : null;
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.category");
                 return Redirect::to("admin/category")->with('success', trans("message.edit", ['name' => $name]));
             }
             return Redirect::to("admin/category")->with('error', trans('message.error'));
         }
     }
     $self = Category::where('id', '=', $id)->first();
     foreach (Category::lists('title', 'id') as $key => $value) {
         $child = Category::where('id', '=', $key)->first();
         if (!$child->isSelfOrDescendantOf($self)) {
             $categories[$key] = $value;
         }
     }
     $categories = array(0 => 'Нет родительской категории') + $categories;
     return View::make("admin.shop.category.edit", ['item' => Category::find($id), 'categories' => $categories]);
 }
Ejemplo n.º 6
0
 /**
  * Category list
  * @return Respanse
  */
 public function category($category_id)
 {
     $articles = Article::where('category_id', $category_id)->orderBy('created_at', 'desc')->where('post_status', 'open')->paginate(6);
     $categories = Category::orderBy('sort_order')->get();
     $current_category = Category::where('id', $category_id)->first();
     return View::make('article.category')->with(compact('articles', 'categories', 'category_id', 'current_category'));
 }
Ejemplo n.º 7
0
 public function showIndex()
 {
     if (!Auth::check()) {
         return View::make('login', array('title' => 'edison'));
     }
     $category_names = array('ent' => 'エンターテイメント', 'music' => '音楽', 'sing' => '歌ってみた', 'play' => '演奏してみた', 'dance' => '踊ってみた', 'vocaloid' => 'VOCALOID', 'nicoindies' => 'ニコニコインディーズ', 'animal' => '動物', 'cooking' => '料理', 'nature' => '自然', 'travel' => '旅行', 'sport' => 'スポーツ', 'lecture' => 'ニコニコ動画講座', 'drive' => '車載動画', 'history' => '歴史', 'politics' => '政治', 'science' => '科学', 'tech' => 'ニコニコ技術部', 'handcraft' => 'ニコニコ手芸部', 'make' => '作ってみた', 'anime' => 'アニメ', 'game' => 'ゲーム', 'toho' => '東方', 'imas' => 'アイドルマスター', 'radio' => 'ラジオ', 'draw' => '描いてみた', 'are' => '例のアレ', 'diary' => '日記', 'other' => 'その他', 'r18' => 'R-18', 'original' => 'オリジナル', 'portrait' => '似顔絵', 'character' => 'キャラクター');
     $all_items = Item::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($all_items as &$item) {
         $item['user'] = User::where('id', '=', $item->user_id)->get()[0];
         $item['star_count'] = Starmap::where('item_id', '=', $item->id)->count();
         $item['comment_count'] = Comment::where('item_id', '=', $item->id)->count();
         if ($item->category_id != 0) {
             $item['category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $recent_works = Work::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($recent_works as &$work) {
         $item = Item::where('id', '=', $work->item_id)->get()[0];
         $work['item'] = $item;
         $work['user'] = User::where('id', '=', $work->user_id)->get()[0];
         $work['item_poster_screen_name'] = User::where('id', '=', $item->user_id)->get()[0]->screen_name;
         if ($item->category_id != 0) {
             $work['item_category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $user = User::where('screen_name', '=', Auth::user()->screen_name)->get()[0];
     $data = array('title' => 'edison', 'user' => $user, 'all_items' => $all_items, 'recent_works' => $recent_works, 'categories' => $category_names, 'star_count' => Starmap::where('user_id', '=', $user->id)->count(), 'work_count' => Work::where('user_id', '=', Auth::user()->id)->count());
     return View::make('index', $data);
 }
Ejemplo n.º 8
0
 function index()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'webboard_quizs' and parents <> 0")->order_by('orderlist', 'asc')->get_page();
     $data['categories']->webboard_quiz->order_by("id", "desc")->get();
     $this->template->build('webboard_index', $data);
 }
 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store()
 {
     $categoryValidator = Validator::make($data = Input::all(), Category::$rules);
     if ($categoryValidator->fails()) {
         return Redirect::back()->withErrors($categoryValidator)->withInput();
     }
     /* Category */
     if (Input::has('createCategory')) {
         Category::create($data);
         $message = "登録しました。";
     }
     if (Input::has('deleteCategory')) {
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $message = "削除しました。";
         if (Input::has('selectedCategory')) {
             Input::replace(array('selectedCategory', ''));
         }
     }
     if (Input::has('updateCategory')) {
         $err = array('required' => '新しい部門名を入力してください。');
         $categoryValidator = Validator::make($data = Input::all(), Category::$update_rules, $err);
         if ($categoryValidator->fails()) {
             return Redirect::back()->withErrors($categoryValidator)->withInput();
         }
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $data['Bumon'] = $data['new_categoryName'];
         Category::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
Ejemplo n.º 10
0
 public function getTorrents($category = null)
 {
     $categories = Category::all();
     $query = Torrent::with('category')->orderBy('created_at', 'desc');
     if ($category) {
         $category = Category::where('name', '=', $category)->first();
         if ($category) {
             $query = $query->where('category_id', $category->id);
         }
     }
     $search = null;
     if (isset($_GET['text'])) {
         $search = $_GET['text'];
         $query = $query->where('name', 'LIKE', '%' . $search . '%');
     }
     $torrents = $query->get();
     $peers = DB::table('torrent_users')->select(DB::raw('torrent_id, seeding, COUNT(user_id) as count'))->groupBy('torrent_id', 'seeding')->get();
     foreach ($peers as $peer) {
         foreach ($torrents as $torrent) {
             if ($torrent->id == $peer->torrent_id) {
                 if ($peer->seeding) {
                     $torrent->seeders = $peer->count;
                 } else {
                     $torrent->leechers = $peer->count;
                 }
             }
         }
     }
     return View::make('torrents/torrents', array('torrents' => $torrents, 'categories' => $categories, 'category' => $category, 'search' => $search));
 }
Ejemplo n.º 11
0
 /**
  * Produce new products
  *
  * @return Response
  */
 public function produce()
 {
     $category_id = Category::where('cat_name', '=', 'Cupcake')->first()->id;
     $items = $this->item->where('category_id', '=', $category_id)->get();
     // return $items = $this->item->getItemsWithInventoryStatus();
     return View::make('items.production.produce')->with('title', 'New Production')->with('items', $items);
 }
Ejemplo n.º 12
0
 /**
  * Show the form for editing the specified resource.
  * GET /articles/{id}/edit
  *
  * @param  string $slug
  * @return Response
  */
 public function edit($slug)
 {
     $articles = Article::where('slug', $slug)->first();
     $category = Category::lists('category', 'id');
     $selected = Category::where('id', $articles->category_id)->first()->id;
     return View::make('article.editpost')->with('articles', $articles)->with('category', $category)->with('selected', $selected);
 }
Ejemplo n.º 13
0
 function index()
 {
     $rs = new Category();
     $data['rs'] = $rs->where('module = "services"')->order_by('id', 'desc')->get();
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/index', $data);
 }
Ejemplo n.º 14
0
 protected function setupLayout()
 {
     if (!is_null($this->layout)) {
         $this->layout = View::make($this->layout);
         $this->layout->menuCategories = Category::where('parent_id', 0)->get();
     }
 }
Ejemplo n.º 15
0
 public function get_list($id = 0)
 {
     $breadcrumbs = Breadcrumbs::get($id);
     $categories = $id ? Category::find($id)->children : Category::where('parent', '=', 0)->get();
     $products = $id ? Category::find($id)->products : array();
     $this->layout->page_title = "Admin - Categories - List";
     $this->layout->page_content = View::make('admin.categories.list')->with('id', $id)->with('breadcrumbs', $breadcrumbs)->with('categories', $categories)->with('products', $products);
 }
Ejemplo n.º 16
0
 public function has_children()
 {
     $all_categories = new Category();
     foreach ($all_categories->where('parent_id', $this->id)->get() as $category) {
         return true;
     }
     return false;
 }
Ejemplo n.º 17
0
 function form($id = FALSE)
 {
     $data['email'] = new Newsletters_email_list($id);
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'newsletters' and parents <> 0 and status = 'approve'")->order_by('id', 'desc')->get_page();
     $this->load->view('inc_register', $data);
     $this->template->build('admin/emaillist_form', $data);
 }
Ejemplo n.º 18
0
 public function index()
 {
     $category = Category::where("level", 1)->lists("name", "code");
     $resource = $this->resource;
     $resourceName = $this->resourceName;
     $resourceDesc = '';
     return View::make($this->resourceView . '.index')->with(compact('resource', 'resourceName', 'resourceDesc'));
 }
Ejemplo n.º 19
0
 /** 
  *	Sua 1 category
  *	@var string category_id
  *	@return boolean
  */
 public static function renameCategory($category_id, $name)
 {
     $result = Category::where('category_id', '=', $category_id)->update($name);
     if ($result > 0) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 20
0
 public function categories()
 {
     $categories = Category::where('status', '=', 'active')->get();
     if (isset($categories) && count($categories) > 0) {
         return json_encode(array('message' => 'found', 'categories' => $categories->toArray()));
     } else {
         return json_encode(array('message' => 'empty'));
     }
 }
Ejemplo n.º 21
0
 /**
  * Automatically set the alias, if one is not provided
  * @param string $alias
  */
 public function setAliasAttribute($alias)
 {
     if ($alias == '') {
         $this->attributes['alias'] = Str::slug($this->attributes['name'], '-');
         if (Category::where('alias', '=', $this->attributes['alias'])->first()) {
             $this->attributes['alias'] = Str::slug($this->attributes['name'], '-') . '-1';
         }
     }
 }
Ejemplo n.º 22
0
 protected function checkExistCategory($categoryId)
 {
     $category = Category::where('categoryId', $categoryId)->first();
     if (is_null($category)) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 23
0
 /**
  * Returns an array of all hidden categories
  * @return array
  */
 public static function getHiddenCategoriesArray()
 {
     $categories = Category::where('hidden', '=', 1)->get();
     $hiddenCategories = array();
     foreach ($categories as $category) {
         $hiddenCategories[$category->id] = $hiddenCategories->name;
     }
     return $hiddenCategories;
 }
Ejemplo n.º 24
0
 function form($id = FALSE)
 {
     $categories = new Category();
     $categories->where("module = 'galleries' and parents = 0")->get();
     $data['parent'] = $categories->get_clone();
     $categories->clear();
     $data['category'] = $categories->get_by_id($id);
     $this->template->build('admin/category_form', $data);
 }
Ejemplo n.º 25
0
 public function getCategories($type)
 {
     $categories = Category::where('type', '=', $type)->get();
     $ret = array();
     foreach ($categories as $category) {
         $ret['category'][] = array('category_id' => $category->id, 'content' => $category->content);
     }
     return json_encode($ret);
 }
Ejemplo n.º 26
0
 /**
  * Process the item on the Sales Order list.
  * GET /sales/registrar
  *
  * @return Response
  */
 public function processOrder($code)
 {
     // return print $code;exit();
     //find the item on the storage
     $found = $this->findItem($code);
     $in_production = false;
     $general_item = false;
     if ($found) {
         //cupcake category id
         $cupcake_cat_id = Category::where('cat_name', '=', 'Cupcake')->first()->id;
         if ($this->item->getCategory($code) == $cupcake_cat_id) {
             //check if the item exist on the production items
             $production_items = $this->production_item->getCurrentProductionsBarcodes();
             if (in_array($code, $production_items)) {
                 $in_production = true;
                 //check if  the item have enough stocks
                 if (!$this->haveEnoughStocks($code)) {
                     return Response::json(array('response' => '300', 'msg' => 'Not enough stocks.'));
                 }
             } else {
                 //not set for production
                 return Response::json(array('response' => '300', 'msg' => 'Not set in production'));
             }
         } else {
             //item is not a cupcake
             //general item  / cookies
             $in_production = true;
             $general_item = true;
         }
         //check if the barcode exist on the cart
         $exist = $this->doExist($code);
         //get the item based on the barcode
         $item = $this->findItem($code);
         //if the product already exist, update its qty
         if ($exist) {
             //before updating qty, check first for the remaining stocks
             $this->updateQty($code, $general_item);
             //check if the cupcake does  exist on the cart list
         } else {
             if (!$exist) {
                 if ($in_production) {
                     $this->insertToTempCart($code, $item);
                 } else {
                     //not in production or out of stocks
                     return Response::json(array('response' => '300'));
                 }
             }
         }
         // $this->printInvoice();
         //retrieve cart items
         return $this->retrieveItems();
         //print receipt
     }
     //throw a not found exception
     return Response::json(array('found' => 'false'));
 }
Ejemplo n.º 27
0
 /**
  * Show the form for creating a new service
  *
  * @return Response
  */
 public function createservice()
 {
     // return "entro a servicios";
     if (Auth::check() || Session::has('account_id')) {
         $categories = Category::where('account_id', Auth::user()->account_id)->orderBy('public_id')->get();
         return View::make('productos.createservice')->with('categories', $categories);
     } else {
         return Redirect::to('/');
     }
 }
Ejemplo n.º 28
0
 public function getCategory($category)
 {
     $cat = Category::where('name', $category)->first();
     if ($cat) {
         $products = Product::where('category_id', $cat->id)->orderBy('created_at', 'ASC')->get();
         return View::make('store.category')->with('cat', $cat)->with('products', $products);
     } else {
         return View::make('404');
     }
 }
Ejemplo n.º 29
0
 public function showHome()
 {
     $todaysDate = Carbon::now();
     $event = CalendarEvent::where('date', '>', $todaysDate)->get()->random();
     // dd($event);
     $categoryId = $event->category_id;
     $category = Category::where('id', '=', $categoryId)->first();
     $group = Group::with('categories')->where('group_name', '<>', '')->get()->random();
     return View::make('index')->with(array('event' => $event, 'group' => $group, 'category' => $category));
 }
Ejemplo n.º 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));
 }