//facebook registration and login Route::get('auth/facebook', 'Auth\\AuthController@redirectToProvider')->name('facebook.login'); Route::get('auth/facebook/callback', 'Auth\\AuthController@handleProviderCallback')->name('facebook.callback'); /* |-------------------------------------------------------------------------- | help files |-------------------------------------------------------------------------- |*/ Route::get('help/index', 'HelpController@index')->name('help.index'); Route::get('help/why-register', 'HelpController@whyRegister')->name('help.why-register'); /* |-------------------------------------------------------------------------- | helper for debugging ajax request and replies |-------------------------------------------------------------------------- |*/ Route::get('emailtest', function () { $user = \App\User::find(4); $email = \App\Email::find(1); \App\Email::sendNewEmailNotification($user, $email, true); //$email = new \App\Mail\ForgotPassword(); //Mail::to('*****@*****.**')->send($email); }); Route::get('error', function () { return view('error'); }); //Route::get('google/page', 'ApiController@googleCoordsPage')->name('google.page'); //Route::get('google/coords/{city}', 'ApiController@getGoogleCoords')->name('google.coords'); //for compiling JS Route::get('compiler', function () { return view('compiler'); });
/** * Safe the email to the database, both for new emails as for replies * * @param Request $request * * @return $this */ public function emailPosted(Request $request) { $email = $request->all(); //the email has to be saved twice, for the sender and the receiver $receiver = $this->_getModelAndId($email['model'], $email['id']); $sender = Auth::user(); if ($sender->id == $receiver->id) { return redirect(route('email.inbox'))->with(['error' => 'You can not email yourself!']); } //create a subject if empty if ($email['subject'] == '') { $email['subject'] = '(no title)'; } //for replied emails, set has_replied if (isset($email['email_id'])) { DB::table('emails')->where('id', $email['email_id'])->update(['has_replied' => 1]); //for inbox DB::table('emails')->where('id', $email['email_id'] + 1)->update(['has_replied' => 1]); //for send box other user } //sender $send_email_id = DB::table('emails')->insertGetId(['subject' => $email['subject'], 'box_id' => '2', 'user_id' => $sender->id, 'sender_id' => $sender->id, 'receiver_id' => $receiver->id, 'body' => $email['body'], 'has_read' => 1, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); //receiver DB::table('emails')->insert(['subject' => $email['subject'], 'box_id' => '1', 'user_id' => $receiver->id, 'sender_id' => $sender->id, 'receiver_id' => $receiver->id, 'body' => $email['body'], 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); $user = User::find($receiver->id); //the user is the receiver, if a copy must be send, do that as well $post = Email::find($send_email_id); //send the email Email::sendNewEmailNotification($user, $post, $email['copy']); if ($email['copy']) { $copy_send = ' A copy has been mailed to ' . Auth::user()->email . '.'; } else { $copy_send = ''; } return redirect(route('email.inbox'))->with(['success' => 'Your email has been send.' . $copy_send]); }