187 lines
6.0 KiB
PHP
187 lines
6.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Aboutus;
|
|
use App\Models\MainCategory;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
class AboutUsController extends Controller
|
|
{
|
|
public function index()
|
|
{ $view_about = Aboutus::get()->toArray();
|
|
|
|
|
|
return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us',compact('view_about'));
|
|
}
|
|
|
|
// public function index(Request $request)
|
|
// {
|
|
|
|
|
|
// try {
|
|
// $about_data = Aboutus::with('category')->get();
|
|
// // @dd($about_data);
|
|
|
|
// foreach ($about_data as $k => $val) {
|
|
// $about_data[$k]['thumbnail_image'] = ListingImageUrl('about_images', $val['thumbnail_image']);
|
|
// }
|
|
|
|
// return view('Admin.pages.manage_cms.manage_aboutus.manage_aboutsus', compact('about_data'));
|
|
// } catch (Exception $e) {
|
|
// Log::error("Manage About Page Not Load " . $e->getMessage());
|
|
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
|
// }
|
|
// }
|
|
|
|
// public function edit($id)
|
|
// {
|
|
|
|
|
|
|
|
|
|
// try {
|
|
// $edit_service = Aboutus::find($id)->toArray();
|
|
// $about_us_cat = MainCategory::all()->toArray();
|
|
// $edit_service['thumbnail_image'] = ListingImageUrl('about_images', $edit_service['thumbnail_image']);
|
|
|
|
// return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_edit', compact('edit_service', 'about_us_cat'));
|
|
// } catch (Exception $e) {
|
|
// Log::error("edit voucher Page Load Failed " . $e->getMessage());
|
|
// return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
|
// }
|
|
// }
|
|
public function edit($id){
|
|
$edit_privacy_policy = Aboutus::find($id)->toArray();
|
|
return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_cust', compact('edit_privacy_policy'));
|
|
}
|
|
|
|
public function edit_rest($id)
|
|
{
|
|
$edit_about_rest = Aboutus::find($id)->toArray();
|
|
dd('sdfnkjfn');
|
|
return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_rest', compact('edit_about_rest'));
|
|
}
|
|
|
|
public function update(Request $request)
|
|
{
|
|
|
|
|
|
try {
|
|
DB::beginTransaction();
|
|
$about_data = Aboutus::where('id', $request->about_id)->first();
|
|
|
|
if ($request->hasFile('about_image')) {
|
|
$image = $request->file('about_image');
|
|
$normalImage = saveSingleImageWithoutCrop($image, 'about_images');
|
|
$about_data->thumbnail_image = $normalImage;
|
|
}
|
|
|
|
$about_data->title = $request->input('about_title');
|
|
$about_data->description = $request->input('about_des');
|
|
$about_data->category_xid = $request->input('category');
|
|
|
|
$about_data->save();
|
|
|
|
|
|
DB::commit();
|
|
|
|
return jsonResponseWithSuccessMessage(__('success.update_data'));
|
|
} catch (Exception $e) {
|
|
DB::rollBack();
|
|
Log::error("updateCustomerNewsArticle Services Page Load Failed " . $e->getMessage());
|
|
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
|
}
|
|
}
|
|
|
|
|
|
public function delete_about($id)
|
|
{
|
|
|
|
|
|
try {
|
|
$blog = Aboutus::find($id);
|
|
|
|
if (!$blog) {
|
|
return response()->json(['error' => 'Aboutus entry not found.'], 404);
|
|
}
|
|
|
|
$blog->delete();
|
|
|
|
return response()->json(['success' => 'Aboutus entry deleted successfully.']);
|
|
} catch (\Exception $e) {
|
|
// Log the exception or handle it in a way that makes sense for your application
|
|
return response()->json(['error' => 'An error occurred while deleting the Aboutus entry.'], 500);
|
|
}
|
|
}
|
|
public function change_about_Status(Request $request)
|
|
{
|
|
|
|
|
|
try {
|
|
$status = Aboutus::find($request->program_id);
|
|
|
|
if (!$status) {
|
|
return response()->json(['error' => 'Aboutus entry not found.'], 404);
|
|
}
|
|
|
|
$status->is_active = $request->status;
|
|
$status->save();
|
|
|
|
return response()->json(['success' => 'Status change successfully.']);
|
|
} catch (\Exception $e) {
|
|
// Log the exception or handle it in a way that makes sense for your application
|
|
return response()->json(['error' => 'An error occurred while changing the status.'], 500);
|
|
}
|
|
}
|
|
|
|
public function add()
|
|
{
|
|
$about_us_cat = MainCategory::all()->toArray();
|
|
return view('Admin.pages.manage_cms.manage_aboutus.manage_about_us_add', compact('about_us_cat'));
|
|
}
|
|
|
|
public function insert(Request $request)
|
|
{
|
|
|
|
try {
|
|
DB::beginTransaction();
|
|
|
|
if (isset($request->about_image)) {
|
|
$image = $request->about_image;
|
|
$image_db = null;
|
|
} else {
|
|
$image = null;
|
|
$image_db = $request->about_image;
|
|
}
|
|
$tnormalImage = saveSingleImageWithoutCrop($image, 'about_images', $image_db);
|
|
|
|
|
|
$about_data = new Aboutus();
|
|
$about_data->title = $request->input('about_title');
|
|
$about_data->description = $request->input('about_des');
|
|
|
|
$about_data->thumbnail_image = $tnormalImage;
|
|
$about_data->category_xid = $request->input('category');
|
|
$about_data->save();
|
|
|
|
DB::commit();
|
|
return jsonResponseWithSuccessMessage(__('success.save_data'));
|
|
// return $voucher_data;
|
|
} catch (Exception $e) {
|
|
DB::rollBack();
|
|
Log::error("About Store Page Load Failed " . $e->getMessage());
|
|
return jsonResponseWithErrorMessage(__('auth.something_went_wrong'), 500);
|
|
}
|
|
}
|
|
|
|
}
|