コード例 #1
0
ファイル: ConversationService.php プロジェクト: Worklemon/api
 public function conversationRead($id, $receiver_id)
 {
     try {
         $conversation = Conversation::where(function ($query) use($id) {
             $query->where('id', '=', $id)->orWhere("parent_conversation_id", '=', $id);
         })->where('receiver_id', '=', $receiver_id)->update(['read' => 1]);
         if ($conversation) {
             return true;
         }
         return false;
     } catch (Exception $e) {
         return Response::json(['error' => $e->getMessage()]);
     }
 }
コード例 #2
0
ファイル: CompanyService.php プロジェクト: Worklemon/api
 public function applyCompanyJob($user_id, $data)
 {
     try {
         $job_id = $data['job_id'];
         $apply = new CompanyApplyJob();
         $apply->job_id = $job_id;
         $apply->user_id = $user_id;
         $apply->status = 0;
         if ($apply->save()) {
             $receiver_id = $data['receiver_id'];
             $content = $data['message'];
             $conversation = new Conversation();
             $conversation->sender_id = $user_id;
             $conversation->receiver_id = $receiver_id;
             $conversation->message = $content;
             $conversation->parent_conversation_id = 0;
             $conversation->application_id = $apply->id;
             if ($conversation->save()) {
                 $sender = $this->user_service->getUserById($user_id);
                 $receiver = $this->user_service->getUserById($receiver_id);
                 $user_name = $sender['first_name'] . ' ' . $sender['last_name'];
                 $company_name = $receiver['company']['name'];
                 $job_post = $this->getJobPostById($job_id)['title'];
                 $email = $receiver['email'];
                 $data = ['company' => $company_name, 'applicant' => $user_name, 'job_post' => $job_post, 'content' => $content];
                 Mail::queue('worklemon.email.company.applicant', $data, function ($message) use($email, $company_name, $user_name, $job_post) {
                     $message->to($email, $company_name);
                     $message->subject('Job Application from ' . $user_name . ' for job post ' . $job_post);
                     $message->priority(1);
                 });
                 return true;
             }
         }
         return false;
     } catch (Exception $e) {
         return Response::json(['error' => $e->getMessage()]);
     }
 }