update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
204
app/Http/Controllers/WizardController.php
Executable file → Normal file
204
app/Http/Controllers/WizardController.php
Executable file → Normal file
|
|
@ -38,17 +38,16 @@ class WizardController extends Controller
|
|||
public function __construct(FileRepository $fileRepo)
|
||||
{
|
||||
$this->fileRepo = $fileRepo;
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -57,7 +56,7 @@ class WizardController extends Controller
|
|||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
|
||||
if($step >= 20){
|
||||
if ($step >= 20) {
|
||||
return redirect('/home');
|
||||
}
|
||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
|
@ -70,7 +69,7 @@ class WizardController extends Controller
|
|||
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
||||
];
|
||||
|
||||
if($step == 15){
|
||||
if ($step == 15) {
|
||||
return view('user.wizard.create_release', $data);
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +79,11 @@ class WizardController extends Controller
|
|||
public function register()
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -93,7 +92,7 @@ class WizardController extends Controller
|
|||
|
||||
$step = !$user->wizard ? 0 : $user->wizard;
|
||||
|
||||
if($step >= 10){
|
||||
if ($step >= 10) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
|
|
@ -103,8 +102,8 @@ class WizardController extends Controller
|
|||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(),
|
||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(),
|
||||
];
|
||||
if($step == 5){
|
||||
if($user->active){
|
||||
if ($step == 5) {
|
||||
if ($user->active) {
|
||||
$user->active = false;
|
||||
$user->save();
|
||||
}
|
||||
|
|
@ -116,12 +115,12 @@ class WizardController extends Controller
|
|||
|
||||
public function payment()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$account = UserAccount::create([]);
|
||||
$user->account_id = $account->id;
|
||||
$user->save();
|
||||
|
|
@ -129,9 +128,9 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
if (!$shipping_country_id) {
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
|
|
@ -149,23 +148,24 @@ class WizardController extends Controller
|
|||
];
|
||||
|
||||
|
||||
if($user->wizard == 20){
|
||||
if ($user->wizard == 20) {
|
||||
return view('user.wizard.register_payment', $data);
|
||||
}
|
||||
|
||||
return redirect(route('/'));
|
||||
return redirect(url('/'));
|
||||
}
|
||||
|
||||
private function checkShoppingCountry($user ){
|
||||
private function checkShoppingCountry($user)
|
||||
{
|
||||
|
||||
$country_id = null;
|
||||
if($user->account->same_as_billing){
|
||||
if ($user->account->same_as_billing) {
|
||||
$country_id = $user->account->country_id;
|
||||
}else{
|
||||
} else {
|
||||
$country_id = $user->account->shipping_country_id;
|
||||
}
|
||||
if($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
if ($country_id) {
|
||||
if ($shipping_country = ShippingCountry::whereCountryId($country_id)->first()) {
|
||||
return $shipping_country->id;
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ class WizardController extends Controller
|
|||
|
||||
|
||||
$data = Request::all();
|
||||
if($step == 7 && Request::get('user_country_id')){
|
||||
if ($step == 7 && Request::get('user_country_id')) {
|
||||
$user->account->country_id = Request::get('user_country_id');
|
||||
$user->account->save();
|
||||
return redirect(route('wizard_register', [1]));
|
||||
|
|
@ -209,14 +209,14 @@ class WizardController extends Controller
|
|||
return view('user.wizard.register', $data)->withErrors($validator);
|
||||
}
|
||||
$account = $user->account;
|
||||
if($account->accepted_contract === null){
|
||||
if ($account->accepted_contract === null) {
|
||||
$account->accepted_contract = now();
|
||||
}
|
||||
if($account->data_protection === null){
|
||||
if ($account->data_protection === null) {
|
||||
$account->data_protection = now();
|
||||
}
|
||||
$account->save();
|
||||
if($user->agreement === null){
|
||||
if ($user->agreement === null) {
|
||||
$user->agreement = now();
|
||||
}
|
||||
|
||||
|
|
@ -227,20 +227,20 @@ class WizardController extends Controller
|
|||
if ($step == 1) {
|
||||
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_validate") {
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_register', [0]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_delete") {
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_register', [0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
|
|
@ -282,31 +282,31 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
if ($step == 2) {
|
||||
if(Request::get('submit') === 'do'){
|
||||
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_id_card_deposited_please_upload_first'));
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
if (Request::get('submit') === 'do') {
|
||||
if (File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0) {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_id_card_deposited_please_upload_first'));
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
$this->fileRepo->_set('disk', 'user');
|
||||
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
||||
$this->fileRepo->_set('dir', '/' . $user->id . '/verification/');
|
||||
$this->fileRepo->_set('user_id', $user->id);
|
||||
$this->fileRepo->_set('identifier', 'id_card');
|
||||
return $this->fileRepo->uploadFile(Request::all());
|
||||
}
|
||||
|
||||
if ($step == 3) {
|
||||
if(Request::get('submit') === 'do'){
|
||||
if (Request::get('submit') === 'do') {
|
||||
$data = Request::all();
|
||||
|
||||
if($data['business_license_choose'] === "now"){
|
||||
if(File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0){
|
||||
if ($data['business_license_choose'] === "now") {
|
||||
if (File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0) {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.no_trade_licence_deposited_please_upload_first'));
|
||||
$user->wizard = 3;
|
||||
|
|
@ -314,17 +314,16 @@ class WizardController extends Controller
|
|||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
if($data['business_license_choose'] === "later"){
|
||||
|
||||
if ($data['business_license_choose'] === "later") {
|
||||
}
|
||||
if($data['business_license_choose'] === "non"){
|
||||
if(!$data['non_business_license_reason'] || $data['non_business_license_reason'] == ""){
|
||||
if ($data['business_license_choose'] === "non") {
|
||||
if (!$data['non_business_license_reason'] || $data['non_business_license_reason'] == "") {
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('msg.please_enter_reason_why_you_not_need_trade_licence'));
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}else{
|
||||
} else {
|
||||
$user->account->setNotice('business_license_reason', $data['non_business_license_reason']);
|
||||
}
|
||||
}
|
||||
|
|
@ -336,7 +335,7 @@ class WizardController extends Controller
|
|||
return redirect(route('wizard_register'));
|
||||
}
|
||||
$this->fileRepo->_set('disk', 'user');
|
||||
$this->fileRepo->_set('dir', '/'.$user->id.'/verification/');
|
||||
$this->fileRepo->_set('dir', '/' . $user->id . '/verification/');
|
||||
$this->fileRepo->_set('user_id', $user->id);
|
||||
$this->fileRepo->_set('identifier', 'business_license');
|
||||
return $this->fileRepo->uploadFile(Request::all());
|
||||
|
|
@ -371,13 +370,13 @@ class WizardController extends Controller
|
|||
$user->m_sponsor = $user->m_sponsor ? $user->m_sponsor : 1;
|
||||
$user->account->m_first_name = $user->account->m_first_name ? $user->account->m_first_name : $user->account->first_name;
|
||||
$user->account->m_last_name = $user->account->m_last_name ? $user->account->m_last_name : $user->account->last_name;
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') +1;
|
||||
$user->account->m_account = UserAccount::withTrashed()->max('m_account') + 1;
|
||||
$user->account->save();
|
||||
$user->save();
|
||||
//create PDF
|
||||
$pdf = new ContractPDFRepository($user);
|
||||
$pdf->_set('disk', 'user');
|
||||
$pdf->_set('dir', '/'.$user->id.'/documents/');
|
||||
$pdf->_set('dir', '/' . $user->id . '/documents/');
|
||||
$pdf->_set('user_id', $user->id);
|
||||
$pdf->_set('identifier', 'contract');
|
||||
$pdf->createContractPDF();
|
||||
|
|
@ -393,15 +392,15 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
|
||||
//mail with code to user?
|
||||
if($user->isTestMode()){
|
||||
if ($user->isTestMode()) {
|
||||
$mail = config('app.info_test_mail');
|
||||
}else{
|
||||
} else {
|
||||
$mail = config('app.info_mail');
|
||||
}
|
||||
Mail::to($mail)->locale($user->getLocale())->send(new MailAutoReleaseAccount($user));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'release_account', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'release_account', 'status' => 0]);
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailAccountActive($user));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'released_completed', 'status' => 0]);
|
||||
\Session()->flash('alert-success', __('msg.account_released'));
|
||||
return redirect(route('wizard_payment'));
|
||||
}
|
||||
|
|
@ -409,16 +408,16 @@ class WizardController extends Controller
|
|||
public function storeCreate($step = 0)
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
if (!Auth::check()) {
|
||||
return redirect('login');
|
||||
}
|
||||
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
if(!$user->account){
|
||||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
|
||||
if($step == 10){
|
||||
if ($step == 10) {
|
||||
$rules = array(
|
||||
'accepted_data_protection' => 'required',
|
||||
'accepted_active' => 'required',
|
||||
|
|
@ -434,17 +433,16 @@ class WizardController extends Controller
|
|||
$user->wizard = 10;
|
||||
$user->save();
|
||||
return view('user.wizard.create', $data)->withErrors($validator);
|
||||
|
||||
}
|
||||
$account = $user->account;
|
||||
if($account->accepted_contract === null){
|
||||
if ($account->accepted_contract === null) {
|
||||
$account->accepted_contract = now();
|
||||
}
|
||||
if($account->data_protection === null){
|
||||
if ($account->data_protection === null) {
|
||||
$account->data_protection = now();
|
||||
}
|
||||
$account->save();
|
||||
if($user->agreement === null){
|
||||
if ($user->agreement === null) {
|
||||
$user->agreement = now();
|
||||
}
|
||||
$user->wizard = 11;
|
||||
|
|
@ -452,9 +450,9 @@ class WizardController extends Controller
|
|||
|
||||
return redirect(route('wizard_create', [11]));
|
||||
}
|
||||
if($step == 11){
|
||||
if ($step == 11) {
|
||||
|
||||
if($user->isPasswort()){
|
||||
if ($user->isPasswort()) {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [12]));
|
||||
|
|
@ -481,23 +479,23 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
return redirect(route('wizard_create', [12]));
|
||||
}
|
||||
if($step == 12){
|
||||
if ($step == 12) {
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_validate") {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
|
||||
if (isset($data['action']) && $data['action'] == "reverse_charge_delete") {
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rules = array(
|
||||
|
|
@ -513,12 +511,12 @@ class WizardController extends Controller
|
|||
'birthday' => 'required',
|
||||
);
|
||||
|
||||
if(!Request::get('same_as_billing')){
|
||||
if (!Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
|
||||
|
|
@ -541,59 +539,59 @@ class WizardController extends Controller
|
|||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
return redirect(route('wizard_create', [13]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function storePayment($step = 0){
|
||||
public function storePayment($step = 0)
|
||||
{
|
||||
|
||||
if(Request::get('switchers-package-wizard')){
|
||||
if (Request::get('switchers-package-wizard')) {
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Request::get('switchers-package-wizard'));
|
||||
$showAboOptions = false;
|
||||
if(Request::get('abo_options')){
|
||||
if (Request::get('abo_options')) {
|
||||
$showAboOptions = false; //true Abo Option deaktivert
|
||||
$user->abo_options = false; //true Abo Option deaktivert
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
if (!$shipping_country_id) {
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
|
||||
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
|
||||
Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id);
|
||||
|
||||
|
||||
if($product && $product->active){
|
||||
if ($product && $product->active) {
|
||||
//set membership product
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
if (\App\Services\UserService::getTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
|
||||
|
||||
//set onboarding products
|
||||
if(Request::get('products_on_board')){
|
||||
foreach (Request::get('products_on_board') as $product_on_board_id){
|
||||
if (Request::get('products_on_board')) {
|
||||
foreach (Request::get('products_on_board') as $product_on_board_id) {
|
||||
$product_on_board = Product::find($product_on_board_id);
|
||||
$image = "";
|
||||
if($product_on_board->images->count()){
|
||||
if ($product_on_board->images->count()) {
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission, 'show_on' => $product_on_board->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
if (\App\Services\UserService::getTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
}
|
||||
|
|
@ -601,7 +599,7 @@ class WizardController extends Controller
|
|||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'wizard';
|
||||
|
|
@ -622,29 +620,27 @@ class WizardController extends Controller
|
|||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'wizard_payment', 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier, 'abo_options'=>$showAboOptions]);
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action' => 'wizard_payment', 'status' => 1, 'product_id' => $product->id, 'identifier' => $identifier, 'abo_options' => $showAboOptions]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-error', "Fehler beim Produkt");
|
||||
return back();
|
||||
}
|
||||
|
||||
public function delete($id, $relation){
|
||||
public function delete($id, $relation)
|
||||
{
|
||||
|
||||
if($relation === 'upload'){
|
||||
if ($relation === 'upload') {
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
$file = $user->files()->findOrFail($id);
|
||||
//remove file
|
||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||
\Storage::disk('user')->delete($file->dir . $file->filename);
|
||||
$file->delete();
|
||||
\Session()->flash('alert-success', __('msg.file_deleted'));
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue