Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for Zend Guard Encoder)
  6. *
  7. * @ Version : 3.0.4.0
  8. * @ Author : DeZender
  9. * @ Release on : 02.04.2017
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. namespace app\http\controllers;
  15.  
  16. class guv6s5j3k5kyhomu19x3q37
  17. {
  18. public function listCategory()
  19. {
  20. $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->paginate( 3 );
  21.  
  22. foreach ($categorys as $category) {
  23. $subCategorys[$category->id] = \App\category_files::where( 'parent_id', $category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  24.  
  25. foreach ($subCategorys[$category->id] as $subCategory) {
  26. $subCategorys2[$subCategory->id] = \App\category_files::where( 'parent_id', $subCategory->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  27. }
  28. }
  29.  
  30. $PostCategorys = \App\category_files::orderBy( 'created_at', 'asc' )->get( )->all( );
  31.  
  32. foreach ($PostCategorys as $PostCategory) {
  33. $countPostCategory[$PostCategory->id] = $PostCategory->files( )->count( );
  34. }
  35.  
  36. return view( $this->theme_admin( ) . '.dash' )->nest( 'content', $this->theme_admin( ) . '.categorys.list', compact( 'categorys', 'subCategorys', 'subCategorys2', 'countPostCategory' ) )->with( 'title', 'دسته بندی ها' );
  37. }
  38.  
  39. public function newCategory()
  40. {
  41. $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
  42. $parentCategorys[0] = 'بدون والد';
  43. $subCategorys[0] = array( );
  44.  
  45. foreach ($categorys as $category) {
  46. $parentCategorys[$category->id] = $category->name;
  47. $subCategorys[$category->id] = \App\category_files::where( 'parent_id', $category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  48. }
  49.  
  50. $pro_categorys = \App\category_products::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
  51.  
  52. foreach ($pro_categorys as $pro_category) {
  53. $pro_subCategorys[$pro_category->id] = \App\category_products::where( 'parent_id', $pro_category->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  54.  
  55. foreach ($pro_subCategorys[$pro_category->id] as $pro_subCategory) {
  56. $pro_subCategorys2[$pro_subCategory->id] = \App\category_products::where( 'parent_id', $pro_subCategory->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  57. }
  58. }
  59.  
  60. return view( $this->theme_admin( ) . '.dash' )->nest( 'content', $this->theme_admin( ) . '.categorys.new', compact( 'parentCategorys', 'subCategorys', 'pro_categorys', 'pro_subCategorys', 'pro_subCategorys2' ) )->with( 'title', 'اضافه کردن دسته بندی' );
  61. }
  62.  
  63. public function saveCategory(\Illuminate\Http\Request $Request)
  64. {
  65. if ($Request->hasFile( 'img_blank' )) {
  66. $allFiles = $Request->file( 'img_blank' );
  67.  
  68. if (!($this->validateFile( $allFiles ))) {
  69. return redirect( )->back( )->with( 'error', 'خطا: فقط تصاویر مجاز به آپلود می باشند.' );
  70. }
  71. }
  72.  
  73. $this->validate( $Request, array(
  74. 'name' => 'required|min:3|unique:category_files,name',
  75. 'parent_id' => 'integer'
  76. ) );
  77.  
  78. if (count( $Request['cat_product_ids'] ) == 0) {
  79. $Request['cat_product_ids'] = array( );
  80. }
  81.  
  82. $posts = \App\category_files::create( array(
  83. 'parent_id' => $Request['parent_id'],
  84. 'name' => $Request['name'],
  85. 'content' => $Request['content'],
  86. 'cat_product_ids' => json_encode( $Request['cat_product_ids'] ),
  87. 'demo' => $Request['demo'],
  88. 'status' => $Request['status'],
  89. 'index_view' => $Request['index_view']
  90. ) );
  91. $imageArray = array( );
  92.  
  93. if (isset( $allFiles )) {
  94. foreach ($allFiles as $key => $imageFile) {
  95. $imageArray[] = $this->saveCategoryImage( $imageFile, $posts->id, 'category_files' );
  96. }
  97. }
  98.  
  99. $posts->img_blank = json_encode( $imageArray );
  100. $posts->save( );
  101. return redirect( 'admin/category/list' )->with( 'success', 'دسته بندی ذخیره شد.' );
  102. }
  103.  
  104. public function editCategory(\App\category_files $category)
  105. {
  106. $categorys = \App\category_files::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
  107. $parentCategorys[0] = 'بدون والد';
  108. $subCategorys[0] = array( );
  109.  
  110. foreach ($categorys as $category2) {
  111. $parentCategorys[$category2->id] = $category2->name;
  112. $subCategorys[$category2->id] = \App\category_files::where( 'parent_id', $category2->id )->orderBy( 'created_at', 'asc' )->get( )->all( );
  113. }
  114.  
  115. $pro_categorys = \App\category_products::where( 'parent_id', '0' )->orwhere( 'parent_id', null )->orderBy( 'created_at', 'asc' )->get( )->all( );
  116.  
  117. foreach ($pro_categorys as $pro_category) {
  118. ..................................................................
  119. ..................................
  120. ............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement