diff --git a/.env b/.env
index 294f0d2..7d2288f 100644
--- a/.env
+++ b/.env
@@ -5,6 +5,9 @@ APP_KEY=base64:HrWQ9AV3Zt2TU0iq1OeUUpTUaXwNUdh8xHmx7RXTif4=
APP_URL=http://mivita.local/
APP_DOMAIN=mivita.local
APP_PROTOCOL=http://
+APP_URL_MAIN=
+#APP_URL_MAIN=dev.
+APP_URL_CRM=mein.
LOG_CHANNEL=stack
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b2b3b33..1dd95e3 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,24 +2,38 @@
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -37,41 +51,42 @@
-
-
-
+
+
+
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -80,22 +95,22 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -115,12 +130,29 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- ?>
- exca
tax
instance
priceTax
@@ -149,6 +181,8 @@
route
$(this).find(".modal-body select[name='factor']").val(button.data('factor'));
dele
+ getRoles
+ admin
@@ -186,57 +220,57 @@
@@ -371,10 +405,10 @@
-
-
-
-
+
+
+
+
@@ -382,6 +416,7 @@
+
@@ -413,29 +448,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -448,12 +460,6 @@
-
-
-
-
-
-
@@ -466,6 +472,11 @@
+
+
+
+
+
@@ -477,90 +488,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -576,65 +514,6 @@
-
-
-
-
-
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-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Http/Controllers/UserShopController.php b/app/Http/Controllers/UserShopController.php
index c28764c..85f249f 100755
--- a/app/Http/Controllers/UserShopController.php
+++ b/app/Http/Controllers/UserShopController.php
@@ -4,6 +4,7 @@
namespace App\Http\Controllers;
use App\Http\Controllers\Api\KasController;
use App\Models\UserShop;
+use App\Models\UserShopOnSite;
use App\Repositories\UserRepository;
use Auth;
use Input;
@@ -25,6 +26,21 @@ class UserShopController extends Controller
public function index()
{
$user = Auth::user();
+
+
+ if ($user->shop && !$user->shop->set_defaults) {
+ if ($user->account) {
+ $user->shop->title = $user->account->first_name . " " . $user->account->last_name;
+ }
+ if ($user->account) {
+ $user->shop->contact = $this->generate_contact($user);
+ } else {
+ $user->shop->contact = "Deine Straße/Nr • Dein PLZ Ort\nFestnetz: Deine Festnetz-Nummer\nMobil: Deine Mobil-Nummer\nDeine E-Mail-Adresse";
+ }
+
+ $user->shop->accessibility = "Mo-Fr: 9.00 - 19.00 Uhr\nSa-So: 11.00 - 18.00 Uhr";
+
+ }
$data = [
'user' => $user,
];
@@ -37,24 +53,46 @@ class UserShopController extends Controller
$user = Auth::user();
$data = Input::all();
- if(!$user->shop){
+ if (!$user->shop) {
abort(404);
}
-
- $user->shop->title = $data['title'];;
- $user->shop->copy = $data['copy'];
- $user->shop->info = $data['info'];
+ $user->shop->title = $data['title'];
+ $user->shop->contact = trim(preg_replace('/\s*\n+/',"\n", $data['contact']));
+ $user->shop->accessibility = trim(preg_replace('/\s*\n+/',"\n", $data['accessibility']));
+ $user->shop->about = trim(preg_replace('/\s+/', ' ',$data['about']));
$user->shop->active = isset($data['active']) ? true : false;
+ $user->shop->set_defaults = true;
$user->shop->save();
\Session()->flash('alert-save', true);
- $data = [
- 'user' => $user,
- ];
- return view('user.shop', $data);
+ return redirect(route('user_shop'));
}
+ private function generate_contact($user)
+ {
+ $ret = "";
+ $sep = "\n";
+
+ $ret = $user->account->street != "" ? $user->account->street : "Deine Straße/Nr";
+ $ret .= " • ";
+ $ret.= $user->account->postal_code != "" ? $user->account->postal_code." " : "Dein PLZ ";
+ $ret.= $user->account->city != "" ? $user->account->city : "Dein Ort";
+ $ret.= $sep;
+
+ $pre = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
+ $ret.= "Festnetz: ".($user->account->phone != "" ? $pre.$user->account->phone : "Deine Festnetz-Nummer");
+ $ret.= $sep;
+
+ $pre = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
+ $ret.= "Mobil: ".($user->account->mobil != "" ? $pre.$user->account->mobil : "Deine Mobil-Nummer");
+ $ret.= $sep;
+
+ $ret.= $user->email;
+
+ return $ret;
+
+ }
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
@@ -141,6 +179,86 @@ class UserShopController extends Controller
}
+ public function uploadOnSiteImage(){
+
+ $user = Auth::user();
+ $user_shop_id = Input::get('user_shop_id');
+
+ if(!$user->shop || $user->shop->id != $user_shop_id){
+ abort(404);
+ }
+
+ try {
+ $image = \App\Services\Slim::getImages('images')[0];
+
+ if ( isset($image['output']['data']) )
+ {
+
+ // Base64 of the image
+ $data = $image['output']['data'];
+ $file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
+
+ if (!isset($file_ex[$image['output']['type']])) {
+ \Session()->flash('alert-danger', 'File is not jpg or png!');
+ return redirect(route('user_shop'));
+ }
+
+ $ext = $file_ex[$image['output']['type']];
+ // Original file name
+ $name = $image['output']['name'];
+ $name = \App\Services\Slim::sanitizeFileName($name);
+ $name = uniqid() . '_' . $name;
+
+ $data = \Storage::disk('public')->put(
+ 'images/user_shop/'.$user->shop->id.'/'.$name,
+ $data
+ );
+
+ UserShopOnSite::create([
+ 'user_shop_id' => $user->shop->id,
+ 'filename' => $name,
+ 'original_name' => $image['output']['name'],
+ 'ext' => $ext,
+ 'mine' => $image['output']['type'],
+ 'size' => $image['input']['size']
+ ]);
+
+ \Session()->flash('alert-success', "Datei hochgeladen");
+ return redirect(route('user_shop'));
+ }
+ \Session()->flash('alert-danger', "Datei leer");
+ return redirect(route('user_shop'));
+
+ }
+ catch (Exception $e) {
+ \Session()->flash('alert-danger', "Fehler".$e);
+ return redirect(route('user_shop'));
+ }
+ }
+
+ public function deleteOnSiteImage($image_id, $user_shop_id){
+
+ $user = Auth::user();
+ if(!$user->shop || $user->shop->id != $user_shop_id){
+ abort(404);
+ }
+ $image = UserShopOnSite::findOrFail($image_id);
+
+ if($image->user_shop_id == $user_shop_id){
+ $file = 'images/user_shop/'.$user_shop_id.'/'.$image->filename;
+ \Storage::disk('public')->delete($file);
+
+ $image->delete();
+
+ \Session()->flash('alert-success', "Datei gelöscht");
+ return redirect(route('user_shop'));
+
+ }
+ \Session()->flash('alert-danger', "Datei nicht gefunden");
+ return redirect(route('user_shop'));
+
+ }
+
diff --git a/app/Http/Controllers/Web/ContactController.php b/app/Http/Controllers/Web/ContactController.php
new file mode 100755
index 0000000..827fc13
--- /dev/null
+++ b/app/Http/Controllers/Web/ContactController.php
@@ -0,0 +1,106 @@
+ $this->GOOGLE_ReCAPTCHA_KEY,
+ 'user_shop' => Util::getUserShop(),
+ ];
+ return view('web.templates.kontakt', $data);
+ }
+
+ public function store()
+ {
+
+ $user_shop = Util::getUserShop();
+
+ $rules = array(
+ 'first_name'=>'required',
+ 'last_name'=>'required',
+ 'email'=>'required|email',
+ 'message'=>'required',
+ 'g-recaptcha-response'=>'required|recaptcha',
+ 'accepted_data_protection' => 'required',
+ );
+
+ Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
+ return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
+ });
+
+ $validator = Validator::make(Input::all(), $rules);
+ if ($validator->fails()) {
+ return back()->withErrors($validator)->withErrors($validator)->withInput(Input::all());
+ }else{
+
+ $contact = [];
+ $contact['first_name'] = Input::get('first_name');
+ $contact['last_name'] = Input::get('last_name');
+ $contact['email'] = Input::get('email');
+ $contact['phone'] = Input::get('phone');
+ $contact['subject'] = Input::get('subject');
+ $contact['message'] = Input::get('message');
+
+ if($user_shop){
+ Mail::to($contact['email'])->bcc([$user_shop->user->email, 'k.adametz@kagado.de'])->send(new MailContact($contact));
+ }else{
+ Mail::to($contact['email'])->bcc('k.adametz@kagado.de')->send(new MailContact($contact));
+ }
+
+ $data = [
+ 'user_shop' => Util::getUserShop(),
+ ];
+ return view('web.templates.contact-final', $data);
+ }
+
+
+ }
+
+
+ private function reCaptcha_validate($attribute, $value, $parameters, $validator)
+ {
+
+ $client = new Client();
+
+ $response = $client->post(
+ 'https://www.google.com/recaptcha/api/siteverify',
+ ['form_params' =>
+ [
+ 'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
+ 'response' => $value
+ ]
+ ]
+ );
+
+ $body = json_decode((string)$response->getBody());
+ return $body->success;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Web/SiteController.php b/app/Http/Controllers/Web/SiteController.php
index f0b766b..1d12de0 100755
--- a/app/Http/Controllers/Web/SiteController.php
+++ b/app/Http/Controllers/Web/SiteController.php
@@ -23,8 +23,12 @@ class SiteController extends Controller
public function index()
{
+ $products = ['aloe-vera-gel-99', 'aloe-vera-saft-500-ml', 'aloe-vera-lippenbalsam'];
+ $set_products = ['aloe-vera-cleaner-set', 'aloe-vera-koerper-set', 'aloe-vera-repair-set'];
$data = [
- 'user_shop' => Util::getUserShop()
+ 'products' => Product::whereIn('slug', $products)->get(),
+ 'set_products' => Product::whereIn('slug', $set_products)->get(),
+ 'user_shop' => Util::getUserShop(),
];
return view('web.index', $data);
}
@@ -32,6 +36,8 @@ class SiteController extends Controller
public function site($site, $subsite = false, $product_slug = false)
{
+ $subsite = trim($subsite, '/');
+ $product_slug = trim($product_slug, '/');
if($product_slug){
$category = Category::where('slug', $subsite)->where('active', true)->first();
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index cef55e6..f3efabf 100755
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -19,6 +19,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
+ # \App\Http\Middleware\RemoveExcessWhitespaceMiddleware::class,
];
/**
diff --git a/app/Http/Middleware/RemoveExcessWhitespaceMiddleware.php b/app/Http/Middleware/RemoveExcessWhitespaceMiddleware.php
new file mode 100755
index 0000000..1abc08a
--- /dev/null
+++ b/app/Http/Middleware/RemoveExcessWhitespaceMiddleware.php
@@ -0,0 +1,29 @@
+getOriginalContent();
+
+ $filters = array(
+ '/
+
+
+
+
+
+
+ {{ $copy1line }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
|
+
+
+
+
+ |
+
+
+
+
+
+
+
+ {{ $salutation }}
+ |
+
+
+
+
+
+
+
+
+ {{ $copy1line }}
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+ @foreach($data as $key=>$value)
+
+ |
+ {{__('email.'.$key)}}:
+ |
+
+ {!! nl2br($value) !!}
+ |
+
+ @endforeach
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+ {{ $copy3line }}
+
+ {{ $greetings }} {{ $sender }}
+
+ |
+
+
+
|
+
+
+
+
+ |
+
+
+
+
+
+
+ |
+
+ mivita e.K. | Leinfeld 2 | 87755 Kirchhaslach
+ Telefon: +49 (0) 8333 946 98 90 | Fax: +49 (0) 8333 7268
+ E-Mail: info@mivita.care
+
+ www.mivita.care
+
+ |
+
+
+ |
+ Geschäftsinhaber: Alois Ried | Registergericht: Memmingen
+ Registernummer: HRA 12236 | USt-ID-Nr.: DE 244162340
+ Datenschutzerklärung
+ © 2018 All Rights Reserved
+
+ |
+
+
+ |
+
+
+
+ |
+
+
+
+