80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Exports\UsersExport;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Illuminate\Support\Facades\DB;
|
|
//use Excel;
|
|
//use App\Models\User;
|
|
use App\Services\Admin\ManageUserService;
|
|
//use App\Repositories\UserRepository;
|
|
|
|
class ManageUserController extends Controller
|
|
{
|
|
protected $manageUserService;
|
|
// protected $selectedRows;
|
|
// protected $data;
|
|
|
|
public function __construct(ManageUserService $manageUserService) {
|
|
$this->manageUserService = $manageUserService;
|
|
}
|
|
|
|
public function create(){
|
|
return view('Admin.Pages.manage_users.manage_user');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// echo $request->activeUser;exit;
|
|
// $users = $userService->getAllUsers();
|
|
// $users->$this->data = $this->manageUserService->getAllUsers();
|
|
$users = $this->manageUserService->getAllUsers();
|
|
// echo '<pre>';print_r($users);exit;
|
|
// dd($users);
|
|
return view('Admin.Pages.manage_users.manage_user')->with(['Users'=>$users]);
|
|
|
|
}
|
|
|
|
public function destroy(Request $request){
|
|
// dd($request->userID);
|
|
$deletedAt = array('isActive'=>0,'deleted_at'=>1);
|
|
$users = $this->manageUserService->deleteUser($request->userID,$deletedAt);
|
|
// dd($users);
|
|
return response()->json(['Delete'=>'Deleted']);
|
|
|
|
}
|
|
|
|
public function show($id) {
|
|
// echo $id;
|
|
$get_single_user_details = $this->manageUserService->show_user($id);
|
|
// dd($get_single_user_details);
|
|
return view('Admin.Pages.manage_users.manage_users_view')->with(['get_single_user_details' => $get_single_user_details]);
|
|
}
|
|
|
|
|
|
public function update(Request $request){
|
|
// echo "fdfjdf"; exit();
|
|
$userData = $request->input('userdata');
|
|
// $updatedata = (['full_name'=>$request->name,
|
|
// 'email'=>$request->email,
|
|
// 'mob_number'=> $request->mobile,
|
|
// ]);
|
|
$users = $this->manageUserService->updateUser($userData);
|
|
// echo $users; exit();
|
|
return response()->json([
|
|
'status'=>'200',
|
|
'message'=>"data updated successfully",
|
|
]);
|
|
}
|
|
|
|
|
|
public function exportUser(){
|
|
// dd($selectedRows);
|
|
return Excel::download(new UsersExport,'users.xlsx');
|
|
}
|
|
|
|
}
|