-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ngtinn59/Version-Deploy-Ubuntu
Version deploy ubuntu
- Loading branch information
Showing
282 changed files
with
413 additions
and
32 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Profile; | ||
use App\Models\User; | ||
use App\Utillities\Constant; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Log; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
class AdminUserController extends Controller | ||
{ | ||
public function blockUser($userId) | ||
{ | ||
$user = User::find($userId); | ||
|
||
if (!$user) { | ||
return response()->json([ | ||
'success' => false, | ||
'error' => 'Người dùng không tồn tại', | ||
'status_code' => 404 | ||
], 404); | ||
} | ||
|
||
$user->update(['status' => Constant::user_status_inactive]); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Tài khoản đã bị chặn thành công', | ||
'status_code' => 200 | ||
], 200); | ||
} | ||
|
||
public function unblockUser($userId) | ||
{ | ||
$user = User::find($userId); | ||
|
||
if (!$user) { | ||
return response()->json([ | ||
'success' => false, | ||
'error' => 'Người dùng không tồn tại', | ||
'status_code' => 404 | ||
], 404); | ||
} | ||
|
||
$user->update(['status' => Constant::user_status_active]); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Tài khoản đã được mở lại thành công', | ||
'status_code' => 200 | ||
], 200); | ||
} | ||
|
||
public function index() | ||
{ | ||
// Ánh xạ giá trị account_type | ||
$accountTypeLabels = [ | ||
Constant::user_level_developer => 'Người tìm việc', | ||
Constant::user_level_employer => 'Người tuyển dụng', | ||
Constant::user_level_host => 'Admin' | ||
]; | ||
|
||
// Ánh xạ giá trị status | ||
$accountTypeStatus = [ | ||
Constant::user_status_active => 'Hoạt động', | ||
Constant::user_status_inactive => 'Không hoạt động' | ||
]; | ||
|
||
// Lấy danh sách người dùng có account_type là 1 hoặc 2 | ||
$dataUsers = User::whereIn('account_type', [1, 2])->get()->map(function ($user) use ($accountTypeLabels, $accountTypeStatus) { | ||
return [ | ||
'id' => $user->id, | ||
'name' => $user->name, | ||
'email' => $user->email, | ||
'account_type' => $accountTypeLabels[$user->account_type] ?? 'Không xác định', // Sử dụng ánh xạ cho account_type | ||
'status' => $accountTypeStatus[$user->status] ?? 'Không xác định', // Sử dụng ánh xạ cho status | ||
'created_at' => $user->created_at, | ||
'updated_at' => $user->updated_at | ||
]; | ||
}); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Lấy danh sách tài khoản thành công!', | ||
'data' => $dataUsers, | ||
'status_code' => 200 | ||
|
||
], 200); | ||
} | ||
|
||
|
||
|
||
|
||
// Create a new user | ||
public function store(Request $request) | ||
{ | ||
// Validation với thông báo tiếng Việt | ||
$messages = [ | ||
'name.required' => 'Tên là bắt buộc.', | ||
'name.string' => 'Tên phải là chuỗi ký tự.', | ||
'name.max' => 'Tên không được vượt quá 255 ký tự.', | ||
'email.required' => 'Email là bắt buộc.', | ||
'email.string' => 'Email phải là chuỗi ký tự.', | ||
'email.max' => 'Email không được vượt quá 255 ký tự.', | ||
'email.unique' => 'Email này đã tồn tại.', | ||
'password.required' => 'Mật khẩu là bắt buộc.', | ||
'password.string' => 'Mật khẩu phải là chuỗi ký tự.', | ||
'password.min' => 'Mật khẩu phải có ít nhất 8 ký tự.', | ||
]; | ||
|
||
// Validation | ||
$validator = Validator::make($request->all(), [ | ||
'name' => 'required|string|max:255', | ||
'email' => 'required|string|email|max:255|unique:users', | ||
'password' => 'required|string|min:8', | ||
], $messages); | ||
|
||
if ($validator->fails()) { | ||
return response()->json([ | ||
'success' => false, | ||
'message'=>'Lỗi tạo tài khoản', | ||
'errors' => $validator->errors(), | ||
'status_code' => 422 | ||
], | ||
422); | ||
} | ||
|
||
DB::beginTransaction(); | ||
try { | ||
// Tạo user mới với dữ liệu từ request | ||
$user = User::create([ | ||
'name' => $request->name, | ||
'email' => $request->email, | ||
'account_type' => Constant::user_level_developer, | ||
'email_verified_at' => now(), | ||
'status' => Constant::user_status_active, | ||
'password' => Hash::make($request->password), | ||
]); | ||
|
||
// Tạo profile cho user | ||
Profile::create([ | ||
'users_id' => $user->id, | ||
'name' => $request->name, | ||
'email' => $request->email, | ||
]); | ||
|
||
DB::commit(); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Đăng ký thành công. Vui lòng xác minh email của bạn.', | ||
'user' => $user, | ||
'status_code' => 200, | ||
]); | ||
} catch (\Exception $e) { | ||
DB::rollback(); | ||
Log::error('Đăng ký thất bại: ' . $e->getMessage()); | ||
|
||
return response()->json([ | ||
'success' => false, | ||
'message' => 'Đăng ký thất bại.', | ||
'status_code' => 500, | ||
], 500); | ||
} | ||
} | ||
|
||
// View user details | ||
public function show($id) | ||
{ | ||
$user = User::find($id); | ||
if (!$user) { | ||
return response()->json([ | ||
'success' => false, | ||
'error' => 'Người dùng không tồn tại', | ||
'status_code' => 404 | ||
], 404); | ||
} | ||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Lấy thông tin tài khoản thành công', | ||
'data' => $user, | ||
'status_code' => 200 | ||
], 200); | ||
} | ||
|
||
// Update user information | ||
public function update(Request $request, $id) | ||
{ | ||
$user = User::find($id); | ||
if (!$user) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'Người dùng không tồn tại', | ||
'status_code' => 404 | ||
], 404); | ||
} | ||
|
||
// Validation với thông báo tiếng Việt | ||
$messages = [ | ||
'name.required' => 'Tên là bắt buộc.', | ||
'name.string' => 'Tên phải là chuỗi ký tự.', | ||
'name.max' => 'Tên không được vượt quá 255 ký tự.', | ||
'email.required' => 'Email là bắt buộc.', | ||
'email.string' => 'Email phải là chuỗi ký tự.', | ||
'email.max' => 'Email không được vượt quá 255 ký tự.', | ||
'email.unique' => 'Email này đã tồn tại.', | ||
'password.required' => 'Mật khẩu là bắt buộc.', | ||
'password.string' => 'Mật khẩu phải là chuỗi ký tự.', | ||
'password.min' => 'Mật khẩu phải có ít nhất 8 ký tự.', | ||
]; | ||
|
||
// Validation | ||
$validator = Validator::make($request->all(), [ | ||
'name' => 'sometimes|required|string|max:255', | ||
'email' => 'sometimes|required|string|email|max:255|unique:users,email,' . $user->id, | ||
'password' => 'sometimes|required|string|min:8', | ||
], $messages); | ||
|
||
if ($validator->fails()) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'Lỗi cập nhật tài khoản', | ||
'errors' => $validator->errors(), | ||
'status_code' => 422 | ||
], 422); | ||
} | ||
|
||
DB::beginTransaction(); | ||
try { | ||
// Cập nhật thông tin user | ||
$user->update([ | ||
'name' => $request->name ?? $user->name, | ||
'email' => $request->email ?? $user->email, | ||
'password' => $request->password ? Hash::make($request->password) : $user->password, | ||
]); | ||
|
||
DB::commit(); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Cập nhật tài khoản thành công', | ||
'user' => $user, | ||
'status_code' => 200, | ||
]); | ||
} catch (\Exception $e) { | ||
DB::rollback(); | ||
Log::error('Cập nhật tài khoản thất bại: ' . $e->getMessage()); | ||
|
||
return response()->json([ | ||
'success' => false, | ||
'message' => 'Cập nhật tài khoản thất bại.', | ||
'status_code' => 500, | ||
], 500); | ||
} | ||
} | ||
|
||
// Delete a user | ||
public function destroy($id) | ||
{ | ||
$user = User::find($id); | ||
if (!$user) { | ||
return response()->json([ | ||
'success' => false, | ||
'error' => 'Người dùng không tồn tại', | ||
'status_code' => 404 | ||
], 404); | ||
} | ||
|
||
$user->delete(); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'User deleted successfully', | ||
'status_code' => 204 | ||
], 204); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
app/Http/Controllers/Api/Admin/JobtypesControllerController.php
100644 → 100755
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file modified
0
app/Http/Controllers/Api/Companies/CompaniesSkillsController.php
100644 → 100755
Empty file.
Empty file modified
0
app/Http/Controllers/Api/Companies/CompanyLocationsController.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
app/Http/Controllers/Api/Employer/EmployerRegisterController.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
app/Repositories/Recruitments/RecruitmentsRepositoryInterface.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,4 @@ class Constant | |
self::user_status_inactive => 'inactive', | ||
]; | ||
|
||
|
||
|
||
|
||
|
||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2019_08_19_000000_create_failed_jobs_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
database/migrations/2024_01_15_082846_create_profiles_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_01_15_082855_create_educations_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_01_15_082912_create_experiences_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_01_15_08292233_create_companies_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_01_15_082931_create_company_reviews_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_01_15_082949_create_projects_table.php
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
database/migrations/2024_01_15_083008_create_statistic_applies_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_02_22_052707_create_aboutme_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_02_22_053630_create__certificates_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_02_22_055329_create__awards_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_02_27_163204_create_countries_table.php
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
database/migrations/2024_02_27_163226_create_locations_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_02_27_163238_create_skillscopamies_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_033_180004_create_job_types_table.php
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
database/migrations/2024_03_03_1759536_create_job_skill_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_05_114101_create_favorites_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_05_114826_create_job_users_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_06_130415_create_company_cities_users_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_06_131038_create_company_types_users_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_06_131100_create_company_sizes_users_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_03_12_180510_add_cv_to_job_user_table.php
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
database/migrations/2024_04_02_164026_add_is_default_to_cvs_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_10_05_065536_create_messages_table.php
100644 → 100755
Empty file.
Empty file modified
0
database/migrations/2024_10_06_125841_create_objectives_table.php
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
public/cvs/02-thong-bao-lien-he-dia-diem-tttt_6627cfa690306_240423_031134.pdf
100644 → 100755
Empty file.
Empty file modified
0
public/cvs/02-thong-bao-lien-he-dia-diem-tttt_662bb93c7f152_240426_022500.pdf
100644 → 100755
Empty file.
Empty file modified
0
public/cvs/cv-back-end-nguyen-thanh-tin_662bba9ee0335_240426_023054.pdf
100644 → 100755
Empty file.
Empty file modified
0
public/cvs/cv-back-end-nguyen-thanh-tin_662c5c1273584_240427_015946.pdf
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
public/cvs/drimaes-internship-program-2023_662138bfcb965_240418_031407.pdf
100644 → 100755
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file modified
0
.../435123129-286250911205781-840224741782651526-n_662bbfc0eb49d_240426_025248.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
.../435123129-286250911205781-840224741782651526-n_662bbfd730fc4_240426_025311.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
...439504673-289844330839631-4585923465327173869-n_662bbcacb12af_240426_023940.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified
0
...439504673-289844330839631-4585923465327173869-n_662bbcbadd2ea_240426_023954.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file modified
0
public/uploads/images/screenshot-1_662beaf20edbd_240426_055706.png
100644 → 100755
Oops, something went wrong.
Empty file modified
0
public/uploads/images/screenshot-1_662bed21a39b4_240426_060625.png
100644 → 100755
Oops, something went wrong.
Empty file modified
0
public/uploads/images/screenshot-1_662bee06a0b1d_240426_061014.png
100644 → 100755
Oops, something went wrong.
Empty file modified
0
public/uploads/images/screenshot-2024-03-04-at-143456_662c5b37f1831_240427_015607.webp
100644 → 100755
Empty file.
Empty file modified
0
public/uploads/images/screenshot-2_662c5bb12ac99_240427_015809.png
100644 → 100755
Oops, something went wrong.
Empty file modified
0
public/uploads/images/screenshot-3_662c534b329eb_240427_012219.png
100644 → 100755
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.