Next Member Shopping

This commit is contained in:
Kevin Adametz 2020-08-21 18:20:40 +02:00
parent fb27009339
commit 16fe2fa363
23 changed files with 619 additions and 334 deletions

View file

@ -8,6 +8,7 @@ use App\Mail\MailCheckout;
use App\Models\PaymentTransaction;
use App\Models\ShoppingOrder;
use App\Models\ShoppingPayment;
use App\Services\Payment;
use App\Services\Shop;
use App\Services\Util;
use App\User;
@ -137,76 +138,10 @@ class PayoneController extends Controller
}
if($data['txaction'] === 'paid'){
$shopping_order->setUserHistoryValue(['status' => 8]);
Shop::userOrders();
$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){
if($shopping_order_item->product){
if($shopping_order_item->product->action){
$user = User::findOrFail($shopping_order->auth_user_id);
$user->save();
$send_link = true;
//new date
$date = \Carbon::now()->modify('1 year');
if($user->payment_account && $user->daysActiveAccount()>0){
$date = \Carbon::parse($user->payment_account)->modify('1 year');
}
foreach ($shopping_order_item->product->action as $do){
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
$user->payment_order_id = $shopping_order_item->product->id; //34
$user->payment_account = $date;
$user->wizard = 100;
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
$user->payment_order_id = $shopping_order_item->product->id; //35
$user->payment_shop = $date;
$user->wizard = 100;
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade'){
if($shopping_order_item->product->upgrade_to_id){
$user->payment_order_id = $shopping_order_item->product->upgrade_to_id;
}
$user->payment_shop = $user->payment_account; //same Date, is upgrade
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){
if($shopping_order_item->product->upgrade_to_id){
$user->m_level = $shopping_order_item->product->upgrade_to_id;
}
}
$user->save();
}
}
}
}
}
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
}
$bcc = [];
$billing_email = $shopping_order->shopping_user->billing_email;
if(!$billing_email){
if($data['mode'] === 'test'){
$billing_email = config('app.checkout_test_mail');
}else{
$billing_email = config('app.checkout_mail');
}
}
if($data['mode'] === 'test'){
$bcc[] = config('app.checkout_test_mail');
}else{
$bcc[] = config('app.checkout_mail');
}
if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){
$bcc[] = $shopping_order->shopping_user->member->email;
}
Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link, $data['mode']));
$data['send_link'] = $send_link;
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
print("TSOK");
exit;
}

View file

@ -79,8 +79,6 @@ class DataTableController extends Controller
}
return $link.'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$user->getPaymentMethodsShort().'</span></a>';
})
->addColumn('action_delete', function (User $user) {
return '<span class="no-line-break"><a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>

View file

@ -97,6 +97,10 @@ class LeadController extends Controller
}
}
$next_account_id = UserAccount::max('m_account') +1;
if($user->account->m_account === null){
$user->account->m_account = $next_account_id;
}
$data = [
'show' => 'check_lead',
'user' => $user,

View file

@ -103,6 +103,10 @@ class MembershipController extends Controller
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
$data = [];
$data['is_from'] = 'membership';
$data['is_for'] = 'me';
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for nuy intern
@ -110,6 +114,8 @@ class MembershipController extends Controller
'payment' => 3, //Berater Membership
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
Yard::instance('shopping')->store($identifier);

View file

@ -166,8 +166,18 @@ class PayoneController extends Controller
}
//Rechnungskauf
/* if($payment_method[0]=== 'fnc'){
$this->method = [
if($payment_method[0] === 'fnc'){
//MIVITA
if(isset($payment_method[1]) && $payment_method[1] === 'MIV'){
$this->method = [
"clearingtype" => "fnc",
"wallettype" => "",
'onlinebanktransfertype' => "MIV",
"request" => "authorization",
];
}
//PAYONE
/* $this->method = [
"clearingtype" => "fnc",
"wallettype" => "",
'onlinebanktransfertype' => "",
@ -175,9 +185,9 @@ class PayoneController extends Controller
"request" => "genericpayment",
"add_paydata[action]" => "pre_check",
"add_paydata[payment_type]" => "Payolution-Invoicing",
];
];*/
}
*/
}
//vorkasse
if($payment_method === 'elv'){
@ -223,6 +233,24 @@ class PayoneController extends Controller
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
//RECHNUNG MIV
if($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV'){
$payt = PaymentTransaction::create([
'shopping_payment_id' => $this->shopping_payment->id,
'request' => $this->method['request'],
'txid' => 0,
'userid' => 0,
'status' => 'FNCMIV',
'transmitted_data' => $request,
'txaction' => 'invoice_open',
'mode' => $this->shopping_payment->mode,
]);
Util::setUserHistoryValue(['status'=>5]);
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
exit;
}
$response = Payone::sendRequest($request);
/*
* status APPROVED / REDIRECT / ERROR / PENDING
@ -273,6 +301,7 @@ class PayoneController extends Controller
]);
Util::setUserHistoryValue(['status'=>5]);
if($payt->shopping_payment->clearingtype === "vor"){
//vorkasse
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));

View file

@ -9,6 +9,8 @@ use App\Models\ShoppingInstance;
use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\Models\UserHistory;
use App\Models\UserShop;
use App\Services\Payment;
use App\Services\Util;
use App\User;
use Auth;
@ -36,14 +38,46 @@ class OrderController extends Controller
{
$user = User::find(\Auth::user()->id);
$shopping_order = ShoppingOrder::findOrFail($id);
if($shopping_order->member_id !== $user->id){
if($shopping_order->auth_user_id !== $user->id){
abort(404);
}
$data = [
'shopping_order' => $shopping_order,
'isAdmin' => false,
];
return view('user.shop.sales.order_detail', $data);
return view('user.order.detail', $data);
}
public function ordersDatatable(){
$user = User::find(\Auth::user()->id);
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('auth_user_id', '=', $user->id)->where('txaction', '!=', NULL);
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('user_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getFormattedTotalShipping();
})
->addColumn('orders', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
})
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('user_shop_id', 'user_shop_id $1')
->rawColumns(['id', 'txaction', 'user_shop_id'])
->make(true);
}

View file

@ -5,12 +5,16 @@ namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Pay\PayoneController;
use App\Models\PaymentMethod;
use App\Models\PaymentTransaction;
use App\Models\ShippingCountry;
use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderItem;
use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\Services\CustomerPriority;
use App\Services\Payment;
use App\Services\Shop;
use App\User;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Collection;
@ -37,7 +41,10 @@ class CheckoutController extends Controller
public function checkout(){
// dd("back");
//TODO ZAHLDIENSTE FORM USER !!!
// dump(Request::all());
// dd("back");
// $user_shop = Util::getUserShop();
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
@ -45,35 +52,50 @@ class CheckoutController extends Controller
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
$shopping_user = null;
if($shopping_data && $is_from !== 'shopping'){
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
}elseif($is_from === 'shopping') {
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
}
/*if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){//$is_from !== 'shopping' && ){ //
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
// $shopping_user->save();
// $this->putPayments('shopping_user_id', $shopping_user->id);
}else{
$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}*/
if(\Session::has('new_session')){
$this->destroy();
\Session::forget('new_session');
}
if(!$this->getPayments('shopping_user_id')){
if($shopping_data && $is_from !== 'shopping'){
//can wizard membership user_order
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
}elseif($is_from === 'shopping') {
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
$shopping_user->mode = 'prev';
}
}else{
$shopping_user = ShoppingUser::findOrFail($this->getPayments('shopping_user_id'));
$shopping_user->billing_state = Shop::getCountryShippingCountryId($shopping_user->billing_country_id);
$shopping_user->shipping_state = Shop::getCountryShippingCountryId($shopping_user->shipping_country_id);
}
if(Request::get('selected_country')){
//Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'), $is_for);
if(old('selected_country') && old('selected_country') === 'change'){
\Session::forget('_old_input.selected_country');
$shopping_user->billing_state = old('billing_state');
$shopping_user->shipping_state = old('shipping_state');
}else{
$shopping_user->billing_state = Yard::instance('shopping')->getShippingCountryId();
$shopping_user->shipping_state = Yard::instance('shopping')->getShippingCountryId();
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
// $selected_country = $ShippingCountry->id;
}
if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){
//$user->email;
// $shopping_user->save();
// $this->putPayments('shopping_user_id', $shopping_user->id);
}else{
//$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}
if(Util::getAuthUser()){
@ -84,12 +106,24 @@ class CheckoutController extends Controller
if($shopping_user->same_as_billing === NULL){
$shopping_user->same_as_billing = true;
}
if($is_from !== 'shopping' && Util::getAuthUser()){
$user = Util::getAuthUser();
$payment_methods = $user->payment_methods;
}else{
$payment_methods = PaymentMethod::getDefaultAsArray();
}
$payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
$data = [
'is_from' => $is_from,
'is_for' => $is_for,
'user_shop' => Util::getUserShop(),
'shopping_user' => $shopping_user,
'shopping_mode' => Util::getUserShoppingMode(),
'payment_methods' => $payment_methods,
'payment_methods_active' => $payment_methods_active,
];
return view('web.templates.checkout', $data);
}
@ -99,6 +133,7 @@ class CheckoutController extends Controller
$user = Util::getAuthUser();
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->mode = 'prev';
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
@ -168,9 +203,8 @@ class CheckoutController extends Controller
$data = Request::all();
//change selected Country
if(isset($data['selected_country']) && $data['selected_country'] === 'change'){
if(Request::get('same_as_billing')){
Yard::instance('shopping')->setShippingCountryWithPrice($data['billing_state'], $data['is_for']);
}else{
@ -180,7 +214,6 @@ class CheckoutController extends Controller
}
dd('ads');
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
@ -214,13 +247,19 @@ class CheckoutController extends Controller
//make Order and Items
$shopping_order = $this->makeShoppingOrder($shopping_user);
//CustomerPriority
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
if($shopping_user->is_from === 'shopping'){
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
}
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
//check credit Card
if(Request::get('payment_method')){
$ret = [];
//Rechnungskauf ohne PAYONE
if(Request::get('payment_method') === 'fnc#MIV'){
}
//need precheck the card
if(Request::get('payment_method') === 'cc'){
$pay = new PayoneController();
@ -249,7 +288,7 @@ class CheckoutController extends Controller
}
}
//need precheck the card
//need precheck the SEPA
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
@ -270,6 +309,7 @@ class CheckoutController extends Controller
\Session::flash('customermessage', $ret['elv']['customermessage']);
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
}
// mandate_status active
if($ret['elv']['status'] === 'APPROVED' && $ret['elv']['mandate_status'] !== "active"){
\Session::flash('elv-managemandate', 1);
\Session::flash('elv-mandate_identification', $ret['elv']['mandate_identification']);
@ -294,7 +334,6 @@ class CheckoutController extends Controller
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
//check abo and save the mandate
$this->storeUserPaymentsData($shopping_user, $ret);
}
//other
$pay = new PayoneController();
@ -359,9 +398,15 @@ class CheckoutController extends Controller
if($payt->shopping_payment->reference != $reference){
abort(404);
}
Yard::instance('shopping')->destroy();
$this->destroy();
//vor
//Rechnung MIV
if($payt->status === 'FNCMIV'){
$this->directPaymentStatus($payt);
}
$data = [
'user_shop' => Util::getUserShop(),
'order_reference' => $payt->shopping_payment->reference,
@ -392,6 +437,7 @@ class CheckoutController extends Controller
$shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id'));
if($shopping_user){
$shopping_user->fill($data);
$shopping_user->mode = null;
$shopping_user->save();
}
}
@ -420,6 +466,7 @@ class CheckoutController extends Controller
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
'txaction' => 'prev',
'mode' => Util::getUserShoppingMode(),
];
$shopping_order= false;
@ -500,4 +547,24 @@ class CheckoutController extends Controller
$this->session->remove($this->instance);
}
private function directPaymentStatus(PaymentTransaction $payt){
if(isset($payt->transmitted_data['param'])){
$shopping_order = ShoppingOrder::find($payt->transmitted_data['param']);
$shopping_order->txaction = 'invoice_open';
$shopping_order->save();
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
$shopping_payment->txaction = 'invoice_open';
$shopping_payment->save();
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
$data = [
'mode' => $payt->transmitted_data['mode'],
'txaction' => $payt->txaction,
'send_link' => $send_link,
];
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
}
}
}

