register, Grundpreis
This commit is contained in:
parent
f06d2d15a5
commit
8e4bb0c2f6
32 changed files with 965 additions and 216 deletions
|
|
@ -141,11 +141,16 @@ class PayoneController extends Controller
|
|||
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;
|
||||
$date = date("Y-m-d H:i:s", strtotime("+1 years"));
|
||||
|
||||
//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
|
||||
|
|
@ -167,7 +172,6 @@ class PayoneController extends Controller
|
|||
}
|
||||
$user->payment_shop = $user->payment_account; //same Date, is upgrade
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
|
||||
}
|
||||
$user->save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailCustomMessage;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\UserMessage;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
|
|
@ -34,6 +38,15 @@ class CronController extends Controller
|
|||
//Mail reminder
|
||||
}
|
||||
|
||||
public function action($action = false, $key = false){
|
||||
|
||||
if($key !== 'key'){
|
||||
abort(404);
|
||||
}
|
||||
if($action === 'check_payments_account'){
|
||||
$this->checkPaymentsAccounts();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
|
|
@ -61,10 +74,180 @@ class CronController extends Controller
|
|||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
|
||||
}
|
||||
|
||||
public function checkPaymentsAccounts(){
|
||||
|
||||
/*RULES
|
||||
reminders
|
||||
> 21 remind_first_days = 31 reminder_first
|
||||
> 21 remind_first_days + sepa = 32 reminder_first_sepa
|
||||
> 14 remind_sec_days = 33 reminder_sec
|
||||
> 2 remind_last_days = 34 reminder_last
|
||||
> 0 deaktiv = 35 reminder_deaktiv
|
||||
> 0 deaktiv + sepa = 36 reminder_deaktiv_sepa
|
||||
== 7 abo_booking_days + sepa + cron = 37 reminder_collect_sepa
|
||||
*/
|
||||
//max Date for reminder
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
|
||||
dump($renewalDate);
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
|
||||
|
||||
$user = User::find(2);
|
||||
|
||||
/* $this->checkReminderPayments($user);
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
die();*/
|
||||
foreach ($users as $user){
|
||||
|
||||
|
||||
//$this->checkReminderPayments($user);
|
||||
|
||||
|
||||
// dump($user->nextRenewalAccount());
|
||||
//$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
||||
//UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
|
||||
}
|
||||
die("");
|
||||
}
|
||||
|
||||
|
||||
private function checkReminderPayments(User $user){
|
||||
|
||||
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
|
||||
return ;
|
||||
|
||||
|
||||
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
|
||||
if(!$user->isActiveAccount()){
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
return $isSend;
|
||||
}
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//34 reminder_last
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//33 reminder_sec
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
|
||||
if(!$user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
}
|
||||
|
||||
//31 reminder_first, 32 reminder_first_sepa
|
||||
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
return $isSend;
|
||||
}
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
return $isSend;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function checkIsReminderSend(User $user, $status){
|
||||
|
||||
$isSend = UserHistory::whereUserId($user->id)
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->get()->last();
|
||||
|
||||
if($isSend){
|
||||
// return true;
|
||||
}
|
||||
$referenz = $this->sendReminderMail($user, $status);
|
||||
//is not sent create
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reminder_payments', 'referenz'=>$referenz, 'identifier'=>$user->payment_account, 'status'=>$status]);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function sendReminderMail(User $user, $status){
|
||||
|
||||
$days = $user->daysActiveAccount();
|
||||
if($days < 0){
|
||||
$days = $days*-1;
|
||||
}
|
||||
|
||||
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
|
||||
$datetime = $user->getPaymentAccountDateFormat();
|
||||
|
||||
$price = "";
|
||||
if($user->payment_order_id && isset($user->payment_order_product->price)){
|
||||
$price = 'von '.$user->payment_order_product->getFormattedPrice().' EUR';
|
||||
}
|
||||
|
||||
$message = __('reminder.copy_first_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$message_last = __('reminder.copy_last_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$button = __('reminder.button_'.$status);
|
||||
|
||||
$message = preg_replace("/[\n\r]/","",$message);
|
||||
$message_last = preg_replace("/[\n\r]/","",$message_last);
|
||||
|
||||
$data = [
|
||||
'subject' => __('reminder.subject')." | ID: ".$status,
|
||||
'message' => $message,
|
||||
'message_last' => $message_last,
|
||||
'url' => route('user_membership'),
|
||||
'button' => $button,
|
||||
];
|
||||
dump($data);
|
||||
$sender = User::find(1);
|
||||
|
||||
$customer_mail = UserMessage::create([
|
||||
'user_id' => $user->id,
|
||||
'send_user_id' => $sender->id,
|
||||
'email' => $user->email,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message']." ".$data['message_last'],
|
||||
]);
|
||||
|
||||
try{
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
\Log::channel('cron')->error('Mail Error: '.$e->getMessage());
|
||||
// Never reached
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
return 0;
|
||||
}
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ class LeadController extends Controller
|
|||
'message' => $input['account_incomplete_message'],
|
||||
'confirmation_code' => $confirmation_code,
|
||||
];
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user()));
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user(), true));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_incomplete', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "E-Mail an Berater gesendet.");
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class PayoneController extends Controller
|
|||
public function init($shopping_user, $shopping_order){
|
||||
$this->shopping_user = $shopping_user;
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->default['mode'] = $this->shopping_order->mode;
|
||||
}
|
||||
|
||||
public function getShoppingPayment(){
|
||||
|
|
@ -328,7 +329,6 @@ class PayoneController extends Controller
|
|||
];
|
||||
$request = array_merge($this->default, $this->prepayment);
|
||||
return Payone::sendRequest($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -348,9 +348,8 @@ class PayoneController extends Controller
|
|||
|
||||
// "language" => 'de',
|
||||
];
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
|
||||
|
||||
// dd($request);
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
|
||||
return Payone::sendRequest($request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,38 @@ class AdminToolsController extends Controller
|
|||
dd('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function cronjobs()
|
||||
{
|
||||
//$user_shops = UserShop::all();
|
||||
$text = "";
|
||||
$values = [
|
||||
'check_payments_account' => route('cron_jobs_action', ['check_payments_account', 'key'])
|
||||
];
|
||||
$data = [
|
||||
'values' => $values,
|
||||
'text' => $text,
|
||||
];
|
||||
|
||||
return view('sys.admin.cronjobs', $data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function cronjobsStore()
|
||||
{
|
||||
$data = Input::all();
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
|
|
@ -75,10 +107,8 @@ class AdminToolsController extends Controller
|
|||
public function domainSSLStore()
|
||||
{
|
||||
$data = Input::all();
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ class CheckoutController extends Controller
|
|||
//need precheck the card
|
||||
if(Input::get('payment_method') === 'cc'){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$ret['cc'] = $pay->checkCreditCard($data);
|
||||
if($ret['cc']['status'] === 'ERROR' || $ret['cc']['status'] === 'INVALID'){
|
||||
/* PaymentTransaction::create([
|
||||
|
|
@ -163,6 +164,7 @@ class CheckoutController extends Controller
|
|||
//need precheck the card
|
||||
if(Input::get('payment_method') === 'elv' && is_null(Input::get('mandate_identification'))){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100;
|
||||
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Mail\MailContact;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Input;
|
||||
|
|
|
|||
|
|
@ -400,7 +400,6 @@ class WizardController extends Controller
|
|||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Input::get('switchers-package-wizard'));
|
||||
$showAboOptions = false;
|
||||
|
||||
if(Input::get('abo_options')){
|
||||
$showAboOptions = true;
|
||||
$user->abo_options = true;
|
||||
|
|
|
|||
|
|
@ -17,15 +17,19 @@ class MailCustomMessage extends Mailable
|
|||
protected $sender;
|
||||
public $subject;
|
||||
public $message;
|
||||
public $message_last;
|
||||
protected $save;
|
||||
|
||||
|
||||
public function __construct(User $user, $data, $sender)
|
||||
public function __construct(User $user, $data, $sender, $save = false)
|
||||
{
|
||||
$this->save = $save;
|
||||
$this->data = $data;
|
||||
$this->user = $user;
|
||||
$this->sender = $sender;
|
||||
$this->subject = isset($data['subject']) ? $data['subject'] : __('email.email_subject');
|
||||
$this->message = isset($data['message']) ? $data['message'] : '';
|
||||
$this->message_last = isset($data['message_last']) ? $data['message_last'] : '';
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -39,18 +43,17 @@ class MailCustomMessage extends Mailable
|
|||
$salutation = __('email.dear_mrs')." ".$this->user->account->first_name.",";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
UserMessage::create([
|
||||
'user_id' => $this->user->id,
|
||||
'send_user_id' => $this->sender->id,
|
||||
'email' => $this->user->email,
|
||||
'subject' => $this->subject,
|
||||
'message' => $this->message,
|
||||
'send' => true,
|
||||
'sent_at' => now(),
|
||||
]);
|
||||
if($this->save){
|
||||
UserMessage::create([
|
||||
'user_id' => $this->user->id,
|
||||
'send_user_id' => $this->sender->id,
|
||||
'email' => $this->user->email,
|
||||
'subject' => $this->subject,
|
||||
'message' => $this->message." ".$this->message_last,
|
||||
'send' => true,
|
||||
'sent_at' => now(),
|
||||
]);
|
||||
}
|
||||
$url = "";
|
||||
$button = "";
|
||||
if(isset($this->data['confirmation_code'])){
|
||||
|
|
@ -58,11 +61,18 @@ class MailCustomMessage extends Mailable
|
|||
$button = __('email.button_account');
|
||||
|
||||
}
|
||||
return $this->view('emails.auth')->with([
|
||||
|
||||
if(isset($this->data['url'])){
|
||||
$url =$this->data['url'];
|
||||
$button = $this->data['button'];
|
||||
|
||||
}
|
||||
return $this->view('emails.custom')->with([
|
||||
'url' => $url,
|
||||
'salutation' => $salutation,
|
||||
'title' => $salutation,
|
||||
'button' => $button,
|
||||
'copy1line' => $this->message,
|
||||
'content' => $this->message,
|
||||
'content_last' => $this->message_last,
|
||||
'copy2line' => __('email.copy2line'),
|
||||
'copy3line' => __('email.copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
|
|
@ -70,4 +80,4 @@ class MailCustomMessage extends Mailable
|
|||
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
|
@ -104,11 +105,6 @@ class Product extends Model
|
|||
upgrade # need upgrade_to_id set user->payment_order_id to the package in the payment api
|
||||
*/
|
||||
|
||||
protected $identifiers_types = [
|
||||
'show_upgrade' => 'Kann gepdatet werden',
|
||||
'show_order' => 'Wird immer als Option angezeigt',
|
||||
'upgrade' => 'Produktupgrade zu upgrade_to_id',
|
||||
];
|
||||
protected $table = 'products';
|
||||
|
||||
protected $casts = [
|
||||
|
|
@ -138,6 +134,8 @@ class Product extends Model
|
|||
'points',
|
||||
'weight',
|
||||
'contents',
|
||||
'contents_total',
|
||||
'unit',
|
||||
'number',
|
||||
'icons',
|
||||
'description',
|
||||
|
|
@ -152,12 +150,28 @@ class Product extends Model
|
|||
'upgrade_to_id'
|
||||
];
|
||||
|
||||
public $identifiers_types = [
|
||||
'' => '-',
|
||||
'show_upgrade' => 'Kann gepdatet werden',
|
||||
'show_order' => 'Wird immer als Option angezeigt',
|
||||
'upgrade' => 'Produktupgrade zur Upgrade to ID',
|
||||
];
|
||||
public $unitTypes = [
|
||||
0 => '',
|
||||
1 => 'ml',
|
||||
2 => 'g',
|
||||
3 => 'Liter',
|
||||
4 => 'KG',
|
||||
];
|
||||
|
||||
public $showATs = [
|
||||
0 => 'nur User Shop',
|
||||
1 => 'User + Berater Shop',
|
||||
2 => 'nur Berater Shop',
|
||||
3 => 'Registrierung Shop',
|
||||
4 => 'Mitgliedschaft Berater',
|
||||
0 => 'Nur Kunden Shop',
|
||||
1 => 'Kunden + Berater Shop',
|
||||
2 => 'Nur Berater Shop',
|
||||
3 => 'Registrierung / Mitgliedschaft Berater',
|
||||
4 => 'Nur Mitgliedschaft Berater',
|
||||
5 => 'Onboarding Berater',
|
||||
|
||||
];
|
||||
|
||||
public $actions = [
|
||||
|
|
@ -221,50 +235,63 @@ class Product extends Model
|
|||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
if(!isset($this->attributes['price'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price'], 2, ',', '.');
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->attributes['price']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedPriceEk()
|
||||
{
|
||||
if(!isset($this->attributes['price_ek'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price_ek'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price_ek'], 2, ',', '.');
|
||||
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
if(!isset($this->attributes['tax'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['tax'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['tax'], 2, ',', '.');
|
||||
return isset($this->attributes['tax']) ? Util::formatNumber($this->attributes['tax']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
if(!isset($this->attributes['price_old'])){
|
||||
return "";
|
||||
}
|
||||
if(\App::getLocale() == "en"){
|
||||
return number_format($this->attributes['price_old'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['price_old'], 2, ',', '.');
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
}
|
||||
|
||||
public function getBasePriceFormattedFull(){
|
||||
if($price = $this->getBasePrice()){
|
||||
$unit = $this->attributes['unit'];
|
||||
//ml g
|
||||
if($unit === 1 || $unit === 2){
|
||||
return Util::formatNumber($price) . ' € 100/'.$this->getUnitType();
|
||||
}
|
||||
//l kg
|
||||
if($unit === 3 || $unit === 4){
|
||||
return Util::formatNumber($price) . ' € 1/'.$this->getUnitType();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getBasePriceFormatted(){
|
||||
if($price = $this->getBasePrice()){
|
||||
return Util::formatNumber($price);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getBasePrice(){
|
||||
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
|
||||
$unit = $this->attributes['unit'];
|
||||
//ml g
|
||||
if($unit === 1 || $unit === 2){
|
||||
return $this->attributes['price'] * 100 / $this->attributes['contents_total'];
|
||||
}
|
||||
//l kg
|
||||
if($unit === 3 || $unit === 4){
|
||||
return $this->attributes['price'] * 1000 / $this->attributes['contents_total'];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public function getUnitType(){
|
||||
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
|
||||
}
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,14 @@ class UserHistory extends Model
|
|||
21 => 'payment_not_found',
|
||||
22 => 'checkout_cancel',
|
||||
23 => 'checkout_error',
|
||||
31 => 'reminder_first',
|
||||
32 => 'reminder_first_sepa',
|
||||
33 => 'reminder_sec',
|
||||
34 => 'reminder_last',
|
||||
35 => 'reminder_deaktiv',
|
||||
36 => 'reminder_deaktiv_sepa',
|
||||
37 => 'reminder_collect_sepa',
|
||||
|
||||
50 => 'delete_membership'
|
||||
];
|
||||
protected $status_colors = [
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class Util
|
|||
|
||||
public static function getUserHistoryValue($key){
|
||||
if($user_history = self::getUserHistory()) {
|
||||
return $user_history->{$user_history};
|
||||
return $user_history->{$key};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,9 @@ class User extends Authenticatable
|
|||
|
||||
|
||||
|
||||
|
||||
public function isAboOption(){
|
||||
return ($this->abo_options && $this->account && $this->account->payment_data) ? true : false;
|
||||
}
|
||||
public function isActiveAccount(){
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->gt(Carbon::now()) : false;
|
||||
}
|
||||
|
|
@ -251,15 +253,15 @@ class User extends Authenticatable
|
|||
public function isRenewalAccount()
|
||||
{
|
||||
if ($this->payment_account) {
|
||||
return Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->lt(Carbon::now());
|
||||
return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nextRenewalAccount(){
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ;
|
||||
}
|
||||
|
||||
|
||||
public function daysActiveAccount(){
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->payment_account), false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue