Pint: Formatierung des bisherigen Stands, ohne inhaltliche Aenderung
Die Dateien lagen im Arbeitsbaum formatiert und inhaltlich geaendert zusammen. Dieser Commit enthaelt nur die Pint-Formatierung des alten Stands, damit die folgenden Commits nur noch Inhalt zeigen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bdef77462d
commit
316a9b76d6
33 changed files with 880 additions and 841 deletions
|
|
@ -1,25 +1,20 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Exports\xExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Request;
|
||||
|
||||
class PaymentSalesController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
|
@ -32,132 +27,135 @@ class PaymentSalesController extends Controller
|
|||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
];
|
||||
|
||||
return view('admin.payment.salesvolume', $data);
|
||||
}
|
||||
|
||||
|
||||
public function download(){
|
||||
|
||||
public function download()
|
||||
{
|
||||
|
||||
/*
|
||||
EXCEL EXPORT function */
|
||||
|
||||
/*
|
||||
if(Request::get('action') === "exportfull_paid"){
|
||||
return $this->exportFullList(1);
|
||||
}
|
||||
if(Request::get('action') === "exportfull_unpaid"){
|
||||
return $this->exportFullList(0);
|
||||
}
|
||||
*/
|
||||
if(Request::get('action') === "exportfull_paid_invoice"){
|
||||
/*
|
||||
if(Request::get('action') === "exportfull_paid"){
|
||||
return $this->exportFullList(1);
|
||||
}
|
||||
if(Request::get('action') === "exportfull_unpaid"){
|
||||
return $this->exportFullList(0);
|
||||
}
|
||||
*/
|
||||
if (Request::get('action') === 'exportfull_paid_invoice') {
|
||||
return $this->exportFullListInvoice();
|
||||
}
|
||||
if(Request::get('action') === "export"){
|
||||
}
|
||||
if (Request::get('action') === 'export') {
|
||||
return $this->exportKompaktListInvoice();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('payment_sales_vol_filter_month')){
|
||||
if (! session('payment_sales_vol_filter_month')) {
|
||||
session(['payment_sales_vol_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('payment_sales_vol_filter_year')){
|
||||
if (! session('payment_sales_vol_filter_year')) {
|
||||
session(['payment_sales_vol_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('payment_sales_vol_filter_month')){
|
||||
if (Request::get('payment_sales_vol_filter_month')) {
|
||||
session(['payment_sales_vol_filter_month' => Request::get('payment_sales_vol_filter_month')]);
|
||||
}
|
||||
if(Request::get('payment_sales_vol_filter_year')){
|
||||
if (Request::get('payment_sales_vol_filter_year')) {
|
||||
session(['payment_sales_vol_filter_year' => Request::get('payment_sales_vol_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function exportKompaktListInvoice(){
|
||||
private function exportKompaktListInvoice()
|
||||
{
|
||||
$objects = $this->initKompaktList();
|
||||
$columns = [];
|
||||
$filename = "mivita-absatzmengen-kompakt".session('payment_sales_vol_filter_month').'_'.session('payment_sales_vol_filter_year')."-export";
|
||||
$headers = array(
|
||||
$filename = 'mivita-absatzmengen-kompakt'.session('payment_sales_vol_filter_month').'_'.session('payment_sales_vol_filter_year').'-export';
|
||||
$headers = [
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
|
||||
);
|
||||
if($objects){
|
||||
foreach ($objects as $key => $obj){
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
|
||||
];
|
||||
if ($objects) {
|
||||
foreach ($objects as $key => $obj) {
|
||||
$columns[] = [
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
|
||||
|
||||
private function exportFullListInvoice(){
|
||||
private function exportFullListInvoice()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
|
||||
$UserInvoices = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', session('payment_sales_vol_filter_month'))
|
||||
->where('user_invoices.year', '=', session('payment_sales_vol_filter_year'))
|
||||
->get();
|
||||
->where('user_invoices.month', '=', session('payment_sales_vol_filter_month'))
|
||||
->where('user_invoices.year', '=', session('payment_sales_vol_filter_year'))
|
||||
->get();
|
||||
|
||||
$headers = array('Rechnungsnummer','Datum', 'EMail', 'Zahlung', 'ProduktNummer', 'ProduktName', 'Anzahl', 'Summe', 'Kompensation');
|
||||
$headers = ['Rechnungsnummer', 'Datum', 'EMail', 'Zahlung', 'ProduktNummer', 'ProduktName', 'Anzahl', 'Summe', 'Kompensation'];
|
||||
$columns = [];
|
||||
$hasSOID = [];
|
||||
$total_value = [];
|
||||
|
||||
foreach($UserInvoices as $UserInvoice){
|
||||
if($UserInvoice->shopping_order){
|
||||
foreach ($UserInvoices as $UserInvoice) {
|
||||
if ($UserInvoice->shopping_order) {
|
||||
$ShoppingOrder = $UserInvoice->shopping_order;
|
||||
$object = [];
|
||||
$object['Rechnungsnummer'] = $UserInvoice->full_number;
|
||||
$object['Datum'] = $UserInvoice->date;
|
||||
$object['EMail'] = $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_email : 'n/a';
|
||||
$object['Zahlung'] = $ShoppingOrder->getPaymentForType();
|
||||
$object['Rechnungsnummer'] = $UserInvoice->full_number;
|
||||
$object['Datum'] = $UserInvoice->date;
|
||||
$object['EMail'] = $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->billing_email : 'n/a';
|
||||
$object['Zahlung'] = $ShoppingOrder->getPaymentForType();
|
||||
|
||||
if($ShoppingOrder->payment_for === 5){ //homeparty
|
||||
if($ShoppingOrder->homeparty){
|
||||
foreach($ShoppingOrder->homeparty->homeparty_order_items as $homeparty_item){
|
||||
if ($ShoppingOrder->payment_for === 5) { // homeparty
|
||||
if ($ShoppingOrder->homeparty) {
|
||||
foreach ($ShoppingOrder->homeparty->homeparty_order_items as $homeparty_item) {
|
||||
$total_value[$homeparty_item->product_id] = isset($total_value[$homeparty_item->product_id]) ? $total_value[$homeparty_item->product_id] + $homeparty_item->qty : $homeparty_item->qty;
|
||||
$object['ProduktNummer'] = $homeparty_item->product ? $homeparty_item->product->number : "n/a";
|
||||
$object['ProduktName'] = $homeparty_item->product ? $homeparty_item->product->name : "n/a";
|
||||
$object['Anzahl'] = $homeparty_item->qty;
|
||||
$object['Summe'] = $total_value[$homeparty_item->product_id];
|
||||
$object['Kompensation'] = '';
|
||||
$object['ProduktNummer'] = $homeparty_item->product ? $homeparty_item->product->number : 'n/a';
|
||||
$object['ProduktName'] = $homeparty_item->product ? $homeparty_item->product->name : 'n/a';
|
||||
$object['Anzahl'] = $homeparty_item->qty;
|
||||
$object['Summe'] = $total_value[$homeparty_item->product_id];
|
||||
$object['Kompensation'] = '';
|
||||
$columns[] = $object;
|
||||
}
|
||||
}
|
||||
|
||||
}elseif($ShoppingOrder->payment_for === 8){ //collective_invoice
|
||||
if($ShoppingOrder->shopping_collect_order){
|
||||
foreach($ShoppingOrder->shopping_collect_order->shop_items as $shop_item){
|
||||
} elseif ($ShoppingOrder->payment_for === 8) { // collective_invoice
|
||||
if ($ShoppingOrder->shopping_collect_order) {
|
||||
foreach ($ShoppingOrder->shopping_collect_order->shop_items as $shop_item) {
|
||||
$total_value[$shop_item['pid']] = isset($total_value[$shop_item['pid']]) ? $total_value[$shop_item['pid']] + $shop_item['qty'] : $shop_item['qty'];
|
||||
$object['ProduktNummer'] = $shop_item['number'];
|
||||
$object['ProduktName'] = $shop_item['name'];
|
||||
$object['Anzahl'] = $shop_item['qty'];
|
||||
$object['Summe'] = $total_value[$shop_item['pid']];
|
||||
$object['Kompensation'] = '';
|
||||
$object['ProduktNummer'] = $shop_item['number'];
|
||||
$object['ProduktName'] = $shop_item['name'];
|
||||
$object['Anzahl'] = $shop_item['qty'];
|
||||
$object['Summe'] = $total_value[$shop_item['pid']];
|
||||
$object['Kompensation'] = '';
|
||||
$columns[] = $object;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}else{
|
||||
if($ShoppingOrder->shopping_order_items){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
} else {
|
||||
if ($ShoppingOrder->shopping_order_items) {
|
||||
foreach ($ShoppingOrder->shopping_order_items as $shopping_order_item) {
|
||||
$total_value[$shopping_order_item->product_id] = isset($total_value[$shopping_order_item->product_id]) ? $total_value[$shopping_order_item->product_id] + $shopping_order_item->qty : $shopping_order_item->qty;
|
||||
$object['ProduktNummer'] = $shopping_order_item->product ? $shopping_order_item->product->number : "n/a";
|
||||
$object['ProduktName'] = $shopping_order_item->product ? $shopping_order_item->product->name : "n/a";
|
||||
$object['Anzahl'] = $shopping_order_item->qty;
|
||||
$object['Summe'] = $total_value[$shopping_order_item->product_id];
|
||||
$object['Kompensation'] = ($shopping_order_item->comp ? $shopping_order_item->comp : '');
|
||||
$object['ProduktNummer'] = $shopping_order_item->product ? $shopping_order_item->product->number : 'n/a';
|
||||
$object['ProduktName'] = $shopping_order_item->product ? $shopping_order_item->product->name : 'n/a';
|
||||
$object['Anzahl'] = $shopping_order_item->qty;
|
||||
$object['Summe'] = $total_value[$shopping_order_item->product_id];
|
||||
$object['Kompensation'] = ($shopping_order_item->comp ? $shopping_order_item->comp : '');
|
||||
|
||||
$columns[] = $object;
|
||||
}
|
||||
|
|
@ -167,74 +165,73 @@ class PaymentSalesController extends Controller
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
$filename = "mivita-absatzmengen-voll-".session('payment_sales_vol_filter_month').'_'.session('payment_sales_vol_filter_year')."-export";
|
||||
|
||||
$filename = 'mivita-absatzmengen-voll-'.session('payment_sales_vol_filter_month').'_'.session('payment_sales_vol_filter_year').'-export';
|
||||
|
||||
return Excel::download(new xExport($columns, $headers), $filename.'.xls');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function initKompaktList()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$UserInvoices = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', session('payment_sales_vol_filter_month'))
|
||||
->where('user_invoices.year', '=', session('payment_sales_vol_filter_year'))
|
||||
->get();
|
||||
->where('user_invoices.month', '=', session('payment_sales_vol_filter_month'))
|
||||
->where('user_invoices.year', '=', session('payment_sales_vol_filter_year'))
|
||||
->get();
|
||||
|
||||
$objects = [];
|
||||
|
||||
foreach($UserInvoices as $UserInvoice){
|
||||
if($UserInvoice->shopping_order){
|
||||
|
||||
foreach ($UserInvoices as $UserInvoice) {
|
||||
if ($UserInvoice->shopping_order) {
|
||||
$ShoppingOrder = $UserInvoice->shopping_order;
|
||||
|
||||
if($ShoppingOrder->payment_for === 5){ //homeparty
|
||||
if($ShoppingOrder->homeparty){
|
||||
foreach($ShoppingOrder->homeparty->homeparty_order_items as $homeparty_item){
|
||||
if(isset($objects[$homeparty_item->product_id])){
|
||||
|
||||
if ($ShoppingOrder->payment_for === 5) { // homeparty
|
||||
if ($ShoppingOrder->homeparty) {
|
||||
foreach ($ShoppingOrder->homeparty->homeparty_order_items as $homeparty_item) {
|
||||
if (isset($objects[$homeparty_item->product_id])) {
|
||||
$value = intval($objects[$homeparty_item->product_id]['value'] + $homeparty_item->qty);
|
||||
$objects[$homeparty_item->product_id]['value'] = $value;
|
||||
}else{
|
||||
} else {
|
||||
$objects[$homeparty_item->product_id] = [
|
||||
'name' => $homeparty_item->product ? $homeparty_item->product->name : "n/a ".$homeparty_item->product_id,
|
||||
'number' => $homeparty_item->product ? $homeparty_item->product->number : "n/a ".$homeparty_item->product_id,
|
||||
'value' => $homeparty_item->qty
|
||||
'name' => $homeparty_item->product ? $homeparty_item->product->name : 'n/a '.$homeparty_item->product_id,
|
||||
'number' => $homeparty_item->product ? $homeparty_item->product->number : 'n/a '.$homeparty_item->product_id,
|
||||
'value' => $homeparty_item->qty,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}elseif($ShoppingOrder->payment_for === 8){ //collective_invoice
|
||||
if($ShoppingOrder->shopping_collect_order){
|
||||
foreach($ShoppingOrder->shopping_collect_order->shop_items as $shop_item){
|
||||
} elseif ($ShoppingOrder->payment_for === 8) { // collective_invoice
|
||||
if ($ShoppingOrder->shopping_collect_order) {
|
||||
foreach ($ShoppingOrder->shopping_collect_order->shop_items as $shop_item) {
|
||||
|
||||
if(isset($objects[$shop_item['pid']])){
|
||||
if (isset($objects[$shop_item['pid']])) {
|
||||
$value = intval($objects[$shop_item['pid']]['value'] + $shop_item['qty']);
|
||||
$objects[$shop_item['pid']]['value'] = $value;
|
||||
}else{
|
||||
} else {
|
||||
$objects[$shop_item['pid']] = [
|
||||
'name' => $shop_item['name'],
|
||||
'number' => $shop_item['number'],
|
||||
'value' => $shop_item['qty']
|
||||
'value' => $shop_item['qty'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($ShoppingOrder->shopping_order_items){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
if(isset($objects[$shopping_order_item->product_id])){
|
||||
} else {
|
||||
if ($ShoppingOrder->shopping_order_items) {
|
||||
foreach ($ShoppingOrder->shopping_order_items as $shopping_order_item) {
|
||||
if (isset($objects[$shopping_order_item->product_id])) {
|
||||
$value = intval($objects[$shopping_order_item->product_id]['value'] + $shopping_order_item->qty);
|
||||
$objects[$shopping_order_item->product_id]['value'] = $value;
|
||||
}else{
|
||||
} else {
|
||||
$objects[$shopping_order_item->product_id] = [
|
||||
'name' => $shopping_order_item->product ? $shopping_order_item->product->name : "n/a ".$shopping_order_item->product_id,
|
||||
'number' => $shopping_order_item->product ? $shopping_order_item->product->number : "n/a ".$shopping_order_item->product_id,
|
||||
'value' => $shopping_order_item->qty
|
||||
'name' => $shopping_order_item->product ? $shopping_order_item->product->name : 'n/a '.$shopping_order_item->product_id,
|
||||
'number' => $shopping_order_item->product ? $shopping_order_item->product->number : 'n/a '.$shopping_order_item->product_id,
|
||||
'value' => $shopping_order_item->qty,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -243,12 +240,12 @@ class PaymentSalesController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
return $objects;
|
||||
return $objects;
|
||||
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
/*$collect = collect([
|
||||
['id' => 1, 'name' => 'John', 'number'=>92012, 'value'=>123],
|
||||
|
|
@ -257,29 +254,29 @@ class PaymentSalesController extends Controller
|
|||
]);*/
|
||||
$objects = $this->initKompaktList();
|
||||
$collection = collect();
|
||||
if($objects){
|
||||
foreach($objects as $key => $obj){
|
||||
if ($objects) {
|
||||
foreach ($objects as $key => $obj) {
|
||||
$collection->push([
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return \DataTables::of($collection)->toJson();
|
||||
}
|
||||
|
||||
/*
|
||||
//Auswertung nach ShoppingOrder
|
||||
|
||||
/*
|
||||
//Auswertung nach ShoppingOrder
|
||||
//nach Datum created_at wann die Bestellung erstellt wurde
|
||||
//Ist nicht das Datum der Rechnung, da hier teilweise die Sammelrechnungen oder Zahlungen erst in nächsten Monat erfolgen
|
||||
|
||||
|
||||
|
||||
public function exportFullList($paid = 1){
|
||||
|
||||
|
||||
|
||||
$date_start = Carbon::parse('01.'.session('payment_sales_vol_filter_month').'.'.session('payment_sales_vol_filter_year'))->format('Y-m-d H:i:s');
|
||||
$date_end = Carbon::parse('01.'.session('payment_sales_vol_filter_month').'.'.session('payment_sales_vol_filter_year'))->endOfMonth()->format('Y-m-d H:i:s');
|
||||
$ShoppingOrders = ShoppingOrder::where('paid', $paid)->where('mode', 'live')->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
|
|
@ -298,14 +295,14 @@ class PaymentSalesController extends Controller
|
|||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
$value = $shopping_order_item->qty;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
$object = [];
|
||||
if(in_array($ShoppingOrder->id, $hasSOID)){
|
||||
|
|
@ -329,7 +326,7 @@ class PaymentSalesController extends Controller
|
|||
|
||||
$hasSOID[] = $ShoppingOrder->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($paid){
|
||||
$filename = "mivita-absatzmengen-full-paid-".session('payment_sales_vol_filter_month').'_'.session('payment_sales_vol_filter_year')."-export";
|
||||
}else{
|
||||
|
|
@ -338,7 +335,7 @@ class PaymentSalesController extends Controller
|
|||
|
||||
return Excel::download(new xExport($columns, $headers), $filename.'.xls');
|
||||
|
||||
//CSV EXPORT function
|
||||
//CSV EXPORT function
|
||||
$headers = array(
|
||||
"Content-type" => "text/csv",
|
||||
"Content-Disposition" => "attachment; filename=$fileName",
|
||||
|
|
@ -357,15 +354,15 @@ class PaymentSalesController extends Controller
|
|||
|
||||
foreach ($columns as $row) {
|
||||
fputcsv($file, $row);
|
||||
|
||||
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
};
|
||||
|
||||
return response()->stream($callback, 200, $headers);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
|
@ -387,7 +384,7 @@ class PaymentSalesController extends Controller
|
|||
$counter = 0;
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->id === 122){
|
||||
//dump($shopping_order_item->qty);
|
||||
|
|
@ -397,8 +394,8 @@ class PaymentSalesController extends Controller
|
|||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
|
|
@ -438,11 +435,11 @@ class PaymentSalesController extends Controller
|
|||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -460,8 +457,8 @@ class PaymentSalesController extends Controller
|
|||
}
|
||||
return $collection;
|
||||
}
|
||||
return $objects;
|
||||
return $objects;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use App\Models\ShoppingUser;
|
|||
use App\Models\ShoppingUserMemberLog;
|
||||
use App\Models\UserCleanUpLog;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AdminUserCleanupController extends Controller
|
||||
|
|
@ -86,7 +88,7 @@ class AdminUserCleanupController extends Controller
|
|||
})
|
||||
->addColumn('deleted_at', function (User $user) {
|
||||
if ($user->pre_deleted_at) {
|
||||
return \Carbon\Carbon::parse($user->pre_deleted_at)->format('d.m.Y H:i');
|
||||
return Carbon::parse($user->pre_deleted_at)->format('d.m.Y H:i');
|
||||
}
|
||||
|
||||
return '-';
|
||||
|
|
@ -215,7 +217,7 @@ class AdminUserCleanupController extends Controller
|
|||
return $html;
|
||||
})
|
||||
->addColumn('created_at', function (UserCleanUpLog $log) {
|
||||
return \Carbon\Carbon::parse($log->created_at)->format('d.m.Y H:i');
|
||||
return Carbon::parse($log->created_at)->format('d.m.Y H:i');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->rawColumns(['inactive_sponsor', 'child_user', 'new_sponsor'])
|
||||
|
|
@ -290,7 +292,7 @@ class AdminUserCleanupController extends Controller
|
|||
return $html;
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingUserMemberLog $log) {
|
||||
return \Carbon\Carbon::parse($log->created_at)->format('d.m.Y H:i');
|
||||
return Carbon::parse($log->created_at)->format('d.m.Y H:i');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->rawColumns(['pre_member', 'shopping_user', 'new_member'])
|
||||
|
|
@ -300,7 +302,7 @@ class AdminUserCleanupController extends Controller
|
|||
/**
|
||||
* User über Artisan Command wiederherstellen
|
||||
*/
|
||||
public function restore(\Illuminate\Http\Request $request)
|
||||
public function restore(Request $request)
|
||||
{
|
||||
$userId = $request->input('user_id');
|
||||
|
||||
|
|
@ -348,7 +350,7 @@ class AdminUserCleanupController extends Controller
|
|||
/**
|
||||
* Suche nach aktiven Sponsoren für Select2
|
||||
*/
|
||||
public function searchSponsors(\Illuminate\Http\Request $request)
|
||||
public function searchSponsors(Request $request)
|
||||
{
|
||||
$search = $request->input('q');
|
||||
$userId = $request->input('exclude_user_id'); // User selbst ausschließen
|
||||
|
|
@ -403,7 +405,7 @@ class AdminUserCleanupController extends Controller
|
|||
/**
|
||||
* Sponsor manuell neu zuweisen
|
||||
*/
|
||||
public function reassignSponsor(\Illuminate\Http\Request $request)
|
||||
public function reassignSponsor(Request $request)
|
||||
{
|
||||
$userId = $request->input('user_id');
|
||||
$newSponsorId = $request->input('new_sponsor_id');
|
||||
|
|
@ -594,7 +596,7 @@ class AdminUserCleanupController extends Controller
|
|||
'name' => trim($customer->billing_firstname.' '.$customer->billing_lastname),
|
||||
'email' => $customer->billing_email,
|
||||
'city' => $customer->billing_city,
|
||||
'created_at' => \Carbon\Carbon::parse($customer->created_at)->format('d.m.Y'),
|
||||
'created_at' => Carbon::parse($customer->created_at)->format('d.m.Y'),
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -626,7 +628,7 @@ class AdminUserCleanupController extends Controller
|
|||
'name' => $log->new_sponsor->account ? trim($log->new_sponsor->account->first_name.' '.$log->new_sponsor->account->last_name) : 'N/A',
|
||||
'email' => $log->new_sponsor->email,
|
||||
] : null,
|
||||
'created_at' => \Carbon\Carbon::parse($log->created_at)->format('d.m.Y H:i'),
|
||||
'created_at' => Carbon::parse($log->created_at)->format('d.m.Y H:i'),
|
||||
];
|
||||
|
||||
// Prüfe aktuellen Sponsor des child_user (falls geändert)
|
||||
|
|
@ -658,7 +660,7 @@ class AdminUserCleanupController extends Controller
|
|||
'name' => $log->new_member->account ? trim($log->new_member->account->first_name.' '.$log->new_member->account->last_name) : 'N/A',
|
||||
'email' => $log->new_member->email,
|
||||
] : null,
|
||||
'created_at' => \Carbon\Carbon::parse($log->created_at)->format('d.m.Y H:i'),
|
||||
'created_at' => Carbon::parse($log->created_at)->format('d.m.Y H:i'),
|
||||
];
|
||||
|
||||
// Prüfe aktuellen Berater des Kunden (falls geändert)
|
||||
|
|
@ -685,7 +687,7 @@ class AdminUserCleanupController extends Controller
|
|||
'm_account' => $user->account ? $user->account->m_account : 'N/A',
|
||||
'active' => $user->active,
|
||||
'deleted' => $user->pre_deleted_at ? true : false,
|
||||
'deleted_at' => $user->pre_deleted_at ? \Carbon\Carbon::parse($user->pre_deleted_at)->format('d.m.Y H:i') : null,
|
||||
'deleted_at' => $user->pre_deleted_at ? Carbon::parse($user->pre_deleted_at)->format('d.m.Y H:i') : null,
|
||||
],
|
||||
'sponsor' => $sponsor ? [
|
||||
'id' => $sponsor->id,
|
||||
|
|
|
|||
|
|
@ -2,81 +2,77 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
//protected static API_MAIL = 'api.thomas.krummel@gmail.com';
|
||||
//protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
|
||||
//protected static API_URL = 'https://mein.sterntours.test/api/';
|
||||
|
||||
// protected static API_MAIL = 'api.thomas.krummel@gmail.com';
|
||||
// protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
|
||||
// protected static API_URL = 'https://mein.sterntours.test/api/';
|
||||
|
||||
public $successStatus = 200;
|
||||
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|string|email',
|
||||
'password' => 'required|string',
|
||||
'remember_me' => 'boolean'
|
||||
'remember_me' => 'boolean',
|
||||
]);
|
||||
$credentials = request(['email', 'password']);
|
||||
|
||||
if (!Auth::attempt($credentials))
|
||||
if (! Auth::attempt($credentials)) {
|
||||
return response()->json([
|
||||
'message' => 'Unauthorized'
|
||||
'message' => 'Unauthorized',
|
||||
], 401);
|
||||
}
|
||||
$user = $request->user();
|
||||
|
||||
$tokenResult = $user->createToken('Personal Access Token');
|
||||
$token = $tokenResult->token;
|
||||
|
||||
if ($request->remember_me){
|
||||
if ($request->remember_me) {
|
||||
$token->expires_at = Carbon::now()->addWeeks(1);
|
||||
}else{
|
||||
} else {
|
||||
$token->expires_at = Carbon::now()->addDays(1);
|
||||
}
|
||||
|
||||
\DB::table('oauth_access_tokens')
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
|
||||
\DB::table('oauth_refresh_tokens')
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
|
||||
$token->save();
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse(
|
||||
$tokenResult->token->expires_at
|
||||
)->toDateTimeString()
|
||||
)->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function checked(Request $request)
|
||||
{
|
||||
return response()->json([
|
||||
'message' => 'login'
|
||||
'message' => 'login',
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->user()->token()->revoke();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Successfully logged out'
|
||||
'message' => 'Successfully logged out',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -85,11 +81,11 @@ class AuthController extends Controller
|
|||
*
|
||||
* @return [json] user object
|
||||
*/
|
||||
/* public function user(Request $request)
|
||||
{
|
||||
return response()->json($request->user());
|
||||
}
|
||||
*/
|
||||
/* public function user(Request $request)
|
||||
{
|
||||
return response()->json($request->user());
|
||||
}
|
||||
*/
|
||||
|
||||
/*public function signup(Request $request)
|
||||
{
|
||||
|
|
@ -109,4 +105,4 @@ class AuthController extends Controller
|
|||
], 201);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ class RegisterController extends Controller
|
|||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
//register off! - to login
|
||||
// register off! - to login
|
||||
return redirect('login');
|
||||
|
||||
}
|
||||
|
|
@ -51,7 +51,6 @@ class RegisterController extends Controller
|
|||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
|
|
@ -66,8 +65,7 @@ class RegisterController extends Controller
|
|||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
* @return User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Acme\Dhl\Models\DhlShipment;
|
||||
use App\Jobs\CancelShipmentJob;
|
||||
use Acme\Dhl\Services\ReturnsService;
|
||||
// Old DHL model replaced with new package model
|
||||
use Acme\Dhl\Support\DhlClient;
|
||||
use App\Jobs\CancelShipmentJob;
|
||||
use App\Jobs\CreateReturnLabelJob;
|
||||
use App\Mail\MailDhlTracking;
|
||||
use App\Models\Country;
|
||||
|
|
@ -16,14 +18,15 @@ use App\Services\DhlShipmentService;
|
|||
use App\Services\DhlTrackingService;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
// Import new DHL package and SettingController
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
// Import new DHL package and SettingController
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use ZipArchive;
|
||||
|
||||
|
|
@ -47,16 +50,16 @@ class DhlShipmentController extends Controller
|
|||
/**
|
||||
* Test the DHL API login credentials and return a JSON response.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function testLogin()
|
||||
{
|
||||
try {
|
||||
// Get DHL configuration with admin settings
|
||||
$settingController = new \App\Http\Controllers\SettingController;
|
||||
$settingController = new SettingController;
|
||||
$dhlConfig = $settingController->getDhlConfig();
|
||||
// Create DhlClient with merged configuration
|
||||
$dhlClient = new \Acme\Dhl\Support\DhlClient(
|
||||
$dhlClient = new DhlClient(
|
||||
$dhlConfig['base_url'],
|
||||
$dhlConfig['api_key'],
|
||||
$dhlConfig['username'],
|
||||
|
|
@ -249,7 +252,7 @@ class DhlShipmentController extends Controller
|
|||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(ShoppingOrder $order): View|\Illuminate\Http\RedirectResponse
|
||||
public function create(ShoppingOrder $order): View|RedirectResponse
|
||||
{
|
||||
// Check if order already has a shipment
|
||||
$existingShipment = DhlShipment::where('shopping_order_id', $order->id)
|
||||
|
|
@ -627,7 +630,7 @@ class DhlShipmentController extends Controller
|
|||
$dhlConfig = $settingController->getDhlConfig();
|
||||
|
||||
// Initialize DHL client
|
||||
$dhlClient = new \Acme\Dhl\Support\DhlClient(
|
||||
$dhlClient = new DhlClient(
|
||||
$dhlConfig['base_url'],
|
||||
$dhlConfig['api_key'],
|
||||
$dhlConfig['username'],
|
||||
|
|
@ -635,7 +638,7 @@ class DhlShipmentController extends Controller
|
|||
);
|
||||
|
||||
// Use ReturnsService instead of ShippingService
|
||||
$returnsService = new \Acme\Dhl\Services\ReturnsService($dhlClient);
|
||||
$returnsService = new ReturnsService($dhlClient);
|
||||
|
||||
// Prepare return label data
|
||||
$order = $shipment->shoppingOrder;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,12 @@ use App\Services\SysLog;
|
|||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\View\View;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
|
@ -31,7 +36,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
|
@ -69,7 +74,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
|
|
@ -98,7 +103,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function editPost($id)
|
||||
{
|
||||
|
|
@ -142,7 +147,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
|
@ -263,7 +268,7 @@ class LeadController extends Controller
|
|||
$to_user = isset($t_user->email) ? $t_user->email : 'empty';
|
||||
|
||||
SysLog::action('save-m_sponsor', 'lead_edit_sponsor', 3)
|
||||
->setUserId(\Auth::user()->id)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user new sponsor from: '.$from_user.' | to: '.$to_user)
|
||||
->save();
|
||||
|
|
@ -364,7 +369,7 @@ class LeadController extends Controller
|
|||
'confirmation_code' => $confirmation_code,
|
||||
];
|
||||
try {
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailCustomMessage($user, $data, \Auth::user(), true));
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailCustomMessage($user, $data, Auth::user(), true));
|
||||
} catch (\Exception $e) {
|
||||
dump($e->getMessage());
|
||||
dd('error');
|
||||
|
|
@ -541,7 +546,7 @@ class LeadController extends Controller
|
|||
}
|
||||
|
||||
// Datum ermitteln
|
||||
$contractDate = $useCurrentDate ? now() : ($user->active_date ? \Carbon\Carbon::parse($user->active_date) : now());
|
||||
$contractDate = $useCurrentDate ? now() : ($user->active_date ? Carbon::parse($user->active_date) : now());
|
||||
|
||||
// Alten Vertrag löschen
|
||||
File::where('user_id', $user->id)
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@ use App\Repositories\CustomerRepository;
|
|||
use App\Services\AboHelper;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\Shop;
|
||||
use App\Services\ShoppingUserService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
protected $customerRepository;
|
||||
|
|
@ -29,22 +28,22 @@ class CustomerController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
if(Request::get('reset') === 'filter'){
|
||||
// set_user_attr('filter_member_id', null);
|
||||
// set_user_attr('filter_customer_member', null);
|
||||
if (Request::get('reset') === 'filter') {
|
||||
// set_user_attr('filter_member_id', null);
|
||||
// set_user_attr('filter_customer_member', null);
|
||||
return redirect(route('admin_customers'));
|
||||
}
|
||||
$data = [
|
||||
|
||||
];
|
||||
|
||||
return view('user.customer.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id != \Auth::user()->id){
|
||||
if ($shopping_user->member_id != \Auth::user()->id) {
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -52,13 +51,14 @@ class CustomerController extends Controller
|
|||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
];
|
||||
|
||||
return view('user.customer.detail', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id != \Auth::user()->id){
|
||||
if ($shopping_user->member_id != \Auth::user()->id) {
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -67,33 +67,34 @@ class CustomerController extends Controller
|
|||
'isView' => 'customer',
|
||||
|
||||
];
|
||||
|
||||
return view('user.customer.edit', $data);
|
||||
}
|
||||
|
||||
public function add($id, $step=0)
|
||||
public function add($id, $step = 0)
|
||||
{
|
||||
if($id === "new"){
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->id = "new";
|
||||
}else{
|
||||
if ($id === 'new') {
|
||||
$shopping_user = new ShoppingUser;
|
||||
$shopping_user->id = 'new';
|
||||
} else {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id != \Auth::user()->id){
|
||||
if ($shopping_user->member_id != \Auth::user()->id) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
$billing_email = null;
|
||||
if(!session('errors')){
|
||||
if(old('email') || old('billing_email')){
|
||||
if (! session('errors')) {
|
||||
if (old('email') || old('billing_email')) {
|
||||
$step = 1;
|
||||
$shopping_user->same_as_billing = true;
|
||||
$billing_email = old('email');
|
||||
}
|
||||
if(old('switcher-without-email') === 'true'){
|
||||
if (old('switcher-without-email') === 'true') {
|
||||
$step = 1;
|
||||
$shopping_user->same_as_billing = true;
|
||||
$shopping_user->faker_mail = true;
|
||||
$billing_email = time()."-faker@mivita.care";
|
||||
$billing_email = time().'-faker@mivita.care';
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -104,42 +105,47 @@ class CustomerController extends Controller
|
|||
'billing_email' => $billing_email,
|
||||
|
||||
];
|
||||
|
||||
return view('user.customer.add', $data);
|
||||
}
|
||||
|
||||
private function checkShoppingUsersEmail($email = 'email', $action = 'return', $id=null){
|
||||
private function checkShoppingUsersEmail($email = 'email', $action = 'return', $id = null)
|
||||
{
|
||||
|
||||
$rules = array(
|
||||
$rules = [
|
||||
$email => 'required|string|email|max:255|unique:shopping_users,billing_email',
|
||||
);
|
||||
];
|
||||
$messages = [
|
||||
'unique' => __('validation.custom.unique_email_client'),
|
||||
'unique' => __('validation.custom.unique_email_client'),
|
||||
];
|
||||
$validator = Validator::make(Request::all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
\Session()->flash('alert-error', __('validation.custom.unique_email_client'));
|
||||
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$rules = array(
|
||||
$rules = [
|
||||
$email => 'required|string|email|max:255|unique:users,email',
|
||||
);
|
||||
];
|
||||
$messages = [
|
||||
'unique' => __('validation.custom.unique_email_member'),
|
||||
'unique' => __('validation.custom.unique_email_member'),
|
||||
];
|
||||
$validator = Validator::make(Request::all(), $rules, $messages);
|
||||
if ($validator->fails()) {
|
||||
\Session()->flash('alert-error', __('validation.custom.unique_email_member'));
|
||||
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
if($action === 'return'){
|
||||
if ($action === 'return') {
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
|
||||
if($action === 'save'){
|
||||
if ($action === 'save') {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
$shopping_user->faker_mail = false;
|
||||
$shopping_user->billing_email = Request::get($email);
|
||||
$shopping_user->save();
|
||||
|
||||
return redirect(route('user_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
}
|
||||
|
|
@ -148,42 +154,42 @@ class CustomerController extends Controller
|
|||
{
|
||||
$data = Request::all();
|
||||
|
||||
if($id === 'new' && $data['action'] === 'add_customer_with_email'){
|
||||
if ($id === 'new' && $data['action'] === 'add_customer_with_email') {
|
||||
return $this->checkShoppingUsersEmail('email', 'return');
|
||||
}
|
||||
if($id === 'new' && $data['action'] === 'add_customer_without_email'){
|
||||
if ($id === 'new' && $data['action'] === 'add_customer_without_email') {
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
|
||||
if($id === 'new' && $data['action'] === ''){
|
||||
if ($id === 'new' && $data['action'] === '') {
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
|
||||
if($id !== 'new' && $data['action'] === 'add-mail-shopping-user-store'){
|
||||
if ($id !== 'new' && $data['action'] === 'add-mail-shopping-user-store') {
|
||||
return $this->checkShoppingUsersEmail('new_email_address', 'save', $id);
|
||||
}
|
||||
|
||||
if($data['action'] === 'shopping-user-store-new' || $data['action']==='shopping-user-store'){
|
||||
$rules = array(
|
||||
if ($data['action'] === 'shopping-user-store-new' || $data['action'] === 'shopping-user-store') {
|
||||
$rules = [
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname'=>'required',
|
||||
'billing_lastname'=>'required',
|
||||
'billing_email'=>'required|email',
|
||||
'billing_address'=>'required',
|
||||
'billing_zipcode'=>'required',
|
||||
'billing_firstname' => 'required',
|
||||
'billing_lastname' => 'required',
|
||||
'billing_email' => 'required|email',
|
||||
'billing_address' => 'required',
|
||||
'billing_zipcode' => 'required',
|
||||
'billing_city' => 'required',
|
||||
'billing_country_id' => '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',
|
||||
'shipping_country_id' => 'required'
|
||||
'shipping_country_id' => 'required',
|
||||
]);
|
||||
}
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
|
@ -196,15 +202,15 @@ class CustomerController extends Controller
|
|||
$data['faker_mail'] = isset($data['faker_mail']) ? true : false;
|
||||
$data['has_buyed'] = isset($data['has_buyed']) ? true : false;
|
||||
$data['subscribed'] = isset($data['subscribed']) ? true : false;
|
||||
//subscribed can only true when has_buyed ist active
|
||||
// subscribed can only true when has_buyed ist active
|
||||
$data['subscribed'] = $data['has_buyed'] ? $data['subscribed'] : false;
|
||||
|
||||
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
|
||||
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
|
||||
|
||||
if($id > 0 && $data['action'] === 'shopping-user-store'){
|
||||
if ($id > 0 && $data['action'] === 'shopping-user-store') {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id != \Auth::user()->id){
|
||||
if ($shopping_user->member_id != \Auth::user()->id) {
|
||||
abort(404);
|
||||
}
|
||||
CustomerPriority::checkChangeOne($shopping_user, $data, true);
|
||||
|
|
@ -213,74 +219,76 @@ class CustomerController extends Controller
|
|||
|
||||
}
|
||||
|
||||
if($id === 'new' && $data['action'] === 'shopping-user-store-new') {
|
||||
if ($id === 'new' && $data['action'] === 'shopping-user-store-new') {
|
||||
$shopping_user = ShoppingUser::create($data);
|
||||
$shopping_user->member_id = \Auth::user()->id;
|
||||
$shopping_user->save();
|
||||
CustomerPriority::checkNewOne($shopping_user, true);
|
||||
}
|
||||
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||
Shop::newUserOrder($shopping_user->number);
|
||||
|
||||
if($shopping_user->is_like){
|
||||
if ($shopping_user->is_like) {
|
||||
\Session()->flash('custom-error', __('validation.custom.match_found'));
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
|
||||
return redirect(route('user_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
|
||||
private function checkShoppingUsersByEmail()
|
||||
{
|
||||
|
||||
private function checkShoppingUsersByEmail(){
|
||||
|
||||
//ist an dieser stelle nicht machbar, zu viele Datenbankzugriffe
|
||||
//siehe App\Console\Commands\SyncShoppingUserData
|
||||
/* $user = User::find(\Auth::user()->id);
|
||||
ShoppingUserService::setFakerMail($user);
|
||||
ShoppingUserService::syncNumbersByEmail($user);
|
||||
ShoppingUserService::syncOrdersByEmail($user); */
|
||||
// ist an dieser stelle nicht machbar, zu viele Datenbankzugriffe
|
||||
// siehe App\Console\Commands\SyncShoppingUserData
|
||||
/* $user = User::find(\Auth::user()->id);
|
||||
ShoppingUserService::setFakerMail($user);
|
||||
ShoppingUserService::syncNumbersByEmail($user);
|
||||
ShoppingUserService::syncOrdersByEmail($user); */
|
||||
|
||||
}
|
||||
|
||||
public function getCustomers()
|
||||
{
|
||||
//$this->checkShoppingUsersByEmail();
|
||||
|
||||
// $this->checkShoppingUsersByEmail();
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
//\Log::info('Current user ID: ' . $user->id);
|
||||
// \Log::info('Current user ID: ' . $user->id);
|
||||
|
||||
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'faker_mail', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
|
||||
->with('billing_country')
|
||||
->whereIn('id', function($query) {
|
||||
$query->select(DB::raw('MAX(id)'))
|
||||
->from('shopping_users')
|
||||
->groupBy('billing_email');
|
||||
})->where('shopping_users.member_id', '=', $user->id)->where('shopping_users.auth_user_id', '=', NULL);
|
||||
->with('billing_country')
|
||||
->whereIn('id', function ($query) {
|
||||
$query->select(DB::raw('MAX(id)'))
|
||||
->from('shopping_users')
|
||||
->groupBy('billing_email');
|
||||
})->where('shopping_users.member_id', '=', $user->id)->where('shopping_users.auth_user_id', '=', null);
|
||||
|
||||
if(Request::get('isfor') === 'ot-member'){ //Bestellung für Kunden
|
||||
if (Request::get('isfor') === 'ot-member') { // Bestellung für Kunden
|
||||
}
|
||||
if(Request::get('isfor') === 'ot-customer' || Request::get('isfor') === 'abo-ot-customer'){ //Bestellung für Kunden Zahlungslink
|
||||
$query->where(function($q) {
|
||||
if (Request::get('isfor') === 'ot-customer' || Request::get('isfor') === 'abo-ot-customer') { // Bestellung für Kunden Zahlungslink
|
||||
$query->where(function ($q) {
|
||||
$q->where('shopping_users.faker_mail', '!=', 1)
|
||||
->orWhereNull('shopping_users.faker_mail');
|
||||
->orWhereNull('shopping_users.faker_mail');
|
||||
});
|
||||
}
|
||||
//\Log::info('SQL Query: ' . $query->toSql());
|
||||
//\Log::info('Query Bindings: ' . print_r($query->getBindings(), true));
|
||||
// \Log::info('SQL Query: ' . $query->toSql());
|
||||
// \Log::info('Query Bindings: ' . print_r($query->getBindings(), true));
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
|
||||
$ot = Request::get('isfor') ? Request::get('isfor') : 'ot-member';
|
||||
if(Request::get('isfor') === 'abo-ot-customer' && AboHelper::memberHasAbo($ShoppingUser)){
|
||||
if (Request::get('isfor') === 'abo-ot-customer' && AboHelper::memberHasAbo($ShoppingUser)) {
|
||||
return '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> '.__('abo.abo_assigned').'</span>';
|
||||
}
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> '.__('customer.under_review').'</span>' : '<a href="' . route('user_order_my_delivery', [$ot, $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> '.__('customer.select').'</a>';
|
||||
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> '.__('customer.under_review').'</span>' : '<a href="'.route('user_order_my_delivery', [$ot, $ShoppingUser->id]).'" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> '.__('customer.select').'</a>';
|
||||
})
|
||||
->addColumn('billing_email', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->faker_mail ? "-" : $ShoppingUser->billing_email;
|
||||
return $ShoppingUser->faker_mail ? '-' : $ShoppingUser->billing_email;
|
||||
})
|
||||
->addColumn('id', function (ShoppingUser $ShoppingUser) {
|
||||
return '<a href="' . route('user_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
return '<a href="'.route('user_customer_detail', [$ShoppingUser->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('billing_salutation', function (ShoppingUser $ShoppingUser) {
|
||||
return HTMLHelper::getSalutationLang($ShoppingUser->billing_salutation);
|
||||
|
|
@ -301,10 +309,10 @@ class CustomerController extends Controller
|
|||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> '.__('customer.under_review').'</span> ' : '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> '.__('customer.assigned').'</span>';
|
||||
})
|
||||
->addColumn('extras', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->wp_order_number.($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
return $ShoppingUser->wp_order_number.($ShoppingUser->mode === 'dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
})
|
||||
->filterColumn('billing_email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('billing_email', function ($query, $keyword) {
|
||||
if ($keyword != '') {
|
||||
$query->where('billing_email', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
|
|
@ -319,4 +327,4 @@ class CustomerController extends Controller
|
|||
->rawColumns(['send_to', 'id', 'subscribed', 'extras', 'status'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,24 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailActivateUser;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Request;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Connection;
|
||||
use App\Mail\MailActivateUser;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
class UserUpdateEmailController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $db;
|
||||
|
||||
protected $table = 'user_update_emails';
|
||||
|
||||
protected $resendAfter = 60; //1min
|
||||
|
||||
protected $resendAfter = 60; // 1min
|
||||
|
||||
public function __construct(Connection $db)
|
||||
{
|
||||
|
|
@ -38,15 +35,16 @@ class UserUpdateEmailController extends Controller
|
|||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . Auth::user()->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
$rules = [
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:'.Auth::user()->id,
|
||||
// 'email-confirm' => 'required|same:email',
|
||||
];
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
if ($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
|
@ -57,30 +55,31 @@ class UserUpdateEmailController extends Controller
|
|||
|
||||
return view('user.update_email')->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$this->sendActivationMail($user, Request::all());
|
||||
\Session()->flash('alert-success', __('We sent you an activation code. Check your email!'));
|
||||
|
||||
return redirect(route('user_update_email'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function adminChangeMail($user_id)
|
||||
public function adminChangeMail($user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
if (! Auth::user()->isAdmin()) {
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'user' => User::findOrFail($user_id),
|
||||
];
|
||||
|
||||
return view('admin.change_email', $data);
|
||||
|
||||
}
|
||||
public function adminUpdateMail(Request $request, $user_id)
|
||||
|
||||
public function adminUpdateMail(Request $request, $user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
if (! Auth::user()->isAdmin()) {
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($user_id);
|
||||
|
|
@ -88,16 +87,16 @@ class UserUpdateEmailController extends Controller
|
|||
'user' => $user,
|
||||
];
|
||||
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . $user->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
$rules = [
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:'.$user->id,
|
||||
// 'email-confirm' => 'required|same:email',
|
||||
];
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
if ($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
});
|
||||
|
|
@ -108,48 +107,45 @@ class UserUpdateEmailController extends Controller
|
|||
|
||||
return view('admin.change_email', $data)->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$this->sendActivationMail($user, Request::all());
|
||||
\Session()->flash('alert-success', __('An activation code was sent to the account by e-mail!'));
|
||||
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function activateMail($token)
|
||||
{
|
||||
|
||||
if ($updateEmail = $this->getUpdateEmailByToken($token)) {
|
||||
$user = User::findOrFail($updateEmail->user_id);
|
||||
if($user->id == $updateEmail->user_id){
|
||||
if ($user->id == $updateEmail->user_id) {
|
||||
$user->fill([
|
||||
'email' => $updateEmail->email
|
||||
'email' => $updateEmail->email,
|
||||
])->save();
|
||||
$this->deleteUpdateEmail($token);
|
||||
//Login!
|
||||
// Login!
|
||||
Auth::login($user);
|
||||
\Session()->flash('alert-success', __('Your e-mail has been changed.'));
|
||||
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return redirect('/home');
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
public function sendActivationMail($user, array $data)
|
||||
{
|
||||
$token = $this->createActivation($user, $data);
|
||||
Mail::to($data['email'])->locale($user->getLocale())->send(new MailActivateUser($token, $user));
|
||||
}
|
||||
|
||||
|
||||
protected function getToken()
|
||||
{
|
||||
return hash_hmac('sha256', Str::random(40), config('app.key'));
|
||||
|
|
@ -160,9 +156,10 @@ class UserUpdateEmailController extends Controller
|
|||
|
||||
$updateEmail = $this->getUpdateEmail($user);
|
||||
|
||||
if (!$updateEmail) {
|
||||
if (! $updateEmail) {
|
||||
return $this->createToken($user, $data);
|
||||
}
|
||||
|
||||
return $this->regenerateToken($user, $data);
|
||||
|
||||
}
|
||||
|
|
@ -174,8 +171,9 @@ class UserUpdateEmailController extends Controller
|
|||
$this->db->table($this->table)->where('user_id', $user->id)->update([
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
'created_at' => new Carbon,
|
||||
]);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +184,9 @@ class UserUpdateEmailController extends Controller
|
|||
'user_id' => $user->id,
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
'created_at' => new Carbon,
|
||||
]);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +195,6 @@ class UserUpdateEmailController extends Controller
|
|||
return $this->db->table($this->table)->where('user_id', $user->id)->first();
|
||||
}
|
||||
|
||||
|
||||
public function getUpdateEmailByToken($token)
|
||||
{
|
||||
return $this->db->table($this->table)->where('token', $token)->first();
|
||||
|
|
@ -206,4 +204,4 @@ class UserUpdateEmailController extends Controller
|
|||
{
|
||||
$this->db->table($this->table)->where('token', $token)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,36 +2,31 @@
|
|||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Mail\MailContact;
|
||||
use App\Models\UserLevel;
|
||||
use App\Services\UserService;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Models\UserLevel;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
private $GOOGLE_ReCAPTCHA_KEY = '6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU';
|
||||
|
||||
private $GOOGLE_ReCAPTCHA_KEY = "6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU";
|
||||
private $GOOGLE_ReCAPTCHA_SECRET = "6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J";
|
||||
private $GOOGLE_ReCAPTCHA_SECRET = '6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J';
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
|
@ -47,7 +42,7 @@ class RegisterController extends Controller
|
|||
'session_id' => \Session::getId(),
|
||||
'session_domain' => config('session.domain'),
|
||||
'request_host' => request()->getHost(),
|
||||
'all_session_keys' => array_keys(\Session::all())
|
||||
'all_session_keys' => array_keys(\Session::all()),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -56,17 +51,18 @@ class RegisterController extends Controller
|
|||
'user_shop' => Util::getUserShop(),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
|
||||
return view('web.templates.registrierung', $data);
|
||||
}
|
||||
|
||||
public function member($member_id = false)
|
||||
{
|
||||
if (!$member_id) {
|
||||
if (! $member_id) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$user_id = (int) str_replace('m', '', $member_id) - config('mivita.add_number_id');
|
||||
$user = User::find($user_id);
|
||||
if (!$user || !$user->isActive() || !$user->isActiveAccount()) {
|
||||
if (! $user || ! $user->isActive() || ! $user->isActiveAccount()) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$data = [
|
||||
|
|
@ -75,13 +71,14 @@ class RegisterController extends Controller
|
|||
'from_member_id' => $member_id,
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
|
||||
return view('web.templates.registrierung', $data);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
|
||||
$rules = array(
|
||||
$rules = [
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
|
|
@ -91,7 +88,7 @@ class RegisterController extends Controller
|
|||
'password_confirmation' => 'required|string|min:6',
|
||||
'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);
|
||||
|
|
@ -114,7 +111,7 @@ class RegisterController extends Controller
|
|||
if (isset($data['from_member_id'])) {
|
||||
$m_sponsor_id = (int) str_replace('m', '', $data['from_member_id']) - config('mivita.add_number_id');
|
||||
}
|
||||
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
||||
$user->lang = ! empty(\App::getLocale()) ? \App::getLocale() : 'de';
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$user->confirmation_code_remider = 0;
|
||||
|
|
@ -133,6 +130,7 @@ class RegisterController extends Controller
|
|||
$user->account->save();
|
||||
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, User::find($user->id)));
|
||||
|
||||
return redirect('/registrierung/finish');
|
||||
}
|
||||
|
||||
|
|
@ -142,26 +140,27 @@ class RegisterController extends Controller
|
|||
'user_shop' => Util::getUserShop(),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
|
||||
return view('web.templates.registrierung_finish', $data);
|
||||
}
|
||||
|
||||
private function reCaptcha_validate($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
|
||||
$client = new Client();
|
||||
$client = new Client;
|
||||
|
||||
$response = $client->post(
|
||||
'https://www.google.com/recaptcha/api/siteverify',
|
||||
[
|
||||
'form_params' =>
|
||||
[
|
||||
'form_params' => [
|
||||
'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
|
||||
'response' => $value
|
||||
]
|
||||
'response' => $value,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$body = json_decode((string)$response->getBody());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
|
||||
return $body->success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue