Exemplo n.º 1
0
 public function isBidder($task_id)
 {
     $task = Task::where(['id' => $task_id])->first();
     if ($task->type == 1) {
         $bidder_array = CommitPivot::where(['task_id' => $task_id, 'user_id' => Auth::user()->id])->get();
     } else {
         if ($task->type == 2) {
             $bidder_array = QuotePivot::where(['task_id' => $task_id, 'user_id' => Auth::user()->id])->get();
         }
     }
     if (count($bidder_array)) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function postRate($task_id)
 {
     $task = Task::where('id', $task_id)->first();
     $comment = new Comment();
     $userInput = ['user_id' => Input::get('user_id'), 'star' => Input::get('star'), 'content' => Input::get('content'), 'from_whom_id' => $task->user->id];
     $rules = ['content' => 'required'];
     $validator = Validator::make($userInput, $rules);
     if ($validator->passes()) {
         $comment->from_whom_id = $userInput['from_whom_id'];
         $comment->user_id = $userInput['user_id'];
         $comment->star = $userInput['star'];
         $comment->content = $userInput['content'];
         $comment->save();
         CommitPivot::where('id', $task->winning_commit_id)->update(['comment_id' => $comment->id]);
         return Redirect::to('dashboard/taskOrder');
     } else {
         return Redirect::to("/dashboard/rate/{$task_id}")->withErrors($validator);
     }
 }
Exemplo n.º 3
0
 public function profile($user_id)
 {
     $user = User::where('id', $user_id)->first();
     // $tasks = $user->task()->paginate(10);
     $commits = CommitPivot::where('user_id', $user_id)->groupBy('task_id')->get();
     $comments = Comment::where('user_id', $user_id)->orderBy('created_at', 'desc')->get();
     $schoolAge = Util::secToYear(strtotime(date('Y-m-d')) - strtotime($user->enrollment_date));
     $grade = Util::getGrade($user, $schoolAge);
     return View::make('user.profile')->with('user', $user)->with('grade', $grade)->with('commits', $commits)->with('comments', $comments);
 }
Exemplo n.º 4
0
 public function successPay($commit_uuid)
 {
     $task_id = Session::get('task_id_session');
     $commit_uuid = Session::get('commit_uuid_session');
     $commit = CommitPivot::where('uuid', $commit_uuid)->first();
     $task = Task::where('id', $task_id)->first();
     // $task->state = 4;
     // $task->save();
     return View::make('task.successPay')->with('task', $task)->with('commit', $commit);
 }