1
0
Fork 0
forked from mirror/pixelfed

Update ContactController

This commit is contained in:
Daniel Supernault 2019-06-06 21:13:52 -06:00
parent fd6a4526ee
commit 09309c1e25
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Auth; use Auth;
use App\Contact;
class ContactController extends Controller class ContactController extends Controller
{ {
@ -24,6 +25,21 @@ class ContactController extends Controller
$message = $request->input('message'); $message = $request->input('message');
$request_response = $request->input('request_response') == 'on' ? true : false; $request_response = $request->input('request_response') == 'on' ? true : false;
$user = Auth::user(); $user = Auth::user();
return $request->all();
$contact = Contact::whereUserId($user->id)
->whereDate('created_at', '>', now()->subDays(1))
->count();
if($contact >= 2) {
return redirect()->back()->with('error', 'You have recently sent a message. Please try again later.');
}
$contact = new Contact;
$contact->user_id = $user->id;
$contact->response_requested = $request_response;
$contact->message = $message;
$contact->save();
return redirect()->back()->with('status', 'Success - Your message has been sent to admins.');
} }
} }