user shop sites
This commit is contained in:
parent
22a2b4710a
commit
dc857e88d5
37 changed files with 2044 additions and 869 deletions
|
|
@ -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'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
106
app/Http/Controllers/Web/ContactController.php
Executable file
106
app/Http/Controllers/Web/ContactController.php
Executable file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailContact;
|
||||
use GuzzleHttp\Client;
|
||||
use Input;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
private $GOOGLE_ReCAPTCHA_KEY = "6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU";
|
||||
private $GOOGLE_ReCAPTCHA_SECRET = "6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J";
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'GOOGLE_ReCAPTCHA_KEY' => $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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue