Ejemplo n.º 1
0
 public function pullCategories()
 {
     $uri = 'https://tartan.plaid.com/categories';
     $client = new Client();
     $response = $client->get($uri);
     $array = json_decode($response->getBody(), true);
     //var_dump($array['66']);
     foreach ($array as $record) {
         $category = new Categories();
         foreach ($record as $key => $value) {
             if ($key == 'id') {
                 if (Categories::where('Cat_ID', '=', $value)->exists()) {
                     break;
                 }
                 $category['Cat_ID'] = $value;
             }
             //echo "I should not be here";
             if ($key == 'type') {
                 $category['Type'] = $value;
             }
             if ($key == 'hierarchy') {
                 $category['c1'] = $value['0'];
                 isset($value['1']) ? $category['c2'] = $value['1'] : ($category['c2'] = null);
                 isset($value['2']) ? $category['c3'] = $value['2'] : ($category['c3'] = null);
             }
             $category->save();
         }
     }
     return view('categories')->with('data', $array);
 }
Ejemplo n.º 2
0
 public function post_year($year)
 {
     // возвращаем посты за year
     # обращаемся к моделе Category
     $Categories = new Categories();
     $categories = $Categories->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     $Posts_model = new Posts();
     $posts = $Posts_model->post_of_year($year);
     return view('layouts.default', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
 }
Ejemplo n.º 3
0
 public function index()
 {
     # обращаемся к моделе Category
     $vrode_model = new Categories();
     $categories = $vrode_model->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     //Получение разбитого на страницы запроса из базы данных:
     $postsi = new Posts();
     $per_page = 10;
     $posts = $postsi->post_paginate($per_page);
     return view('layouts.default', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
 }
Ejemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CategoryRequest|Request $request
  * @return Response
  */
 public function store(CategoryRequest $request)
 {
     $this->validate($request, ['name' => 'required']);
     Categories::create(['name' => $request->get('name')]);
     message()->success('Alright Sparky !', 'You have created the category !');
     return redirect('/category');
 }
Ejemplo n.º 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $infoArr = [["cat_name" => "先锋网络部专版"], ["cat_name" => "吐槽什么什么的"], ["cat_name" => "技术宅们的世界"], ["cat_name" => "音游交流区"], ["cat_name" => "niconico 分享"], ["cat_name" => "声控灯"], ["cat_name" => "管理版"]];
     foreach ($infoArr as $data) {
         Categories::create($data);
     }
 }
Ejemplo n.º 6
0
 public function pullCategories()
 {
     $uri = 'https://tartan.plaid.com/categories';
     $client = new Client();
     $response = $client->get($uri);
     $categories = json_decode($response->getBody(), true);
     // var_dump($categories);
     foreach ($categories as $category_key => $category_value) {
         $category = Categories::find($category_value['id']);
         if (!$category) {
             $category = new Categories();
             $category['id'] = $category_value['id'];
             $category['type'] = $category_value['type'];
             isset($category_value['hierarchy'][0]) ? $category['c1'] = $category_value['hierarchy'][0] : ($category['c1'] = null);
             isset($category_value['hierarchy'][1]) ? $category['c2'] = $category_value['hierarchy'][1] : ($category['c2'] = null);
             isset($category_value['hierarchy'][2]) ? $category['c3'] = $category_value['hierarchy'][2] : ($category['c3'] = null);
             // if(isset($category_value['meta']['location']['city']))
             //     $category['location_city'] = $category_value['meta']['location']['city'];
             var_dump($category);
             $category->save();
             // die;
         }
     }
     return view('categories')->with('data', $category);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     //        $user_id = 1;
     //        $productsCount = Products::count();
     //        $product = Products::get();
     //        $ordersCount = DB::select('select count(*) as say from orders where cast(created_at as DATE) = ?', array(Carbon::now()->format('Y-m-d')));
     //
     //        if ($productsCount != ($ordersCount[0]->say)) {
     //            foreach ($product as $key => $pro) {
     ////                $ordersCount = DB::select('select count(*) as say from orders where cast(created_at as DATE) = ? and ProductName = ? ', array(Carbon::now()->format('Y-m-d'), $pro->Name));
     ////dd(Carbon::now()->format('Y-m-d h:i:s'));
     ////                dd(Carbon::now());
     //                $today = Carbon::now()->format('Y-m-d h:n:s');
     //                $ifnotinsert = DB::insert(DB::raw("INSERT INTO orders (ProductName,CustomerId,CustomerName,quantity,Alish,Satish,Income,created_at,updated_at,user_id)
     //SELECT * FROM (SELECT '$pro->Name' as name, '$pro->CustomerId' as cusid, '$pro->CustomerId'  as cusname, 0 as quantity , '$pro->Alish' as alish , '$pro->Satish'  as satish, '$pro->Income'  as income, '$today'  as created_at, '$today' as updated_at,0 as user_id) AS tmp
     //WHERE NOT EXISTS (
     //    SELECT * FROM orders WHERE ProductName = '$pro->Name' and CustomerId = '$pro->CustomerId' and Format(Alish,2) = Format('$pro->Alish',2) AND
     //Format(Satish,2)= Format('$pro->Satish',2)) LIMIT 1"));
     //
     //            }
     //        }
     $CustomerName = Customers::lists('name', 'id');
     $CategoryName = Categories::lists('name', 'id');
     return view('orders.newAlish', compact('CustomerName', $CustomerName), compact('CategoryName'));
 }
Ejemplo n.º 8
0
 public function index($category)
 {
     $categories = Categories::all();
     $topics = new Topic();
     $topics = $topics->getTopicChannel($category);
     $title = $category;
     return view('channel', compact('categories', 'topics', 'title'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $category = Categories::findOrFail($id);
     $this->validate($request, ['name' => 'required|max:100']);
     $category->update($request->all());
     Flash::success('Category updated');
     return redirect()->action('CategoriesController@index');
 }
Ejemplo n.º 10
0
 public static function children($id)
 {
     $child = Categories::whereParent($id)->get();
     if (count($child)) {
         return $child;
     }
     return false;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $categories = Categories::all();
     $jsonArray = [];
     foreach ($categories as $category) {
         $jsonArray[] = ["categoryId" => $category->category_id, "categoryName" => $category->name, "categoryDescription" => $category->description];
     }
     return response()->json($jsonArray);
 }
Ejemplo n.º 12
0
 public function index($id = 0)
 {
     $categories = Categories::all();
     $categories = $categories->sortBy('sort_id');
     $item = Items::find($id);
     $comments = Comments::where('items_id', '=', $id)->get();
     $data = ['categories' => $categories, 'item' => $item, 'id' => $item->categories_id, 'comments' => $comments];
     return view('items.index', $data);
 }
Ejemplo n.º 13
0
 public function cachecate()
 {
     $data = \App\Categories::select(array('id', 'name'))->whereRaw("cid_parent=0 AND status='1'")->orderBy("id", "ASC")->get();
     $j = array();
     foreach ($data as $key => $value) {
         $j[] = array($value['id'], IndexController::toAlias2($value['name']));
     }
     echo json_encode($j);
 }
Ejemplo n.º 14
0
 public function index($slug)
 {
     # обращаемся к моделе Category
     $vrode_model = new Categories();
     $categories = $vrode_model->cats_for_header();
     // проверка на правильнось данных
     /*
     $post = DB::table('pages')
     ->where('slug', '=', "$slug")
     
     ->get();
     */
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     $post = $pages->page_text($slug);
     return view('layouts.page_lay', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'post_content', 'post' => $post]);
 }
Ejemplo n.º 15
0
 public function user_posts_all(Request $request)
 {
     //
     $user = $request->user();
     $posts = Posts::where('author_id', $user->id)->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     $id = $request->user()->id;
     $categories = Categories::where('author_id', $id);
     return view('home')->withPosts($posts)->withTitle($title)->withTitlecategory('Categories')->withCategories($categories);
 }
Ejemplo n.º 16
0
 /**
  * @param Request $request
  * @param $id
  * @return mixed
  */
 public function edit(Request $request, $id)
 {
     $comment = Comments::where('id', $id)->first();
     $user = $request->user();
     $categories = Categories::all();
     if ($user->is_admin() or $user->is_moderator() or $user->id == $comment->user_id) {
         return view('comment.edit')->withComment($comment)->withCategories($categories);
     } else {
         redirect('/')->withErrors('You have not sufficient permissions');
     }
 }
Ejemplo n.º 17
0
 public static function getCategories()
 {
     $resultArr = [];
     $catsObj = Categories::all();
     foreach ($catsObj as $cat) {
         $tmpData = ['cat_id' => $cat->cat_id, 'cat_name' => $cat->cat_name];
         array_push($resultArr, $tmpData);
     }
     //var_dump($resultArr);
     return $resultArr;
 }
Ejemplo n.º 18
0
 public function index($id = 0)
 {
     # обращаемся к моделе Category
     $vrode_model = new Categories();
     $categories = $vrode_model->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     if ($id == 0 || empty($id)) {
         //Нету номера выводим рандомную цытату
         $ex_id = mt_rand(1, 366);
     } else {
         // выведем цытату с номером в заросе
         if ($id > 366 || $id <= 0) {
             return view('errors.404');
         }
         $ex_id = $id;
     }
     $excerptions_model = new Excerptions();
     $ex = $excerptions_model->index($ex_id);
     return view('layouts.default', ['categories' => $categories, 'pages' => $footer_pages, 'ex' => $ex, 'content_layout' => 'ex_content']);
 }
Ejemplo n.º 19
0
 public static function getColumn($column)
 {
     $array = Categories::all();
     $result = array();
     foreach ($array as $item) {
         $result += array($item['id'] => $item[$column]);
     }
     if (count($result) > 0) {
         return $result;
     } else {
         return array('-1' => 'Chưa có Category nào được tạo. Liên hệ Webmaster');
     }
 }
Ejemplo n.º 20
0
 public function index($slug = 0)
 {
     # обращаемся к моделе Category
     $category_model = new Categories();
     $categories = $category_model->cats_for_header();
     # обращаемся к моделе Page
     $pages = new Page();
     $footer_pages = $pages->footer_pages();
     if (isset($slug) && !empty($slug)) {
         //категория есть, выводим по ней посты
         //тут нужно сначала проверить категорию и вытащить ее айди
         $cat_id = $category_model->select_cat($slug);
         $postsi = new Posts();
         $posts = $postsi->post_of_category($slug);
         return view('layouts.category_lay', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
     } else {
         //категория не указана, выводим список категорий
         // зделаем запрос на категорию с картинкой и количеством постов внем
         $posts = $category_model->cats_page();
         return view('layouts.categories_lay', ['categories' => $categories, 'pages' => $footer_pages, 'content_layout' => 'posts_content', 'posts' => $posts]);
     }
     // return view('layouts.default',['categories' => $categories]);
 }
Ejemplo n.º 21
0
    /**
     * @return mixed
     */
    public function data()
    {
        $categories = Categories::select('id', 'name', 'description', 'slug')->orderBy('id', 'desc');
        return Datatables::of($categories)->editColumn('name', '
				<a href="#"><b>{{$name}}</b></a>
				<div class="row-actions hide">
					<a href="{{{ URL::to(\'admin/categories/edit/\' . $id . \'/\') }}}">Edit</a>
					|
					<a class="delete-tag" href="{{ URL::to(\'admin/categories/delete/\' . $id .\'/\') }}"
						onclick=" return confirm(\'Are you want to delete\')">Delete</a>
					|
					<a href="#">View</a>
				</div>
			')->editColumn('id', '<input id="cb-select-all-1" type="checkbox" data="{{$id}}">')->make();
    }
 public function show($slug)
 {
     /**
      * @var $category Categories
      */
     $category = Categories::where('slug', $slug)->first();
     if ($category == NULL) {
         return redirect('/')->withErrors('Requested url does not exist');
     }
     $categories = Categories::all();
     /**
      * @var $products Products
      */
     $products = $category->products()->paginate(9);
     return view('home')->withProducts($products)->withCategories($categories)->withTitle('Products from the  category ' . $category->title);
 }
Ejemplo n.º 23
0
 public function index($id = 0)
 {
     //get rundom category
     if ($id == 0) {
         $category = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(1)->get();
         $id = $category[0]->id;
     }
     //get all categories for menu
     $categories = Categories::all();
     $categories = $categories->sortBy('sort_id');
     //get categories for slider
     $sliders = Categories::where('parent_id', '!=', 0)->orderBy(DB::raw('RAND()'))->take(3)->get();
     //get items
     $items = Items::where('categories_id', '=', $id)->get();
     $data = ['categories' => $categories, 'items' => $items, 'id' => $id, 'sliders' => $sliders];
     return view('categories.index', $data);
 }
Ejemplo n.º 24
0
 public function sort(Request $request)
 {
     $criterion = $request->get('criterion');
     $order = $request->get('order');
     $posts = Posts::where('active', 1)->orderBy($criterion, $order)->paginate(5);
     $titlepost = 'News';
     $titlecategory = 'Categories';
     $categories = Categories::all();
     return view('home')->withPosts($posts)->withCategories($categories)->withTitlepost($titlepost)->withTitlecategory($titlecategory)->withCriterion($criterion)->withOrder($order);
     //		var_dump($posts[0]->title);
     //		die();
 }
Ejemplo n.º 25
0
 /**
  * Создание категории (AJAX)
  */
 public function addCategory(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'url' => 'required']);
     $category = new Categories();
     $category->title = $request->title;
     $category->slug = $request->url;
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = str_random(10);
         $extension = $file->getClientOriginalExtension();
         $surl = $this->globalSiteSettings['site_url'];
         $imgurl = $surl . '/uploads/' . $filename . '.' . $extension;
         Image::make($request->file('image'))->fit(135, 120)->save(public_path() . '/uploads/' . $filename . '.' . $extension);
         $category->img = $imgurl;
     }
     if ($category->save()) {
         Session::flash('success', 'Категория «' . $request->title . '» успешно создана.');
         return redirect()->back();
     }
     return response()->json(['status' => 'error']);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Categories::destroy($id);
     return redirect('categories');
 }
Ejemplo n.º 27
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $categories = Categories::all();
     $user = User::find(Auth::user()->id);
     /*echo $user;
       echo $user->uuid;*/
     if (empty($user->displayname)) {
         return redirect()->action('ProfileController@createName');
     }
     $followFeed = new Users_follow();
     $topics = $followFeed->getFeed(Auth::user()->uuid);
     //        print_r($topics);
     return view('home', compact('categories', 'topics'));
 }
