Commit 695af99e authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Added possibility to attach files to message

parent 34ed8a16
......@@ -28,14 +28,15 @@ class MailController extends Controller
$returnMessage = '';
# Wir benötigen 3 Felder von dem Benutzer wenn diese nicht übermittelt wurden, oder nicht korrekt sind geben wir einen Error zurück
$input_data = $request->all();
$maxFileSize = 5 * 1024 * 1024;
$validator = Validator::make(
[
'email' => $request->input('email'),
'pcsrf' => $request->input('pcsrf'),
],
$input_data,
[
'email' => 'required|email',
'pcsrf' => ['required', 'string', new \App\Rules\PCSRF],
'attachments' => ['max:5'],
'attachments.*' => ['max:' . $maxFileSize],
]
);
......@@ -63,8 +64,9 @@ class MailController extends Controller
}
$message = $request->input('message');
$subject = $request->input('subject');
$files = $request->file("attachments");
Mail::to($mailto)
->send(new Kontakt($name, $replyTo, $subject, $message));
->send(new Kontakt($name, $replyTo, $subject, $message, $files));
$returnMessage = trans('kontakt.success.1');
$messageType = "success";
......@@ -74,6 +76,8 @@ class MailController extends Controller
->with('title', 'Kontakt')
->with('js', ['lib.js'])
->with($messageType, $returnMessage);
}
public function donation(Request $request)
......
......@@ -15,12 +15,13 @@ class Kontakt extends Mailable
*
* @return void
*/
public function __construct($name, $from, $subject, $message)
public function __construct($name, $from, $subject, $message, $attachments)
{
$this->name = $name;
$this->reply = $from;
$this->subject = $subject;
$this->message = $message;
$this->attachedFiles = $attachments;
}
/**
......@@ -30,9 +31,14 @@ class Kontakt extends Mailable
*/
public function build()
{
return $this->from($this->reply, $this->name)
$mail = $this->from($this->reply, $this->name)
->subject($this->subject)
->text('kontakt.mail')
->with('messageText', $this->message);
foreach($this->attachedFiles as $attachment){
$mail->attachData(file_get_contents($attachment->getRealPath()), $attachment->getClientOriginalName());
}
return $mail;
}
}
......@@ -4,6 +4,8 @@ server {
root /html/public;
index index.php index.html index.htm;
client_max_body_size 50M;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
......
......@@ -4,6 +4,8 @@ server {
root /html/public;
index index.php index.html index.htm;
client_max_body_size 50M;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
......
......@@ -26,6 +26,7 @@ http {
#tcp_nopush on;
keepalive_timeout 65;
client_max_body_size 30M;
gzip on;
......
......@@ -10,6 +10,7 @@ Alternativ können Sie uns natürlich auch per <a href="mailto:support@suma-ev.d
'form.6' => 'Ihre Nachricht',
'form.7' => 'Betreff',
'form.8' => 'Senden',
'form.9' => 'Bis zu 5 Anhänge hinzufügen (Dateigröße < 5 MB)',
'letter.1' => 'Per Brief-Post',
'letter.2' => 'Wir ziehen es vor, auf digitalem Wege kontaktiert zu werden.
Wenn Sie jedoch eine postalische Kontaktaufnahme als unbedingt nötig erachten,
......
......@@ -3,44 +3,48 @@
@section('title', $title )
@section('content')
<div id="kontakt">
<h1 class="page-title">{!! trans('kontakt.headline.1') !!}</h1>
<div class="card-heavy">
<h2>{!! trans('kontakt.form.1') !!}</h2>
<p>{!! trans('kontakt.form.2') !!}</p>
@if(isset($formerrors))
@foreach($formerrors->errors()->all() as $errormessage)
<div class="alert alert-danger" role="alert">{{$errormessage}}</div>
@endforeach
@endif
<form class="contact" name="contact" method="post" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/kontakt") }}">
{{ csrf_field() }}
<input type="hidden" name="pcsrf" value="{{ base64_encode(\time()) }}">
<div class="form-group kontakt-form-group">
<input class="form-control" name="name" placeholder="{!!trans('kontakt.form.name')!!}" type="text" required @if(isset($formerrors) && Request::has('name'))value="{{Request::input('name')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="email" required @if(isset($formerrors) && Request::has('email'))value="{{Request::input('email')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="subject" placeholder="{!! trans('kontakt.form.7') !!}" type="text" required @if(isset($formerrors) && Request::has('subject'))value="{{Request::input('subject')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
@if(isset($url) && $url !== "")
<label for="message">Wenn MetaGer bestimmte Webseiten nicht angezeigt hat, von denen Sie wissen, dass es sie gibt: Bitte nennen Sie deren Adresse/n (http:// ...???...). Wir werden das detailliert untersuchen.</label>
@endif
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}" required>@if(isset($formerrors) && Request::has('message')){{Request::input('message')}}@endif</textarea>
</div>
<div class="form-group kontakt-form-group">
<button title="" data-original-title="" class="btn btn-default encrypt-btn" type="submit">{!! trans('kontakt.form.8') !!}</button>
</div>
</form>
</div>
<div class="card-heavy">
<h2>{!! trans('kontakt.letter.1') !!}</h2>
<p>{!! trans('kontakt.letter.2') !!}</p>
<address>{!! trans('kontakt.letter.3') !!}</address>
</div>
<script src="{{ mix('js/lib.js') }}"></script>
</div>
<div id="kontakt">
<h1 class="page-title">{!! trans('kontakt.headline.1') !!}</h1>
<div class="card-heavy">
<h2>{!! trans('kontakt.form.1') !!}</h2>
<p>{!! trans('kontakt.form.2') !!}</p>
@if(isset($formerrors))
@foreach($formerrors->errors()->all() as $errormessage)
<div class="alert alert-danger" role="alert">{{$errormessage}}</div>
@endforeach
@endif
<form class="contact" name="contact" method="post" action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), "/kontakt") }}" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" name="pcsrf" value="{{ base64_encode(\time()) }}">
<div class="form-group kontakt-form-group">
<input class="form-control" name="name" placeholder="{!!trans('kontakt.form.name')!!}" type="text" required @if(isset($formerrors) && Request::has('name'))value="{{Request::input('name')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="email" required @if(isset($formerrors) && Request::has('email'))value="{{Request::input('email')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="subject" placeholder="{!! trans('kontakt.form.7') !!}" type="text" required @if(isset($formerrors) && Request::has('subject'))value="{{Request::input('subject')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
@if(isset($url) && $url !== "")
<label for="message">Wenn MetaGer bestimmte Webseiten nicht angezeigt hat, von denen Sie wissen, dass es sie gibt: Bitte nennen Sie deren Adresse/n (http:// ...???...). Wir werden das detailliert untersuchen.</label>
@endif
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}" required>@if(isset($formerrors) && Request::has('message')){{Request::input('message')}}@endif</textarea>
</div>
<div class="form-group kontakt-form-group">
<label for="attachments">@lang("kontakt.form.9")</label>
<input type="file" multiple="multiple" name="attachments[]" id="">
</div>
<div class="form-group kontakt-form-group">
<button title="" data-original-title="" class="btn btn-default encrypt-btn" type="submit">{!! trans('kontakt.form.8') !!}</button>
</div>
</form>
</div>
<div class="card-heavy">
<h2>{!! trans('kontakt.letter.1') !!}</h2>
<p>{!! trans('kontakt.letter.2') !!}</p>
<address>{!! trans('kontakt.letter.3') !!}</address>
</div>
<script src="{{ mix('js/lib.js') }}"></script>
</div>
@endsection
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment