Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP5 Decoder for Zend Guard Encoder)
- *
- * @ Version : 3.0.4.0
- * @ Author : DeZender
- * @ Release on : 02.04.2017
- * @ Official site : http://DeZender.Net
- *
- */
- namespace app\http\controllers;
- class guv6s5j3k5kyhomu19x3q37
- {
- public function listCategory()
- {
- $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->paginate( 3 );
- foreach ($categorys as $category) {
- $subCategorys[$category->id] = \App\category_files::where( 'parent_id', $category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- foreach ($subCategorys[$category->id] as $subCategory) {
- $subCategorys2[$subCategory->id] = \App\category_files::where( 'parent_id', $subCategory->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- }
- }
- $PostCategorys = \App\category_files::orderBy( 'created_at', 'asc' )->get( )->all( );
- foreach ($PostCategorys as $PostCategory) {
- $countPostCategory[$PostCategory->id] = $PostCategory->files( )->count( );
- }
- return view( $this->theme_admin( ) . '.dash' )->nest( 'content', $this->theme_admin( ) . '.categorys.list', compact( 'categorys', 'subCategorys', 'subCategorys2', 'countPostCategory' ) )->with( 'title', 'دسته بندی ها' );
- }
- public function newCategory()
- {
- $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
- $parentCategorys[0] = 'بدون والد';
- $subCategorys[0] = array( );
- foreach ($categorys as $category) {
- $parentCategorys[$category->id] = $category->name;
- $subCategorys[$category->id] = \App\category_files::where( 'parent_id', $category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- }
- $pro_categorys = \App\category_products::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
- foreach ($pro_categorys as $pro_category) {
- $pro_subCategorys[$pro_category->id] = \App\category_products::where( 'parent_id', $pro_category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- foreach ($pro_subCategorys[$pro_category->id] as $pro_subCategory) {
- $pro_subCategorys2[$pro_subCategory->id] = \App\category_products::where( 'parent_id', $pro_subCategory->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- }
- }
- return view( $this->theme_admin( ) . '.dash' )->nest( 'content', $this->theme_admin( ) . '.categorys.new', compact( 'parentCategorys', 'subCategorys', 'pro_categorys', 'pro_subCategorys', 'pro_subCategorys2' ) )->with( 'title', 'اضافه کردن دسته بندی' );
- }
- public function saveCategory(\Illuminate\Http\Request $Request)
- {
- if ($Request->hasFile( 'img_blank' )) {
- $allFiles = $Request->file( 'img_blank' );
- if (!($this->validateFile( $allFiles ))) {
- return redirect( )->back( )->with( 'error', 'خطا: فقط تصاویر مجاز به آپلود می باشند.' );
- }
- }
- $this->validate( $Request, array(
- 'name' => 'required|min:3|unique:category_files,name',
- 'parent_id' => 'integer'
- ) );
- if (count( $Request['cat_product_ids'] ) == 0) {
- $Request['cat_product_ids'] = array( );
- }
- $posts = \App\category_files::create( array(
- 'parent_id' => $Request['parent_id'],
- 'name' => $Request['name'],
- 'content' => $Request['content'],
- 'cat_product_ids' => json_encode( $Request['cat_product_ids'] ),
- 'demo' => $Request['demo'],
- 'status' => $Request['status'],
- 'index_view' => $Request['index_view']
- ) );
- $imageArray = array( );
- if (isset( $allFiles )) {
- foreach ($allFiles as $key => $imageFile) {
- $imageArray[] = $this->saveCategoryImage( $imageFile, $posts->id, 'category_files' );
- }
- }
- $posts->img_blank = json_encode( $imageArray );
- $posts->save( );
- return redirect( 'admin/category/list' )->with( 'success', 'دسته بندی ذخیره شد.' );
- }
- public function editCategory(\App\category_files $category)
- {
- $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
- $parentCategorys[0] = 'بدون والد';
- $subCategorys[0] = array( );
- foreach ($categorys as $category2) {
- $parentCategorys[$category2->id] = $category2->name;
- $subCategorys[$category2->id] = \App\category_files::where( 'parent_id', $category2->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
- }
- $pro_categorys = \App\category_products::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
- foreach ($pro_categorys as $pro_category) {
- ..................................................................
- ..................................
- ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement