コード例 #1
0
 public function reportPage($id)
 {
     $report = Reports::find($id);
     if ($report) {
         $recommendation = Recommendation::where('report_id', $report->id)->join('users', 'users.id', '=', 'recommendations.doctor_id')->first();
         $conversations = Conversation::where('report_id', $report->id)->where('patient_id', auth()->user()->id)->get();
         $data = ['report' => $report, 'recommendation' => $recommendation, 'conversations' => $conversations];
         return view('frontend.user.report_page', $data);
     } else {
         abort(404);
     }
 }
コード例 #2
0
 public function handle(Request $request, $id)
 {
     $conversation = Conversation::where(['from' => Auth::user()->id, 'to' => $id])->orWhere(['to' => Auth::user()->id, 'from' => $id])->first();
     if (count($conversation) == 0) {
         $conversation = Conversation::create(['from' => Auth::user()->id, 'to' => $id]);
     }
     if ($request->get('content') != "" && Message::create(['from' => Auth::user()->id, 'to' => $id, 'content' => htmlentities($request->get('content')), 'conversation_id' => $conversation->id])) {
         $conversation->updated_at = date("Y-m-d H:i:s");
         $conversation->save();
         return json_encode(['error' => 0, 'message' => htmlentities($request->get('content')), 'reciever' => $id, 'avatar_url' => Auth::user()->getProfilePictureUrl(), 'type' => 0]);
     }
     return json_encode(['error' => 1, 'message' => 'Can not send message!', 'type' => -1]);
 }
コード例 #3
0
 public function getShowProject($projectid, $userid)
 {
     $project = Project::find($projectid);
     $project_status = \DB::table('project')->where('project.id', '=', $projectid)->leftJoin('project_status', 'status_id', '=', 'project_status.id')->leftJoin('project_budget', 'project_budget.id', '=', 'project.project_budget')->get(array('status_sign', 'budget'));
     $user = User::find($project->freelancer_id);
     $exists = \DB::table('bids')->where("project_id", "=", $projectid)->where("user_id", "=", $userid)->count();
     $bids = \DB::table('bids')->leftJoin('users', 'users.id', '=', 'bids.user_id')->where("project_id", "=", $projectid)->get();
     $conversationsExists = array();
     foreach ($bids as $bid) {
         $results = Conversation::where(function ($query) use($bid) {
             $query->where('user_one', '=', $bid->user_id)->orWhere('user_two', '=', $bid->user_id);
         })->where(function ($query) use($project) {
             $query->where('user_one', '=', $project->user_id)->orWhere('user_two', '=', $project->user_id);
         })->count();
         array_push($conversationsExists, $results);
     }
     $bid = Bid::where('project_id', '=', $projectid)->where('user_id', '=', $project->freelancer_id)->get();
     $milesstone = ProjectMilestones::where('project_id', '=', $projectid)->get();
     $files = \DB::table('project_files')->where('project_id', '=', $projectid)->get();
     return view('showproject')->with('project', $project)->with('exists', $exists)->with('bids', $bids)->with('project_status', $project_status)->with('freelancer', $user)->with('bid', $bid)->with('milesstone', $milesstone)->with('files', $files)->with('conversationsExists', $conversationsExists);
 }
コード例 #4
0
ファイル: routes.php プロジェクト: yves01/dashboard
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('messages');
});
Route::get('home', 'DashboardController@index');
Route::get('messages', function (Request $request) {
    // we recover all the data sent by the ajax request
    $keys = $request::all();
    $query = "";
    // test of the query parameter
    if ($keys['query'] != "") {
        $query = Conversation::where("Title", "like", "%" . $keys['query'] . "%");
        //->skip($keys['offset']);//->get();
    } else {
        $query = Conversation::select("*");
    }
    //test of the offset parameter
    if ($keys['offset'] != 0) {
        $query = $query->take($keys['limit'])->skip($keys['offset'])->get();
    } else {
        $query = $query->get();
    }
    //else
    //{	// cannot use offset alone, so we take a limit very high
    //	$query=Conversation::select("*")->take(9999999)->skip($keys['offset'])->get();
    // we do not want so much be we still need to know how much answer we get
    //}
コード例 #5
0
 /**
  * Set messages from a specific conversation as read.
  */
 private function markReadMessages($id)
 {
     $messagesUnread = Conversation::where('id', $id)->with(['messages' => function ($query) {
         $query->where('user_id', '!=', \Auth::id())->where('read', '=', 0);
     }])->first();
     foreach ($messagesUnread->messages as $message) {
         $message->read = true;
         $message->save();
     }
 }
 public function feedback($id)
 {
     $doctor = auth()->user();
     //Get last 10 reports assigned to this doctor
     $reports = Reports::where('user_id', $id)->where('assigned_doctor_id', $doctor->id)->orderBy('id', 'DESC')->paginate(10);
     if ($reports->total() === 0) {
         abort(404);
     }
     $lastReport = Reports::where('user_id', $id)->where('assigned_doctor_id', $doctor->id)->orderBy('id', 'DESC')->first();
     if (Input::get('conversation')) {
         //If this report doesn't exits, Get outta here
         if (!Reports::where('user_id', $id)->where('assigned_doctor_id', $doctor->id)->where('id', Input::get('conversation'))->orderBy('id', 'DESC')->count()) {
             abort(404);
         }
         //Now getting everything based on user id and report id : if specified
         $lastReport = Reports::where('user_id', $id)->where('assigned_doctor_id', $doctor->id)->where('id', Input::get('conversation'))->first();
         //Same for conversations
         $conversations = Conversation::where('doctor_id', auth()->user()->id)->where('report_id', Input::get('conversation'))->join('users', 'users.id', '=', 'conversations.sender')->get();
     } else {
         $conversations = Conversation::where('doctor_id', auth()->user()->id)->where('report_id', $lastReport->id)->join('users', 'users.id', '=', 'conversations.sender')->get();
     }
     $data = ['conversations' => $conversations, 'reports' => $reports, 'lastReport' => $lastReport, 'id' => $id];
     return view('frontend.doctor.feedback', $data);
 }