Ejemplo n.º 28
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $myasset = MyAsset::findOrFail($id);
     $categories = Categories::distinct()->select('name')->where('creater_id', Auth::id())->orderBy('id', 'desc')->get();
     return view('myasset.edit')->with('myasset', $myasset)->with('category', $categories);
 }
Ejemplo n.º 29
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Requests\PostsFormRequest $request)
 {
     $post = Posts::findOrFail($id);
     $input = $request->all();
     $input['alias'] = HelperFunctions::str2url($request->title);
     $post->update($input);
     $categories_ids = [];
     foreach ($input['categories_list'] as $value) {
         $category = Categories::findOrNew($value);
         if ($category->exists) {
             array_push($categories_ids, $value);
         } else {
             $category->name = $value;
             $category->save();
             array_push($categories_ids, $category->id);
         }
     }
     $post->categories()->sync($categories_ids);
     $tags_ids = [];
     foreach ($input['tags_list'] as $value) {
         $tag = Tags::findOrNew($value);
         if ($tag->exists) {
             array_push($tags_ids, $value);
         } else {
             $tag->name = $value;
             $tag->save();
             array_push($tags_ids, $tag->id);
         }
     }
     $post->tags()->sync($tags_ids);
     \Session::flash('success', 'Post updated');
     return redirect('/');
 }
Ejemplo n.º 30
0
 public function updateCategoryPost()
 {
     $categories = Categories::where('added_by', Session::get('id'))->get();
     $data = Input::get('enabled');
     foreach ($categories as $category) {
         if (in_array($category->id, $data)) {
             $category->is_enabled = "yes";
             $category->save();
         } else {
             $category->is_enabled = "no";
             $category->save();
         }
     }
     Flash::success('Category preferences updated successfully.');
     return redirect('/admin/categories/manage');
 }