Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace app\http\controllers;
- class guv6s5j3k5kyhomu19x3q37 extends Controller
- {
- 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)) {
- ..........................................................
- ......................
- .........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement