membership register
This commit is contained in:
parent
3711fcc8d0
commit
37cb2b06c7
38 changed files with 1261 additions and 463 deletions
|
|
@ -93,6 +93,15 @@ class PayoneController extends Controller
|
|||
die();
|
||||
}
|
||||
|
||||
/* TODO -- need this?
|
||||
|
||||
if($shopping_payment->txaction == $data['txaction']){
|
||||
\Log::channel('payone')->error('PaymentStatus: same txaction error: '.json_encode($data));
|
||||
echo "PaymentStatus: same txaction:";
|
||||
var_dump($data);
|
||||
die();
|
||||
}
|
||||
*/
|
||||
//create transaction
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
|
|
@ -110,13 +119,15 @@ class PayoneController extends Controller
|
|||
$shopping_payment->txaction = $data['txaction'];
|
||||
$shopping_payment->save();
|
||||
|
||||
|
||||
if($data['txaction'] == 'failed'){
|
||||
$send_link = false;
|
||||
if($data['txaction'] === 'failed'){
|
||||
|
||||
}
|
||||
if($data['txaction'] == 'paid'){
|
||||
|
||||
if($data['txaction'] === 'paid'){
|
||||
$shopping_order->paid = true;
|
||||
$shopping_order->save();
|
||||
|
||||
//if product has actions
|
||||
if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){
|
||||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
|
|
@ -124,14 +135,18 @@ class PayoneController extends Controller
|
|||
if($shopping_order_item->product->action){
|
||||
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->payment_order_id = $shopping_order_item->product->id;
|
||||
$user->save();
|
||||
$send_link = true;
|
||||
$date = date("Y-m-d H:i:s", strtotime("+1 years"));
|
||||
foreach ($shopping_order_item->product->action as $do){
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
|
||||
$user->payment_account = date("Y-m-d H:i:s", strtotime("+1 years"));
|
||||
$user->wizard = 10;
|
||||
$user->payment_account = $date;
|
||||
$user->wizard = 100;
|
||||
}
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
|
||||
$user->payment_shop = date("Y-m-d H:i:s", strtotime("+1 years"));
|
||||
$user->wizard = 10;
|
||||
$user->payment_shop = $date;
|
||||
$user->wizard = 100;
|
||||
}
|
||||
$user->save();
|
||||
}
|
||||
|
|
@ -141,7 +156,7 @@ class PayoneController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['txaction'] == 'appointed'){
|
||||
if($data['txaction'] === 'appointed'){
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +167,9 @@ class PayoneController extends Controller
|
|||
}
|
||||
$checkout_mail = config('app.checkout_mail');
|
||||
if($user_shop_email){
|
||||
Mail::to($billing_email)->bcc([$user_shop_email, $checkout_mail])->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment));
|
||||
Mail::to($billing_email)->bcc([$user_shop_email, $checkout_mail])->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link));
|
||||
}else{
|
||||
Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment));
|
||||
Mail::to($billing_email)->bcc($checkout_mail)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link));
|
||||
}
|
||||
|
||||
print("TSOK");
|
||||
|
|
|
|||
|
|
@ -32,14 +32,15 @@ class HomeController extends Controller
|
|||
|
||||
}
|
||||
|
||||
//login
|
||||
//login / Dashboard
|
||||
public function show()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
return redirect('login');
|
||||
}
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'now' => Carbon::now(),
|
||||
];
|
||||
return view('home', $data);
|
||||
}
|
||||
|
|
@ -226,15 +227,16 @@ class HomeController extends Controller
|
|||
$ShoppingPayment = ShoppingPayment::where('reference', $reference)->first();
|
||||
if($ShoppingPayment && $ShoppingPayment->status === 'success'){
|
||||
$user = Auth::user();
|
||||
if($user && $user->wizard < 4){
|
||||
$user->wizard = 4;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [4]));
|
||||
//is form wizard create payment
|
||||
if($user && ($user->wizard == 13 || $user->wizard == 20)){
|
||||
$user->wizard = 15; //realese Payments
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [15]));
|
||||
}
|
||||
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Es ist ein Fehler bei der Bestellung aufgetreten");
|
||||
return redirect(route('wizard'));
|
||||
return redirect(route('/'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
86
app/Http/Controllers/MembershipController.php
Executable file
86
app/Http/Controllers/MembershipController.php
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use Request;
|
||||
use Input;
|
||||
use Util;
|
||||
use Yard;
|
||||
|
||||
class MembershipController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
'upgrade' => Product::where('active', true)->where('show_at', '=', 4)->where('identifier', 'upgrade')->get(),
|
||||
];
|
||||
return view('user.membership.index', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function storePayment($step = 0){
|
||||
if(Input::get('switchers-package-wizard')){
|
||||
$user = Auth::user();
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Input::get('switchers-package-wizard'));
|
||||
|
||||
if(Input::get('abo_options')){
|
||||
$user->abo_options = true;
|
||||
$user->save();
|
||||
}
|
||||
if($product && $product->active && $product->show_at >= 3){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Input::get('qty') ? Input::get('qty') : 1;
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop!
|
||||
'auth_user_id' => Auth::user()->id,
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,7 +68,6 @@ class PayoneController extends Controller
|
|||
$this->default = \Config::get('payone.defaults');
|
||||
}
|
||||
|
||||
|
||||
public function init($shopping_user, $shopping_order){
|
||||
$this->shopping_user = $shopping_user;
|
||||
$this->shopping_order = $shopping_order;
|
||||
|
|
@ -81,7 +80,7 @@ class PayoneController extends Controller
|
|||
//make Payone payment
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
|
||||
|
||||
$this->reference = substr(uniqid(true), 0, 16);
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
$this->setMethod($payment_method, $ret);
|
||||
|
||||
$this->urls = [
|
||||
|
|
@ -342,10 +341,8 @@ class PayoneController extends Controller
|
|||
];
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
|
||||
|
||||
|
||||
// dd($request);
|
||||
return Payone::sendRequest($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,15 +21,13 @@ class UserShopController extends Controller
|
|||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('active.shop');
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Models\ShoppingOrder;
|
|||
use App\Models\ShoppingOrderItem;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\User;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Collection;
|
||||
use Validator;
|
||||
|
|
@ -43,12 +44,9 @@ class CheckoutController extends Controller
|
|||
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
|
||||
// $selected_country = $ShippingCountry->id;
|
||||
}
|
||||
|
||||
if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){
|
||||
|
||||
$user = Util::getAuthUser();
|
||||
$user->email;
|
||||
$account = $user->account;
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->auth_user_id = $user->id;
|
||||
$shopping_user->billing_salutation = $user->account->salutation;
|
||||
|
|
@ -74,6 +72,7 @@ class CheckoutController extends Controller
|
|||
$shopping_user->shipping_city = $user->account->shipping_city;
|
||||
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
|
||||
$shopping_user->shipping_phone = $user->account->shipping_phone;
|
||||
$shopping_user->abo_options = $user->abo_options;
|
||||
$shopping_user->save();
|
||||
$this->putPayments('shopping_user_id', $shopping_user->id);
|
||||
|
||||
|
|
@ -200,6 +199,9 @@ class CheckoutController extends Controller
|
|||
$ret['elv']['iban'] = $data['elv_iban'];
|
||||
$ret['elv']['bic'] = $data['elv_bic'];
|
||||
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
|
||||
//check abo and save the mandate
|
||||
$this->storeUserPaymentsData($shopping_user, $ret);
|
||||
|
||||
}
|
||||
//other
|
||||
$pay = new PayoneController();
|
||||
|
|
@ -271,6 +273,18 @@ class CheckoutController extends Controller
|
|||
return view('web.templates.checkout-final', $data);
|
||||
}
|
||||
|
||||
private function storeUserPaymentsData($shopping_user, $ret){
|
||||
if($shopping_user->auth_user_id){
|
||||
$user = User::find($shopping_user->auth_user_id);
|
||||
if($user && $user->account && $user->abo_options){
|
||||
if(isset($ret['elv']) && is_array($ret['elv'])){
|
||||
$user->account->payment_data = $ret['elv'];
|
||||
$user->account->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function makeShoppingUser($data){
|
||||
|
||||
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
|
||||
|
|
@ -365,6 +379,7 @@ class CheckoutController extends Controller
|
|||
$this->session->put($this->instance, $content);
|
||||
|
||||
}
|
||||
|
||||
private function getPayments($key){
|
||||
$content = $this->getContent();
|
||||
if ($content->has($key)){
|
||||
|
|
@ -372,6 +387,7 @@ class CheckoutController extends Controller
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getContent()
|
||||
{
|
||||
if (is_null($this->session->get($this->instance))) {
|
||||
|
|
@ -380,7 +396,6 @@ class CheckoutController extends Controller
|
|||
return $this->session->get($this->instance);
|
||||
}
|
||||
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$this->session->remove($this->instance);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class WizardController extends Controller
|
|||
|
||||
public function create()
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
|
|
@ -46,11 +45,12 @@ class WizardController extends Controller
|
|||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
return redirect(route('wizard'));
|
||||
return redirect(route('wizard_create'));
|
||||
}
|
||||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
if($step == 10){
|
||||
|
||||
if($step >= 20){
|
||||
return redirect('/');
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -59,6 +59,10 @@ class WizardController extends Controller
|
|||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
|
||||
if($step == 15){
|
||||
return view('user.wizard.create_release', $data);
|
||||
}
|
||||
|
||||
return view('user.wizard.create', $data);
|
||||
}
|
||||
|
||||
|
|
@ -73,12 +77,12 @@ class WizardController extends Controller
|
|||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
return redirect(route('wizard'));
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
|
||||
if($step == 10){
|
||||
if($step >= 10){
|
||||
return redirect('/');
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -93,6 +97,33 @@ class WizardController extends Controller
|
|||
return view('user.wizard.register', $data);
|
||||
}
|
||||
|
||||
public function payment()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
return redirect(route('wizard_payment'));
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'step' => 0,
|
||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
|
||||
if($user->wizard == 20){
|
||||
return view('user.wizard.register_payment', $data);
|
||||
}
|
||||
|
||||
return redirect(route('/'));
|
||||
}
|
||||
|
||||
public function storeRegister($step = false)
|
||||
{
|
||||
|
||||
|
|
@ -235,7 +266,7 @@ class WizardController extends Controller
|
|||
$user->account = new UserAccount();
|
||||
}
|
||||
|
||||
if($step == 0){
|
||||
if($step == 10){
|
||||
$rules = array(
|
||||
'accepted_data_protection' => 'required',
|
||||
'accepted_active' => 'required',
|
||||
|
|
@ -245,33 +276,33 @@ class WizardController extends Controller
|
|||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'step' => $step,
|
||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
return view('user.wizard.show', $data)->withErrors($validator);
|
||||
$user->wizard = 10;
|
||||
$user->save();
|
||||
return view('user.wizard.create', $data)->withErrors($validator);
|
||||
|
||||
}
|
||||
$account = $user->account;
|
||||
$account->data_protection = now();
|
||||
if($account->data_protection === null){
|
||||
$account->data_protection = now();
|
||||
}
|
||||
if($user->agreement === null){
|
||||
$user->agreement = now();
|
||||
}
|
||||
$account->save();
|
||||
$user->agreement = now();
|
||||
if($user->wizard < 1){
|
||||
$user->wizard = 1;
|
||||
}
|
||||
$user->wizard = 11;
|
||||
$user->save();
|
||||
|
||||
return redirect(route('wizard', [1]));
|
||||
return redirect(route('wizard_create', [11]));
|
||||
}
|
||||
if($step == 1){
|
||||
if($step == 11){
|
||||
|
||||
if($user->isPasswort()){
|
||||
if($user->wizard < 2){
|
||||
$user->wizard = 2;
|
||||
}
|
||||
//has Passwort -> delete Code!
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [2]));
|
||||
return redirect(route('wizard_create', [12]));
|
||||
}
|
||||
$rules = array(
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
|
|
@ -281,34 +312,31 @@ class WizardController extends Controller
|
|||
$data = [
|
||||
'user' => Auth::user(),
|
||||
'step' => $step,
|
||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
return view('user.wizard.show', $data)->withErrors($validator);
|
||||
}else{
|
||||
$user->fill([
|
||||
'password' => Hash::make(Input::get('password'))
|
||||
])->save();
|
||||
if($user->wizard < 2){
|
||||
$user->wizard = 2;
|
||||
}
|
||||
//has Passwort -> delete Code!
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [2]));
|
||||
|
||||
|
||||
|
||||
return view('user.wizard.create', $data)->withErrors($validator);
|
||||
}
|
||||
|
||||
$user->fill([
|
||||
'password' => Hash::make(Input::get('password'))
|
||||
])->save();
|
||||
$user->wizard = 12;
|
||||
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [12]));
|
||||
}
|
||||
if($step == 2){
|
||||
if($step == 12){
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'address'=>'required',
|
||||
'zipcode'=>'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'address' => 'required',
|
||||
'zipcode' => 'required',
|
||||
'city' => 'required',
|
||||
'phone' => 'required_without:mobil',
|
||||
'mobil' => 'required_without:phone',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'birthday' => 'required',
|
||||
);
|
||||
|
||||
if(!Input::get('same_as_billing')){
|
||||
|
|
@ -324,63 +352,65 @@ class WizardController extends Controller
|
|||
}
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('wizard', [2]))->withErrors($validator)->withInput(Input::all());
|
||||
}else{
|
||||
$data = Input::all();
|
||||
$data['same_as_billing'] = Input::get('same_as_billing') == NULL ? 0 : 1;
|
||||
$user->account->fill($data)->save();
|
||||
if($user->wizard < 3){
|
||||
$user->wizard = 3;
|
||||
}
|
||||
$user->active_date = now();
|
||||
$user->active = 1;
|
||||
$user->save();
|
||||
return redirect(route('wizard', [3]));
|
||||
|
||||
return redirect(route('wizard_create', [12]))->withErrors($validator)->withInput(Input::all());
|
||||
}
|
||||
}
|
||||
|
||||
if($step == 3){
|
||||
$data = Input::all();
|
||||
$data['same_as_billing'] = Input::get('same_as_billing') == NULL ? 0 : 1;
|
||||
$user->account->fill($data)->save();
|
||||
|
||||
$user->wizard = 13;
|
||||
$user->active_date = now();
|
||||
$user->active = 1;
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [13]));
|
||||
|
||||
if(Input::get('switchers-package-wizard')){
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Input::get('switchers-package-wizard'));
|
||||
if($product && $product->active && $product->show_at == 3){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop!
|
||||
'auth_user_id' => $user->id,
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
||||
return redirect(route('wizard', [3]));
|
||||
}
|
||||
}
|
||||
|
||||
public function storePayment($step = 0){
|
||||
if(Input::get('switchers-package-wizard')){
|
||||
$user = Auth::user();
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Input::get('switchers-package-wizard'));
|
||||
|
||||
if(Input::get('abo_options')){
|
||||
$user->abo_options = true;
|
||||
$user->save();
|
||||
}
|
||||
if($product && $product->active && $product->show_at == 3){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop!
|
||||
'auth_user_id' => Auth::user()->id,
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
||||
return back();
|
||||
}
|
||||
|
||||
public function delete($id, $relation){
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ class Kernel extends HttpKernel
|
|||
'admin' => \App\Http\Middleware\Admin::class,
|
||||
'superadmin' => \App\Http\Middleware\SuperAdmin::class,
|
||||
'sysadmin' => \App\Http\Middleware\SysAdmin::class,
|
||||
'active.account' => \App\Http\Middleware\ActiveAccount::class,
|
||||
'active.shop' => \App\Http\Middleware\ActiveShop::class,
|
||||
'subdomain' => \App\Http\Middleware\Subdomain::class,
|
||||
'checkout' => \App\Http\Middleware\Checkout::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
|
|||
26
app/Http/Middleware/ActiveAccount.php
Executable file
26
app/Http/Middleware/ActiveAccount.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class ActiveAccount
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ( Auth::check() && Auth::user()->isActiveAccount() )
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
26
app/Http/Middleware/ActiveShop.php
Executable file
26
app/Http/Middleware/ActiveShop.php
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
class ActiveShop
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ( Auth::check() && Auth::user()->isActiveShop() )
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -56,11 +56,10 @@ class Authenticate
|
|||
if(in_array('user', $guards) && $this->auth->user()->wizard < 20){
|
||||
return redirect(route('wizard_create'));
|
||||
}
|
||||
//is wizard
|
||||
/*if(in_array('user', $guards) && $this->auth->user()->wizard < 5){
|
||||
return redirect(route('wizard'));
|
||||
//20 is payment
|
||||
if(in_array('user', $guards) && $this->auth->user()->wizard == 20){
|
||||
return redirect(route('wizard_payment'));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Carbon;
|
||||
use Closure;
|
||||
use Auth;
|
||||
|
||||
|
|
@ -20,8 +21,7 @@ class Localization
|
|||
|
||||
if ( \Session::has('locale')) {
|
||||
\App::setLocale(\Session::get('locale'));
|
||||
// You also can set the Carbon locale
|
||||
//Carbon::setLocale(\Session::get('locale'));
|
||||
Carbon::setLocale(\Session::get('locale'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
|
|||
|
|
@ -15,16 +15,18 @@ class MailCheckout extends Mailable
|
|||
public $txaction;
|
||||
public $shopping_order;
|
||||
public $shopping_payment;
|
||||
protected $send_link;
|
||||
|
||||
public $subject;
|
||||
public $data;
|
||||
|
||||
|
||||
public function __construct($txaction, $shopping_order, $shopping_payment)
|
||||
public function __construct($txaction, $shopping_order, $shopping_payment, $send_link)
|
||||
{
|
||||
$this->txaction = $txaction;
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->shopping_payment = $shopping_payment;
|
||||
$this->send_link = $send_link;
|
||||
|
||||
$this->subject = __('email.checkout_subject')." mivita.care";
|
||||
if($shopping_order->user_shop){
|
||||
|
|
@ -42,6 +44,11 @@ class MailCheckout extends Mailable
|
|||
//make Adresse
|
||||
}
|
||||
if($this->txaction === 'paid'){
|
||||
|
||||
|
||||
if($this->send_link){
|
||||
|
||||
}
|
||||
return $this->view('emails.checkout')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => __('email.checkout_copy1line'),
|
||||
|
|
@ -50,6 +57,9 @@ class MailCheckout extends Mailable
|
|||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
'send_link' => $this->send_link,
|
||||
'url' => Util::getMyMivitaUrl(),
|
||||
'button' => Util::getMyMivitaUrl(false),
|
||||
]);
|
||||
}else{
|
||||
return $this->view('emails.checkout_status')->with([
|
||||
|
|
@ -61,6 +71,7 @@ class MailCheckout extends Mailable
|
|||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
'send_link' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ class Product extends Model
|
|||
'amount',
|
||||
'active',
|
||||
'show_at',
|
||||
'identifier',
|
||||
'action'
|
||||
];
|
||||
|
||||
|
|
@ -141,6 +142,7 @@ class Product extends Model
|
|||
1 => 'User + Berater Shop',
|
||||
2 => 'nur Berater Shop',
|
||||
3 => 'Registrierung Shop',
|
||||
4 => 'Mitgliedschaft Berater',
|
||||
];
|
||||
|
||||
public $actions = [
|
||||
|
|
|
|||
|
|
@ -124,6 +124,10 @@ class UserAccount extends Model
|
|||
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payment_data' => 'array',
|
||||
];
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Util
|
|||
}
|
||||
|
||||
public static function formatDate(){
|
||||
if(\App::getLocale() == "en"){
|
||||
if(\App::getLocale() === "en"){
|
||||
return 'yyyy-mm-dd';
|
||||
}
|
||||
return 'dd.mm.yyyy';
|
||||
|
|
@ -24,19 +24,26 @@ class Util
|
|||
}
|
||||
|
||||
public static function formatDateDB(){
|
||||
if(\App::getLocale() == "en"){
|
||||
if(\App::getLocale() === "en"){
|
||||
return 'Y-m-d';
|
||||
}
|
||||
return 'd.m.Y';
|
||||
}
|
||||
|
||||
public static function formatDateTimeDB(){
|
||||
if(\App::getLocale() == "en"){
|
||||
if(\App::getLocale() === "en"){
|
||||
return 'Y-m-d - H:i';
|
||||
}
|
||||
return 'd.m.Y - H:i';
|
||||
}
|
||||
|
||||
public static function formatNumber($value){
|
||||
if(\App::getLocale() === "en"){
|
||||
return number_format($value, 2, '.', ',');
|
||||
}
|
||||
return number_format($value, 2, ',', '.');
|
||||
}
|
||||
|
||||
public static function utf8ize( $mixed ) {
|
||||
if (is_array($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
|
|
@ -95,6 +102,10 @@ class Util
|
|||
return false;
|
||||
}
|
||||
|
||||
public static function getMyMivitaUrl($protocol = true){
|
||||
$pro = $protocol ? config('app.protocol') : "";
|
||||
return $pro.config('app.pre_url_crm').config('app.domain').config('app.tld_care');
|
||||
}
|
||||
public static function getUserShopBackUrl($reference = ""){
|
||||
|
||||
if(\Session::has('user_shop')){
|
||||
|
|
|
|||
14
app/User.php
14
app/User.php
|
|
@ -129,11 +129,21 @@ class User extends Authenticatable
|
|||
|
||||
}
|
||||
|
||||
public function payment_order(){
|
||||
return $this->belongsTo('App\Models\Product', 'payment_order_id');
|
||||
}
|
||||
|
||||
public function files(){
|
||||
return $this->hasMany('App\Models\File', 'user_id', '');
|
||||
|
||||
}
|
||||
|
||||
public function shopping_orders(){
|
||||
return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', '');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function shop()
|
||||
{
|
||||
return $this->hasOne('App\Models\UserShop', 'user_id', 'id');
|
||||
|
|
@ -141,7 +151,6 @@ class User extends Authenticatable
|
|||
|
||||
|
||||
|
||||
|
||||
public function user_update_email()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id');
|
||||
|
|
@ -228,7 +237,6 @@ class User extends Authenticatable
|
|||
}
|
||||
|
||||
public function daysHumansActiveAccount(){
|
||||
Carbon::setLocale(\App::getLocale());
|
||||
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_account));
|
||||
}
|
||||
|
||||
|
|
@ -241,11 +249,9 @@ class User extends Authenticatable
|
|||
}
|
||||
|
||||
public function daysHumansActiveShop(){
|
||||
Carbon::setLocale(\App::getLocale());
|
||||
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_shop));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue