public function beforeRender()
 {
     $this->template->categories = $this->category->where('parent IS NULL');
     $this->category->createSelectionInstance();
     $this->template->manufacturers = $this->manufacturer;
     $this->template->filterName = 'Doporučené';
     $this->template->goodsRecommended = array();
     $this->template->goodsOther = array();
     $this->template->selectedCategoryId = null;
     $this->template->selectedSubcategoryId = null;
     $this->template->selectedManufacturerId = null;
 }
Example #2
0
 public function show()
 {
     $data['categories'] = Category::where('pid', 0)->get();
     $data['activity_classification'] = ActivityClassification::all();
     $data['free_post'] = FreePost::all();
     return view('admin.goods.index', $data);
 }
Example #3
0
 public function delete($id)
 {
     Category::find($id)->delete();
     Category::where('pid', $id)->delete();
     $ret['meta']['code'] = 1;
     echo json_encode($ret);
 }
Example #4
0
 public function edit(Request $request)
 {
     $id = $request->route('id');
     $cats = CategoryModel::where("cat_status_cd", "ACT")->get(["cat_id", "cat_desc"]);
     $page = PageModel::findOrFail($id);
     return view('pages.edit', compact('page', 'cats'));
 }
Example #5
0
 /**
  * Hiển thị danh sách các bài viết thuộc category đã chọn
  *
  * @return Response
  */
 public function category($cat_url)
 {
     /* Tìm bản ghi trong bảng Categories có điều kiện thỏa mãn */
     $cat_id = Category::where('cat_url', $cat_url)->first();
     /* Tìm các bản ghi trong bảng News có điều kiện thỏa mãn */
     return Response::json(News::where('news_category', $cat_id->id)->orderBy('id', 'desc')->get());
 }
Example #6
0
 /**
  * カテゴリー編集画面
  */
 public function getUpdate($id)
 {
     $category = Category::where('user_id', Auth::user()->id)->where('id', $id)->where('not_delete_flag', 0)->get();
     if (count($category) == 0) {
         abort(404, 'ページが存在しません。');
     }
     return view('categories.update')->with('category', $category);
 }
 public function show($id = 0)
 {
     if (!preg_match("/^[1-9]\\d*\$/", $id)) {
         return Redirect::to('/');
     }
     $parent = Category::find($id);
     if (!$parent) {
         return Redirect::to(route('admin.category.index'));
     }
     $categories = Category::where('parent_id', $id)->get();
     return Theme::view('admin.category.show', compact('categories', 'parent'));
 }
Example #8
0
 public function destroy($id)
 {
     //
     $son = Category::where('parent_id', '=', $id)->get()->toArray();
     if (!empty($son)) {
         Notification::error('请先删除下级分类');
         return redirect()->route('backend.cate.index');
     }
     if (Category::destroy($id)) {
         Notification::success('删除成功');
         return redirect()->route('backend.cate.index');
     }
 }
 public function run()
 {
     $category = Category::where('id', 1)->first();
     if (!$category) {
         $category = new Category();
         $category->title = '技术漫谈';
         $category->sort = 0;
         $category->info = '';
         $category->cover = '';
         $category->thumb = '';
         $category->parent_id = 0;
         $category->root_id = 0;
         $category->is_nav_show = 1;
         $category->keywords = '';
         $category->description = '';
         $category->templet_all = '';
         $category->templet_nosub = '';
         $category->templet_article = '';
         $category->save();
     }
     $category = Category::where('id', 2)->first();
     if (!$category) {
         $category = new Category();
         $category->title = '说天道地';
         $category->sort = 0;
         $category->info = '';
         $category->cover = '';
         $category->thumb = '';
         $category->parent_id = 0;
         $category->root_id = 0;
         $category->is_nav_show = 1;
         $category->keywords = '';
         $category->description = '';
         $category->templet_all = '';
         $category->templet_nosub = '';
         $category->templet_article = '';
         $category->save();
     }
 }
 function deletecategory(Request $request, $id)
 {
     Category::where('id', $id)->delete();
     return redirect()->to('/backoffice/category/add/');
     //return "Delete แล้ว";
 }
 public function index()
 {
     $types = Category::where('parent_id', 0)->isNavShow()->sortByDesc('sort')->get();
     return Theme::view('welcome.index', compact('types'));
 }
Example #12
0
 public static function categoryTree($id = 0, $step = 0)
 {
     $key = 'categoryTree';
     $id = intval($id);
     $step = intval($step);
     if (Cache::store('category')->has($key) && $id == 0 && $step == 0) {
         $date = Cache::store('category')->get($key);
         return $date;
     } else {
         $categories = Category::where('parent_id', $id)->get();
         if ($step == 0) {
             $date = '';
             $prefix = '';
         } else {
             $date = '';
             $prefix = '';
             for ($i = 0; $i < $step; $i++) {
                 $prefix .= ' ';
             }
             $prefix .= '┖';
         }
         foreach ($categories as $category) {
             $date .= "<option value='" . $category->id . "'>" . $prefix . $category->title . "</option>";
             $subs = Category::where('parent_id', $category->id)->get();
             if ($subs->count() > 0) {
                 $date .= Theme::categoryTree($category->id, $step + 1);
             }
         }
         if ($id == 0 && $step == 0) {
             $expiresAt = Carbon::now()->addMinutes(60);
             //设置缓存时间
             Cache::store('category')->put($key, $date, $expiresAt);
         }
         return $date;
     }
 }
 public function categoryTree($id = 0, $step = 0)
 {
     $categories = Category::where('parent_id', $id)->get();
     if ($step == 0) {
         $tree = '';
         $prefix = '';
     } else {
         $tree = '';
         $prefix = '';
         for ($i = 0; $i < $step; $i++) {
             $prefix .= ' ';
         }
         $prefix .= '┖';
     }
     foreach ($categories as $category) {
         $tree .= "<option value='" . $category->id . "'>" . $prefix . $category->title . "</option>";
         $subs = Category::where('parent_id', $category->id)->get();
         if ($subs->count() > 0) {
             $tree .= $this->categoryTree($category->id, $step + 1);
         }
     }
     return $tree;
 }
