PATH:
home
/
lab2454c
/
sportsnovate.com
/
backups
/
core
/
app
/
Http
/
Controllers
/
Admin
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Category; use App\Models\Subcategory; use Illuminate\Http\Request; class SubcategoryController extends Controller { public function index() { $pageTitle = "Manage Team"; $emptyMessage = "No data found"; $subCategorys = Subcategory::latest()->with('category')->paginate(getPaginate()); $categorys = Category::where('status', 1)->select('id', 'name')->get(); return view('admin.sub_category.index', compact('pageTitle', 'emptyMessage', 'categorys', 'subCategorys')); } public function store(Request $request) { $request->validate([ 'name' => 'required|max:120', 'category_id' => 'required|exists:categories,id', 'social_link'=> 'nullable|url|max:255', 'image'=> 'required|image|mimes:jpeg,png,jpg,svg,gif|max:2000', ]); $subCategory = new Subcategory(); $subCategory->name = $request->name; $subCategory->category_id = $request->category_id; $subCategory->save(); if (isset($request->social_link)) { $subCategory->social_link = $request->social_link; $subCategory->save(); } if ($request->hasFile('image')) { $path = imagePath()['teamIcon']['path']; try { $filename = uploadImage($request->image, $path); $subCategory->image = $filename; $subCategory->save(); } catch (\Exception $exp) { $notify[] = ['errors', 'Image could not be uploaded.']; return back()->withNotify($notify); } } $notify[] = ['success', 'Sub Category has been created']; return back()->withNotify($notify); } public function update(Request $request) { $request->validate([ 'id' => 'required|exists:subcategories,id', 'category_id' => 'required|exists:categories,id', 'name' => 'required|max:120', 'social_link'=> 'nullable|url|max:255', 'image'=> 'nullable|image|mimes:jpeg,png,jpg,svg,gif|max:2000', ]); $subCategory = Subcategory::findOrFail($request->id); $subCategory->name = $request->name; $subCategory->category_id = $request->category_id; $subCategory->save(); if ($subCategory->social_link !== $request->social_link) { $subCategory->social_link = $request->social_link; $subCategory->save(); } if ($request->hasFile('image')) { $path = imagePath()['teamIcon']['path']; try { $filename = uploadImage($request->image, $path); $subCategory->image = $filename; $subCategory->save(); } catch (\Exception $exp) { $notify[] = ['errors', 'Image could not be uploaded.']; return back()->withNotify($notify); } } $notify[] = ['success', 'Sub Category has been updated']; return back()->withNotify($notify); } }
[-] SubcategoryController.php
[edit]
[-] CategoryController.php
[edit]
[-] FrontendController.php
[edit]
[-] PageBuilderController.php
[edit]
[-] WithdrawalController.php
[edit]
[-] SupportTicketController.php
[edit]
[-] SpecificationController.php
[edit]
[-] AdvertisementController.php
[edit]
[+]
..
[-] HomeImageController.php
[edit]
[-] DepositController.php
[edit]
[-] ProductContentController.php
[edit]
[-] ExtensionController.php
[edit]
[-] MomentContentController.php
[edit]
[-] DynamicPageController.php
[edit]
[-] ManageUsersController.php
[edit]
[-] ReportController.php
[edit]
[-] GatewayController.php
[edit]
[-] EmailTemplateController.php
[edit]
[-] FaqContentController.php
[edit]
[-] OrderController.php
[edit]
[-] BrandController.php
[edit]
[-] ManualGatewayController.php
[edit]
[-] AdminController.php
[edit]
[+]
Auth
[-] LanguageController.php
[edit]
[-] WithdrawMethodController.php
[edit]
[-] FashionNftController.php
[edit]
[-] GeneralSettingController.php
[edit]
[-] ProductController.php
[edit]
[-] SmsTemplateController.php
[edit]