コード例 #1
0
ファイル: UserService.php プロジェクト: Worklemon/api
 public function bookMarkCompanyJob($user_id, $job_id)
 {
     try {
         if (BookMarkJob::withTrashed()->where('user_id', '=', $user_id)->where('job_id', '=', $job_id)->count() == 1) {
             BookMarkJob::withTrashed()->where('user_id', '=', $user_id)->where('job_id', '=', $job_id)->restore();
             return BookMarkJob::where('user_id', '=', $user_id)->where('job_id', '=', $job_id)->first()->toArray();
         } else {
             $bookmark = new BookMarkJob();
             $bookmark->user_id = $user_id;
             $bookmark->job_id = $job_id;
             $bookmark->save();
             return $bookmark->toArray();
         }
     } catch (Exception $e) {
         return Response::json(['error' => $e->getMessage()]);
     }
 }