Example #14
0
 public function delete()
 {
     $id = Input::get('id');
     $validator = Validator::make(array('id' => $id), array('id' => 'required|integer'));
     if ($validator->fails()) {
         return $this->responseJson(false, $validator->messages(), 101);
     }
     $category = Category::find($id);
     if (!$category) {
         return $this->responseJson(false, "不存在该分类!", 102);
     }
     $childdrenCategory = Category::where('parent_id', $id)->first();
     if (!count($childdrenCategory)) {
         return $this->responseJson(false, "该分类存在子分类!", 103);
     }
     $article = $category->article->first();
     if (count($article)) {
         return $this->responseJson(false, "该分类下存在文章!", 104);
     }
     $res = $category->delete();
     if (!$res) {
         return $this->responseJson(false, "删除分类失败!", 199);
     }
     return $this->responseJson(true, '删除分类成功!', 200);
 }
Example #15
0
 /**
  * カテゴリーの作成
  */
 public function postCategoryCreate(Request $request)
 {
     $category = Category::where('name', $request->name)->where('user_id', $request->user_id)->get();
     if (count($category) == 0) {
         $data = ['user_id' => $request->user_id, 'name' => $request->name];
         Category::create($data);
     }
     \Session::flash('flash_message', 'カテゴリーを作成しました。');
     return redirect()->back();
 }
Example #16
0
 public function show()
 {
     $data['categories'] = Category::where('pid', 0)->get();
     return view('admin.themes.index', $data);
 }
Example #17
0
 /**
  * ユーザ削除
  */
 public function postDelete(Request $request)
 {
     if ($request->id == Auth::user()->id) {
         return redirect()->back()->withErrors(['現在ログイン中なので削除できません。']);
     }
     $user = User::findOrFail($request->id);
     DB::transaction(function () use($user) {
         $user->delete();
         Category::where('user_id', $user->id)->delete();
         Post::where('user_id', $user->id)->delete();
     });
     $user->delete();
     \Session::flash('flash_message', '削除しました。');
     return redirect('/users');
 }
 public function renderChildren($id)
 {
     $this->template->selectedCategory = $this->category->get($id);
     $this->template->category = $this->category->where('parent', $id);
 }
 public function listLikeName($name, $limit = 20, $page = 1)
 {
     $name = "\\" . $name;
     return \Response::json(Category::where('name', 'LIKE', "%{$name}%")->take($limit)->offset($limit * ($page - 1))->orderBy("name", "asc")->get());
 }
Example #20
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Category::where('id', $id)->delete();
     return redirect('/admin/categories');
 }
Example #21
0
 public function index()
 {
     $cats = CategoryModel::where('cat_status_cd', 'ACT')->get();
     return view('settings.categories.index', compact('cats'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     try {
         $this->validate($request, ['category_name' => 'required|max:255|min:3', 'category_code' => 'required|min:2', 'category_desc' => 'required|min:10']);
         $is_active = $request->input('is_active') ? true : false;
         $categobj = new Category();
         $categobj->where('id', $id)->update(['category_name' => $request->input('category_name'), 'category_code' => $request->input('category_code'), 'category_desc' => $request->input('category_desc'), 'is_active' => $is_active]);
         return Redirect::to("/back/category/edit/{$id}")->with('message', $request->input('category_name') . ' was successfully updated');
     } catch (Exception $e) {
         return Redirect::to("/back/category/edit/{$id}")->with('message', 'Oops! Something went wrong. Please try again later');
     }
 }
Example #23
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\Model\Category;
use App\Model\Deal;
use App\Model\Partner;
Route::group(['prefix' => 'api', 'namespace' => 'Api', 'middleware' => 'cors'], function () {
    Route::get('/categories', function () {
        $categories = Category::where('parent_id', null)->get();
        return $categories;
    });
    Route::get('/categories/{id}', function ($id) {
        return Deal::where('partner_id', $id)->get();
    });
});
Route::group(['namespace' => 'Frontend'], function () {
    Route::get('/', 'MainController@index');
    Route::get('/index', 'MainController@index');
    Route::get('/danh-muc/{category_id}', 'MainController@listProductByCategory');
    Route::get('/san-pham/{deal_id}', 'MainController@productByCategory');
    Route::post('/search', 'MainController@search');
    Route::post('/san-pham/{deal_id}', 'MainController@addToCart');
    Route::get('/gio-hang', 'MainController@getCarts');
    Route::post('/gio-hang/{dea_id}', 'MainController@removeCart');
Example #24
0
 public function category($slug, Category $categories, Publication $publication)
 {
     $category = $categories->where('slug', '=', $slug)->first();
     $publications = $publication->where('category_id', '=', $category->id)->with('user')->paginate(6);
     return view('pages.publications.category', compact('publications', 'category'));
 }