View file

@ -457,6 +457,12 @@ class WizardController extends Controller
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
$data = [];
$data['is_from'] = 'wizard';
$data['is_for'] = 'me';
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => 1, //is first faker shop for buy intern
@ -464,6 +470,8 @@ class WizardController extends Controller
'payment' => 4, //Berater Wizard
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
Yard::instance('shopping')->store($identifier);

View file

@ -38,7 +38,10 @@ class Checkout
}
if($shopping_instance->back){
\Session::put('back_link', $shopping_instance->back);
}
\Session::put('new_session', true);
Yard::instance('shopping')->destroy();
//restore yard
Yard::instance('shopping')->restore($request->route('identifier'));

View file

@ -71,7 +71,7 @@ class PaymentMethod extends Model
return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-';
}
public static function getDefaultAsArray(){
public static function getDefaultAsArray($short=false){
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
}
}

View file

@ -89,6 +89,11 @@ class ShoppingPayment extends Model
return 'Sofort Überweisung';
}
}
if($this->clearingtype === 'fnc') {
if ($this->onlinebanktransfertype === 'MIV') {
return 'Rechnung';
}
}
}
public function getPaymentAmount(){

View file

@ -2,9 +2,11 @@
namespace App\Services;
use App\Mail\MailCheckout;
use App\Models\ShoppingOrder;
use App\Models\ShoppingPayment;
use App\User;
use Illuminate\Support\Facades\Mail;
class Payment
{
@ -14,6 +16,7 @@ class Payment
'appointed' => "offen",
'failed' => "abbruch",
'extern' => "extern",
'invoice_open' => "Re. offen",
'NULL' => 'keine Zahlung',
];
@ -22,6 +25,7 @@ class Payment
'appointed' => "warning",
'failed' => "danger",
'extern' => "success",
'invoice_open' => "warning",
];
@ -44,7 +48,7 @@ class Payment
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
}
if($shopping_order->mode === 'dev'){
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
return '<span class="badge badge-pill badge-info">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
}
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_order->txaction).'">'.self::getFormattedTxaction($shopping_order->txaction).'</span>';
}
@ -57,4 +61,79 @@ class Payment
}
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
$send_link = false;
$shopping_order->setUserHistoryValue(['status' => 8]);
Shop::userOrders();
$shopping_order->paid = $paid;
$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){
if($shopping_order_item->product){
if($shopping_order_item->product->action){
$user = User::findOrFail($shopping_order->auth_user_id);
$user->save();
$send_link = true;
//new date
$date = \Carbon::now()->modify('1 year');
if($user->payment_account && $user->daysActiveAccount()>0){
$date = \Carbon::parse($user->payment_account)->modify('1 year');
}
foreach ($shopping_order_item->product->action as $do){
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
$user->payment_order_id = $shopping_order_item->product->id; //34
$user->payment_account = $date;
$user->wizard = 100;
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
$user->payment_order_id = $shopping_order_item->product->id; //35
$user->payment_shop = $date;
$user->wizard = 100;
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade'){
if($shopping_order_item->product->upgrade_to_id){
$user->payment_order_id = $shopping_order_item->product->upgrade_to_id;
}
$user->payment_shop = $user->payment_account; //same Date, is upgrade
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){
if($shopping_order_item->product->upgrade_to_id){
$user->m_level = $shopping_order_item->product->upgrade_to_id;
}
}
$user->save();
}
}
}
}
}
return $send_link;
}
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){
$bcc = [];
$billing_email = $shopping_order->shopping_user->billing_email;
if(!$billing_email){
if($data['mode'] === 'test'){
$billing_email = config('app.checkout_test_mail');
}else{
$billing_email = config('app.checkout_mail');
}
}
if($data['mode'] === 'test'){
$bcc[] = config('app.checkout_test_mail');
}else{
$bcc[] = config('app.checkout_mail');
}
if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){
$bcc[] = $shopping_order->shopping_user->member->email;
}
Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $data['send_link'], $data['mode']));
}
}

View file

@ -2,6 +2,8 @@
namespace App\Services;
use App\Models\Country;
use App\Models\ShippingCountry;
use App\Models\ShoppingUser;
use Gloudemans\Shoppingcart\CartItem;
@ -40,4 +42,22 @@ class Shop
}
}
}
public static function getShippingCountryCountryId($shipping_country_id){
$shippingCountry = ShippingCountry::find($shipping_country_id);
if($shippingCountry && $shippingCountry->country){
return $shippingCountry->country->id;
}
return 1; //default DE
}
public static function getCountryShippingCountryId($country_id){
$shippingCountry = ShippingCountry::whereCountryId($country_id)->first();
if($shippingCountry){
return $shippingCountry->id;
}
return ShippingCountry::all()->first()->id;
}
}