/** * Show all products by category id. * * @param $id * @return \Illuminate\View\View */ public function category($id) { $categories = $this->category->orderBy('name')->get(); $products = $this->product->where('category_id', '=', $id)->paginate(8); $categoryName = $this->category->find($id)->name; return view('ecomm.shop.partial.products-category', compact('categories', 'products', 'categoryName')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $job_id = $id; $job_info = Job::find($job_id); $job_category_info = JobCategory::where('job_id', '=', $job_id)->get(); $category_array = array(); foreach ($job_category_info as $a_job_category) { $a_category_id = $a_job_category->category_id; $a_category_value = Category::find($a_category_id)->kategori; $category_array[count($category_array)] = $a_category_value; } $data['job_info'] = $job_info; $data['category_array'] = $category_array; // find out whether the logged-in user have already request this job (as a seeker) // if the owner of this job is the logged-in user, then don't show the request button $show_request_button = true; $this_is_the_owner = false; if (Auth::user() != null) { $logged_user_id = Auth::user()->id; if ($job_info->freelancer_info_id == $logged_user_id) { // if the owner of this job is the logged-in user $show_request_button = false; $this_is_the_owner = true; } else { // if logged-in user already request this job (as a seeker) if (JobRequest::find($job_id, $logged_user_id) != null) { $show_request_button = false; } } } else { //if guest (not logged-in user) } return View::make('job.show')->with('data', $data)->with('jobs', $job_info)->with('job_id', $id)->with('show_request_button', $show_request_button)->with('this_is_the_owner', $this_is_the_owner); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $category = Category::find($id); $category->name = $request->name; $category->save(); return redirect()->route('category.index'); }
/** * Show user receipts of a specific Category. * * @param int $id * @return Response */ public function browseCategory($id) { $receipts = Receipt::whereHas('categories', function ($query) use($id) { $query->where('id', '=', $id); })->where('user_id', '=', $this->user->id)->paginate(); return view('pages.receipts', compact('receipts'))->with('page_title', Category::find($id)->name); }
public function deactivate($id) { $category = Category::find($id); $category->status = 0; $category->save(); return redirect('home/categories'); }
public function showByUser($user_id) { //directly copied pasted from list controller. $list = Vote::where('user_id', '=', $user_id)->get(); $user_list = []; foreach ($list as $pro) { $product_id = $pro->product_id; $product = Product::find($product_id); if ($product != null) { $created_by = $product['created_by']; $category = Category::find($product['category_id']); $category = $category['category']; $user = User::find($created_by); array_add($product, 'category', $category); array_add($product, 'created_by_name', $user['name']); $initial = explode(".", $product['image_url']); $thumbFirst = ""; for ($i = 0; $i < sizeof($initial) - 1; $i++) { $thumbFirst = $thumbFirst . $initial[$i]; } $thumbnail = $thumbFirst . '-200x200.' . $initial[sizeof($initial) - 1]; array_add($product, 'thumbnail', $thumbnail); array_push($user_list, $product); } } return $user_list; // return response()->json([ // 'upvotted'=>$user_list] // ); }
public function categories() { $view = Input::get('view'); if ($view == null) { return redirect('/admin/categories?view=hierarchy'); } $levels = ['Main Category', 'Subcategory', 'Post Sub Category']; $types = ['main-categories', 'sub-categories', 'post-sub-categories']; $views = ['Hierarchy', 'Type', 'All']; $cats = Category::roots()->get(); $category = Input::get('category'); $_category = Category::find($category); if ($view == 'type') { $type = Input::get('type'); if ($type == null) { $type = $types[0]; } // array_keys() = get keys from value // appends() = add 'get' variables (to url) $cats = Category::whereDepth(array_keys($types, $type))->paginate(25)->appends(Input::except('page')); } else { if ($view == 'all') { $cats = Category::paginate(25)->appends(Input::except('page')); } } return view('admin.main')->with('category', $_category)->with('cats', $cats)->with('levels', $levels)->with('view', $view)->with('views', $views)->with('types', $types); // only for 'type' view }
public function store(Request $request) { $validator = Validator::make($request->all(), ['name' => 'required|max:100', 'model' => 'max:100', 'category_id' => 'required|array', 'photo' => 'image|max:2048']); if (!$validator->fails()) { $categories_id = $request->input('category_id'); $catTitles = ""; // add title and comma for success message foreach ($categories_id as $index => $id) { $catTitles .= Category::find($id)->title; if ($index + 1 != count($categories_id)) { $catTitles .= ", "; } } $product = Product::create(['name' => $request->input('name'), 'model' => $request->input('model')]); $product->categories()->attach($categories_id); if ($request->hasFile('photo')) { $uploaded_photo = $request->file('photo'); $extension = $uploaded_photo->getClientOriginalExtension(); $filename = md5(time()) . '.' . $extension; $destinationPath = public_path('img'); $uploaded_photo->move($destinationPath, $filename); } $product->photo = $filename; $product->save(); return redirect('products')->with('successMsg', $request->input('name') . ' has been successfully created under : ' . $catTitles); } else { return redirect()->back()->withErrors($validator)->withInput(); } }
public function index() { $updates = new Update(); $category = Category::find(4); $now = Carbon::now(); return view('about.galleries.index', compact('updates', 'now', 'category')); }
/** * Destroy the given category. * * @param Request $request * @param string $categoryId * @return Response */ public function destroy(Request $request, $categoryId) { $category = Category::find($categoryId); $this->authorize('destroy', $category); $category->destroy($categoryId); return redirect('/categories'); }
public function edit($id, $extra = array()) { $category = \App\Category::find($id); $extra['parents'] = array_filter($this->getParents($category)); $extra['selectedParentId'] = $id; return parent::edit($id, $extra); }
public function razredi($id) { $category = Category::find($id); $students = Student::where('category_id', '=', $category->id)->get(); //return $category; return view('reports.razred')->with('category->id', $category->id)->with('students', $students)->with('category', $category); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); // Topic $topicCategorys = ['Talk', 'Party', 'Movie', 'Music', 'Goods', 'Sport', 'Game']; foreach ($topicCategorys as $index => $category) { Category::create(['name' => $category, 'type_id' => Category::TYPE_TOPIC]); } // children Topic $topicCategorys = Category::where('type_id', '=', Category::TYPE_TOPIC)->lists('id')->toArray(); foreach (range(1, 20) as $index) { $parentId = $faker->randomElement($topicCategorys); $name = Category::find($parentId)->name; Category::create(['name' => $name . $index, 'type_id' => Category::TYPE_TOPIC, 'parent_id' => $parentId]); } // Article $articleCategorys = ['Hot News', 'BeiJing', 'China', 'America', 'England']; foreach ($articleCategorys as $index => $category) { Category::create(['name' => $category, 'type_id' => Category::TYPE_ARTICLE]); } // Blog $blogCategorys = ['Uncategory', 'Log', 'Heavy']; foreach ($blogCategorys as $index => $category) { Category::create(['name' => $category, 'type_id' => Category::TYPE_BLOG]); } }
public function show_for_other_user($user_id) { $list = Lists::where('user_id', '=', $user_id)->get(); $user_list = []; foreach ($list as $pro) { $product_id = $pro->product_id; $product = Product::find($product_id); if ($product != null) { $created_by = $product['created_by']; $category = Category::find($product['category_id']); $category = $category['category']; $user = User::find($created_by); array_add($product, 'category', $category); array_add($product, 'created_by_name', $user['name']); $initial = explode(".", $product['image_url']); $thumbFirst = ""; for ($i = 0; $i < sizeof($initial) - 1; $i++) { $thumbFirst = $thumbFirst . $initial[$i]; } $thumbnail = $thumbFirst . '-130x90.' . $initial[sizeof($initial) - 1]; //thumb size changed array_add($product, 'thumbnail', $thumbnail); array_push($user_list, $product); } } return response()->json(['list' => $user_list]); }
public function updateCategory(Request $request, $id) { $Category = Category::find($id); $Category->name = $request->input('name'); $Category->save(); return response()->json($Category); }
public function search_in_category(Request $request, $get_category_id, $get_subcategory_id) { $items = $this->get_category($get_category_id, $get_subcategory_id, $request->search_term, true); $category_title = $get_category_id == 0 ? "Все товары" : Category::find($get_category_id)->title; $subcategory_title = $get_subcategory_id == 0 ? "Все товары" : Sub_category::find($get_subcategory_id)->title; return view('viewcategory', ['items' => $items, 'category_id' => $get_category_id, 'category_title' => $category_title, 'subcategory_id' => $get_subcategory_id, 'subcategory_title' => $subcategory_title]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $category = Category::find(4); $updates = new Update(); $now = Carbon::now(); return view('academylife.sports.index', compact('updates', 'category', 'now')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($cat_id) { //return view('store.category') //->with('product',Product::find($id)); return view('store/category')->with('products', Product::where('category_id', '=', $cat_id)->paginate(2))->with('category', Category::find($cat_id)); // dd($cat_id); }
/** * Return all all articles */ public function getIndex(Request $request) { $articles = Article::where('active', 1); /** * Filter by category */ if ($request->has('category')) { $filter_category = $request->get('category'); $category = Category::find($filter_category); // if there is no category with this name if (!$category) { return response()->json(['code' => '404', 'message' => 'There is no category with this id'], 404); } // if category is exists $articles = $category->articles(); } /** * Filter by order */ if ($request->has('order')) { $fitler_order = $request->get('order'); if ($fitler_order == 'desc' || $fitler_order == 'asc') { $articles->orderBy('views', $fitler_order); } } return response()->json(['code' => '200', 'data' => $articles->get()], 200); }
public static function display($parent_id) { $category = Category::find($parent_id); if (isset($category) && !empty($category)) { echo $category->name; } }
public function show($id) { $product = Product::find($id); $product_categories = $product->categories()->lists('id')->toArray(); $similair = Category::find($product_categories[array_rand($product_categories)])->products()->whereNotIn('id', array($id))->orderByRaw("RAND()")->take(6)->get(); helperFunctions::getPageInfo($sections, $cart, $total); return view('site.product', compact('sections', 'product', 'similair', 'cart', 'total')); }
public function update(CategoryRequest $request, $id) { $cat = Category::find($id); $cat->name = $request->name; $cat->save(); Flash::warning("La Categoría ha sido editada de manera exitosa!"); return redirect()->route('admin.categories.index'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $category = Category::find($id); $category->name = $request->input('name'); $category->weight = $request->input('weight'); $category->save(); return redirect('/back/goals'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $twitter = $this->getTweets(); $category = Category::find(1); $updates = new Update(); $now = Carbon::now(); return view('about.news.index', compact('updates', 'category', 'now', 'twitter')); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, CategoryUpdateRequest $request) { $category = Category::find($id); $category->fill($request->all()); $category->save(); flash()->warning('La categoria fue editada correctamente'); return Redirect::to('admin/categories'); }
public function postNew(SubjectRequest $req) { $subject = new Subject($req->all()); $category = Category::find($req->input('categories')); $category->subjects()->save($subject); session()->flash('flash_mess', 'Subject was created completely'); return redirect(action('SubjectController@getIndex')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validate($request, ['name' => 'required|max:255']); $category = Category::find($id); $category->name = $request->input('name'); $category->save(); return redirect('categories'); }
/** * Update the specified resource in storage. * * @param UpdateCategoryRequest $request * @param int $id * @return RedirectResponse */ public function update(UpdateCategoryRequest $request, $id) : RedirectResponse { $category = Category::find($id); $params = $request->all(); $params['slug'] = strtolower($params['slug']); $category->update($params); return Redirect::route('back.category.index')->with('message', ucfirst(trans('back/category.success_updated'))); }
public function getDelete($id) { $category = Category::find($id); if ($category) { $category->delete(); } return redirect('categories'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $category = Category::find($id); $category->category_name = $request->category_name; $category->gender_id = $request->gender_id; $category->update(); return redirect('admin/categories'); }