Skip to content

Commit

Permalink
Merge pull request #2 from ngtinn59/Version-Deploy-Ubuntu
Browse files Browse the repository at this point in the history
Version-Deploy-Ubuntu
  • Loading branch information
ngtinn59 authored Nov 9, 2024
2 parents 9a4a8e2 + fccb346 commit 2360d5e
Show file tree
Hide file tree
Showing 135 changed files with 8,933 additions and 1,654 deletions.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +0,0 @@

**Project: Job Finder - CV Export API**

[****Installation****]()

- Clone the repository.
- Run `composer install`.
- Copy .env.example to .env.
- Generate a secure key in the .env file by running `php artisan key:generate`.

[****API Documentation****]()

- **Link Postman**: [Postman Link](https://app.getpostman.com/join-team?invite_code=397abbe48fa386e5196125f8977342e5&target_code=345b78a8750f067c027971d49da4b134)
- **Link Drive**: [Drive Link](https://drive.google.com/file/d/1ne18eqa7bhZ0O8zQKqe4byYgzWaadI-f/view)

**Link API Deploy:** [API Deploy Link](http://20.212.246.49/api/countries)

**Link Slide Báo cáo:** [Slide](https://www.canva.com/design/DAGDhAD8K-4/XY7H4xQ30hsrozfU_DS3_g/view?utm_content=DAGDhAD8K-4&utm_campaign=designshare&utm_medium=link&utm_source=editor)
68 changes: 68 additions & 0 deletions app/Events/ApplicationStatusUpdated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ApplicationStatusUpdated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public $jobId;
public $userId;
public $status;
public $name;
public $notification;
public $job;


public function __construct($jobId, $userId, $status, $name, $notification, $job)
{
$this->jobId = $jobId;
$this->userId = $userId;
$this->status = $status;
$this->name = $name;
$this->notification = $notification;
$this->job = $job;

}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn()
{
return ['user.' . $this->userId]; // Kênh riêng cho ứng viên
}
public function broadcastAs()
{
return 'ApplicationStatusUpdated';
}

public function broadcastWith(): array
{
return [
'notifications' => [
'notifiable_id' => $this->notification->id,
'data' => [
'job_id' => $this->jobId,
'job_title' => $this->job->title,
'status' => $this->status,
'message' => 'Trạng thái đơn ứng tuyển của bạn đã được cập nhật.'
],
'read' => $this->notification->read_at ? true : false, // Kiểm tra xem thông báo đã đọc hay chưa
'created_at' => $this->notification->created_at->format('Y-m-d H:i:s'), // Định dạng thời gian
]

];
}

}
11 changes: 9 additions & 2 deletions app/Events/MessageSent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public function __construct(Message $message)

public function broadcastOn()
{
$channel = new Channel('chat.' . $this->message->receiver_id);
return $channel; // Trả về kênhss
return [
new Channel('chat.' . $this->message->receiver_id),
];
}

public function broadcastAs()
Expand All @@ -35,11 +36,17 @@ public function broadcastAs()

public function broadcastWith(): array
{
// Tải người gửi nếu chưa được tải
$sender = $this->message->sender; // Giả sử bạn đã định nghĩa quan hệ 'sender' trong mô hình Message

return [
'message' => $this->message->message,
'sender_id' => $this->message->sender_id,
'sender_name' => $sender->name,
'receiver_id' => $this->message->receiver_id,
'file_url' => $this->message->file_path ? url('uploads/' . $this->message->file_path) : null, // Đường dẫn file
'created_at' => $this->message->created_at->toDateTimeString(),
];
}

}
168 changes: 168 additions & 0 deletions app/Http/Controllers/Api/Admin/AdminCompaniesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php

namespace App\Http\Controllers\Api\Admin;

use App\Http\Controllers\Controller;
use App\Models\Company;
use Illuminate\Http\Request;

class AdminCompaniesController extends Controller
{
public function index(Request $request)
{
// Lấy danh sách công ty, có thể phân trang
$companies = Company::paginate(10);

$companiesdata = $companies->map(function ($company) {
$companyType = optional($company->companytype)->name;
$companySize = optional($company->companysize)->name;
$country = optional($company->country)->name;
$city = optional($company->city)->name;
$district = optional($company->district)->name;

return [
'id' => $company->id,
'name' => $company->company_name,
'phone' => $company->phone, // Thêm số điện thoại
'company_email' => $company->company_email, // Thêm email công ty
'logo' => asset('uploads/images/' . $company->logo),
'city' => $city,
'is_hot' => $company->is_hot
];

});

return response()->json([
'success' => true,
'message' => 'successfully.',
'data' => $companiesdata
], 200);
}

public function show($id)
{
$company = Company::find($id);

if (!$company) {
return response()->json([
'success' => false,
'message' => 'Công ty không tồn tại.',
], 404);
}

// Retrieve optional related data
$companyType = optional($company->companytype)->name;
$companySize = optional($company->companysize)->name;
$country = optional($company->country)->name;
$city = optional($company->city)->name;
$district = optional($company->district)->name;

// Structured company data
$companyDetails = [
'id' => $company->id,
'name' => $company->company_name,
'company_type' => $companyType,
'company_size' => $companySize,
'country' => $country,
'city' => $city,
'district' => $district,
'phone' => $company->phone,
'company_email' => $company->company_email,
'tax_code' => $company->tax_code,
'date_of_establishment' => $company->date_of_establishment,
'working_days' => $company->working_days,
'overtime_policy' => $company->overtime_policy,
'website' => $company->website,
'facebook' => $company->facebook,
'youtube' => $company->youtube,
'linked' => $company->linked,
'address' => $company->address,
'latitude' => $company->latitude,
'longitude' => $company->longitude,
'description' => $company->description,
'is_hot' => $company->is_hot,
'logo' => asset('uploads/images/' . $company->logo),
'banner' => asset('uploads/images/' . $company->banner),

];

return response()->json([
'success' => true,
'message' => 'successfully.',
'data' => $companyDetails
], 200);
}


public function markAsHot($companyId)
{
$company = Company::find($companyId);

if (!$company) {
return response()->json([
'success' => false,
'message' => 'Không tìm thấy công ty.',
'status_code' => 404,
], 404);
}

// Đánh dấu công ty là "nổi bật"
$company->is_hot = true;
$company->save();

// Chuẩn bị dữ liệu trả về
$companyType = optional($company->companytype)->name;
$companySize = optional($company->companysize)->name;
$country = optional($company->country)->name;
$city = optional($company->city)->name;
$district = optional($company->district)->name;

$companyDetails = [
'id' => $company->id,
'name' => $company->company_name,
'company_type' => $companyType,
'company_size' => $companySize,
'country' => $country,
'city' => $city,
'district' => $district,
'phone' => $company->phone,
'company_email' => $company->company_email,
'tax_code' => $company->tax_code,
'date_of_establishment' => $company->date_of_establishment,
'working_days' => $company->working_days,
'overtime_policy' => $company->overtime_policy,
'website' => $company->website,
'facebook' => $company->facebook,
'youtube' => $company->youtube,
'linked' => $company->linked,
'address' => $company->address,
'latitude' => $company->latitude,
'longitude' => $company->longitude,
'description' => $company->description,
'is_hot' => $company->is_hot,
'logo' => asset('uploads/images/' . $company->logo),
'banner' => asset('uploads/images/' . $company->banner),

];

return response()->json([
'success' => true,
'message' => 'Công ty đã được đánh dấu là nổi bật.',
'data' => $companyDetails,
'status_code' => 200,
], 200);
}

public function destroy(Company $company)
{
$company->delete();
return response()->json([
'success' => true,
'message' => 'Company deleted successfully.',
'status_code' => 200
]);

}


}
Loading

0 comments on commit 2360d5e

Please sign in to comment.