User Order step1
This commit is contained in:
parent
eb55b01b0d
commit
a5db985ae8
90 changed files with 6439 additions and 421 deletions
|
|
@ -4,8 +4,11 @@ namespace App\Http\Controllers;
|
|||
|
||||
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\SysLog;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -63,6 +66,11 @@ class AdminUserController extends Controller
|
|||
|
||||
if(isset($data['save-admin'])){
|
||||
$user->admin = $data['admin'];
|
||||
SysLog::action('save-admin', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user admin value: '.HTMLHelper::getRoleLabel($user->admin))
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-confirmed'])){
|
||||
|
|
@ -77,10 +85,14 @@ class AdminUserController extends Controller
|
|||
}else{
|
||||
$user->confirmation_date = null;
|
||||
}
|
||||
SysLog::action('save-confirmed', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user confirmed value: '.$user->confirmed." to date: ".$data['confirmation_date'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-active'])){
|
||||
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$user->active = $data['active'];
|
||||
if($data['active']){
|
||||
|
|
@ -92,28 +104,59 @@ class AdminUserController extends Controller
|
|||
}else{
|
||||
$user->active_date = null;
|
||||
}
|
||||
SysLog::action('save-active', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user active value: '.$user->active." to date: ".$data['active_date'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-account'])){
|
||||
$old = $user->getPaymentAccountDateFormat(true);
|
||||
if(!isset($data['payment_account']) || $data['payment_account'] == ""){
|
||||
$user->payment_account = null;
|
||||
}else{
|
||||
$user->wizard = 100;
|
||||
$user->payment_account = \Carbon::parse(str_replace("- ", "", $data['payment_account']));
|
||||
}
|
||||
SysLog::action('save-account', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_account from date: '.$old." to date: ".$data['payment_account'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-shop'])){
|
||||
$old = $user->getPaymentShopDateFormat(true);
|
||||
if(!isset($data['payment_shop']) || $data['payment_shop'] == ""){
|
||||
$user->payment_shop = null;
|
||||
}else{
|
||||
$user->wizard = 100;
|
||||
$user->payment_shop = \Carbon::parse(str_replace("- ", "", $data['payment_shop']));
|
||||
}
|
||||
SysLog::action('save-shop', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_shop from date: '.$old." to date: ".$data['payment_shop'])
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-test_mode'])){
|
||||
$user->test_mode = isset($data['test_mode']) ? true : false;;
|
||||
$user->test_mode = isset($data['test_mode']) ? true : false;
|
||||
SysLog::action('save-test_mode', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user test_mode value: '.$user->test_mode)
|
||||
->save();
|
||||
}
|
||||
|
||||
if(isset($data['save-payment_methods'])){
|
||||
$user->payment_methods = isset($data['payment_methods']) ? array_map('intval', $data['payment_methods']) : null;
|
||||
SysLog::action('save-payment_methods', 'admin_user', 3)
|
||||
->setUserId(Auth::user()->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setMessage('Set user payment_methods value: '.$user->getPaymentMethodsShort())
|
||||
->save();
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
|
|
|||
|
|
@ -132,36 +132,36 @@ idWkvklsQLI+qGu41SWyxP7x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
|
||||
-----END CERTIFICATE-----";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,11 @@ class PayoneController extends Controller
|
|||
die();
|
||||
}
|
||||
|
||||
$price = intval($data['price']*100);
|
||||
if($shopping_payment->amount != $price){
|
||||
$price = number_format((round($data['price'],2) * 100), 0, '.', '');
|
||||
$price_amount = number_format($shopping_payment->amount, 0, '.', '');
|
||||
if($price_amount != $price){
|
||||
$data['shopping_payment-amount'] = $price_amount;
|
||||
$data['price-amount'] = $price;
|
||||
\Log::channel('payone')->error('PaymentStatus: Price error: '.json_encode($data));
|
||||
echo "PaymentStatus: Price error:";
|
||||
var_dump($data);
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ class ShoppingUserController extends Controller
|
|||
'wp_order' => 'required',
|
||||
]);
|
||||
|
||||
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
|
|
@ -251,7 +252,10 @@ class ShoppingUserController extends Controller
|
|||
}else{
|
||||
$wp_order = $request->wp_order;
|
||||
}
|
||||
$wp_order = $this->prepareOrder($wp_order, $shopping_user);
|
||||
|
||||
$wp_invoice_path = isset($request->wp_invoice_path) ? $request->wp_invoice_path : null;
|
||||
$wp_order = $this->prepareOrder($wp_order, $shopping_user, $wp_invoice_path);
|
||||
|
||||
//TODO Status
|
||||
if ($wp_order){
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
|
|
@ -260,6 +264,7 @@ class ShoppingUserController extends Controller
|
|||
'success' => true,
|
||||
'data' => [
|
||||
'wp_order_number' => $shopping_user->wp_order_number,
|
||||
'wp_invoice_path' => $wp_invoice_path,
|
||||
'wp_order' => $wp_order,
|
||||
'user' => $user,
|
||||
'order' => $order,
|
||||
|
|
@ -351,6 +356,7 @@ class ShoppingUserController extends Controller
|
|||
}
|
||||
$ret = [
|
||||
'country' => isset($shopping_order->shipping_country->country->code) ? $shopping_order->shipping_country->country->code : '',
|
||||
'wp_invoice_path' => $shopping_order->wp_invoice_path,
|
||||
'total' => ($shopping_order->total*100),
|
||||
'shipping' => ($shopping_order->shipping*100),
|
||||
'total_net' => ($shopping_order->subtotal*100),
|
||||
|
|
@ -374,18 +380,21 @@ class ShoppingUserController extends Controller
|
|||
private function prepareForUpdate($data){
|
||||
|
||||
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
|
||||
|
||||
if(isset($data['billing_salutation'])){
|
||||
$data['billing_salutation'] = (int) $data['billing_salutation'];
|
||||
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if(isset($data['shipping_salutation'])){
|
||||
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
|
||||
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
|
||||
|
||||
foreach ($data as $key=>$value){
|
||||
|
||||
if($key === 'billing_salutation') {
|
||||
$ret['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if($key === 'shipping_salutation') {
|
||||
$ret['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if($key === 'billing_country_code' && isset($data['billing_country_code'])) {
|
||||
$ret['billing_country_id'] = Country::getCountryIdByCodeOrOne($data['billing_country_code']);
|
||||
}
|
||||
|
|
@ -408,6 +417,14 @@ class ShoppingUserController extends Controller
|
|||
private function prepareForStore($data){
|
||||
|
||||
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
|
||||
if(isset($data['billing_salutation'])){
|
||||
$data['billing_salutation'] = (int) $data['billing_salutation'];
|
||||
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if(isset($data['shipping_salutation'])){
|
||||
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
|
||||
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
|
||||
|
|
@ -417,13 +434,6 @@ class ShoppingUserController extends Controller
|
|||
foreach ($needs as $need){
|
||||
|
||||
$ret[$need] = isset($data[$need]) ? $data[$need] : null;
|
||||
|
||||
if ($need === 'billing_salutation' && $ret[$need] !== null) {
|
||||
$ret['billing_salutation'] = $ret['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if ($need === 'shipping_salutation' && $ret[$need] !== null) {
|
||||
$ret['shipping_salutation'] = $ret['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if ($need === 'billing_country_id') {
|
||||
$ret['billing_country_id'] = isset($data['billing_country_code']) ? Country::getCountryIdByCodeOrOne($data['billing_country_code']) : 1;
|
||||
}
|
||||
|
|
@ -448,7 +458,7 @@ class ShoppingUserController extends Controller
|
|||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareOrder($wp_shopping_order, $shopping_user){
|
||||
private function prepareOrder($wp_shopping_order, $shopping_user, $wp_invoice_path){
|
||||
Yard::instance('shopping')->destroy();
|
||||
$ret = [];
|
||||
|
||||
|
|
@ -479,14 +489,14 @@ class ShoppingUserController extends Controller
|
|||
if($ShippingCountry){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
|
||||
}
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user);
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user, $wp_invoice_path);
|
||||
$shopping_user->shopping_order = $shopping_order;
|
||||
Yard::instance('shopping')->destroy();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function makeShoppingOrder($shopping_user){
|
||||
private function makeShoppingOrder($shopping_user, $wp_invoice_path){
|
||||
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
|
|
@ -503,6 +513,7 @@ class ShoppingUserController extends Controller
|
|||
'weight' => Yard::instance('shopping')->weight(),
|
||||
'paid' => true,
|
||||
'txaction' => 'extern',
|
||||
'wp_invoice_path' => $wp_invoice_path,
|
||||
'mode' => $shopping_user->mode,
|
||||
];
|
||||
$shopping_order = $shopping_user->shopping_order;
|
||||
|
|
|
|||
|
|
@ -163,9 +163,6 @@ class CustomerController extends Controller
|
|||
return get_active_badge($ShoppingUser->auth_user_id).($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
})
|
||||
->addColumn('member_id', function (ShoppingUser $ShoppingUser) {
|
||||
if($ShoppingUser->member_id){
|
||||
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
|
||||
}
|
||||
if($ShoppingUser->is_like){
|
||||
return '<button type="button" class="btn btn-xs btn-outline-info" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$ShoppingUser->id.'"
|
||||
|
|
@ -174,6 +171,10 @@ class CustomerController extends Controller
|
|||
data-modal="modal-xl"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-edit"></span> Berater zuordnen</button>';
|
||||
}
|
||||
if($ShoppingUser->member_id){
|
||||
return '<a href="'.route('admin_lead_edit', [$ShoppingUser->member_id]).'">'.$ShoppingUser->member->getFullName().'</a>';
|
||||
}
|
||||
|
||||
return '';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingUser $ShoppingUser) {
|
||||
|
|
|
|||
|
|
@ -70,10 +70,21 @@ class DataTableController extends Controller
|
|||
return $user->shop->getActiveDateFormatSmall();
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('my_payment_methods', function (User $user) {
|
||||
$payment_methods = json_encode($user->payment_methods);
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_methods="'.htmlspecialchars($payment_methods).'">';
|
||||
if(!$user->payment_methods){
|
||||
return $link.'<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
}
|
||||
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 '<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>
|
||||
<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a>';
|
||||
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>
|
||||
<a href="' . route('admin_user_login_as', [$user->id]) . '" class="btn icon-btn btn-sm btn-warning" onclick="return confirm(\''.__('Login as User?').'\');"><span class="fa fa-sign-in-alt"></span></a></span>';
|
||||
})
|
||||
->addColumn('test_mode', function (User $user) {
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-test_mode" data-id="'.$user->id.'" data-email="'.$user->email.'" data-test_mode="'.$user->test_mode.'">';
|
||||
|
|
@ -85,7 +96,7 @@ class DataTableController extends Controller
|
|||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('shop', 'shop $1')
|
||||
->orderColumn('admin', 'active $1')
|
||||
->rawColumns(['id', 'admin', 'confirmed', 'active', 'account', 'shop', 'test_mode', 'action_delete'])
|
||||
->rawColumns(['id', 'admin', 'confirmed', 'active', 'account', 'shop', 'my_payment_methods', 'test_mode', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,6 +344,9 @@ class LeadController extends Controller
|
|||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('user_level', function (User $user) {
|
||||
return $user->user_level ? $user->user_level->name : '';
|
||||
})
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
|
||||
|
|
@ -42,6 +43,25 @@ class ModalController extends Controller
|
|||
}
|
||||
$ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'user-order-show-product'){
|
||||
$product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-show'){
|
||||
$user = \Auth::user();
|
||||
$ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-add'){
|
||||
$user = \Auth::user();
|
||||
|
||||
/* $product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render(); */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
87
app/Http/Controllers/PaymentMethodController.php
Executable file
87
app/Http/Controllers/PaymentMethodController.php
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserLevel;
|
||||
use Request;
|
||||
|
||||
|
||||
class PaymentMethodController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => PaymentMethod::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.payment_method.index', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] === "new"){
|
||||
$model = PaymentMethod::create([
|
||||
'name' => $data['name'],
|
||||
'short' => $data['short'],
|
||||
'pos' => $data['pos'],
|
||||
'show_at' => $data['show_at'],
|
||||
'default' => isset($data['default']) ? true : false,
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = PaymentMethod::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->short = $data['short'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->show_at = $data['show_at'];
|
||||
$model->default = isset($data['default']) ? true : false;
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
|
||||
/* if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
if(count($trans)){
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_payment_methods'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*public function delete($id){
|
||||
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ class ProductController extends Controller
|
|||
|
||||
public function edit($id)
|
||||
{
|
||||
if($id == "new"){
|
||||
if($id === "new"){
|
||||
$model = new Product();
|
||||
$model->active = true;
|
||||
}else{
|
||||
|
|
@ -66,7 +66,7 @@ class ProductController extends Controller
|
|||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if($data['id'] == "new"){
|
||||
if($data['id'] === "new"){
|
||||
$model = new Product();
|
||||
}else{
|
||||
$model = Product::findOrFail($data['id']);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class ShippingController extends Controller
|
|||
|
||||
public function edit($shipping_id)
|
||||
{
|
||||
if($shipping_id == "new"){
|
||||
if($shipping_id === "new"){
|
||||
$shipping = new Shipping();
|
||||
$shipping->active = 1;
|
||||
|
||||
|
|
|
|||
50
app/Http/Controllers/SyS/SettingController.php
Executable file
50
app/Http/Controllers/SyS/SettingController.php
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SySetting;
|
||||
use Request;
|
||||
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('sysadmin');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => SySetting::all(),
|
||||
];
|
||||
return view('sys.settings.index', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
if($data['id'] === "new"){
|
||||
$model = SySetting::create($data);
|
||||
}else{
|
||||
$model = SySetting::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('sysadmin_settings'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,10 +7,12 @@ use App\Http\Controllers\Api\KasController;
|
|||
use App\Http\Controllers\Api\KasSLLController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Shop;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
|
|
@ -50,6 +52,15 @@ class AdminToolsController extends Controller
|
|||
public function customerStore()
|
||||
{
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if($data['action'] === 'makePaymentMethodsDefault'){
|
||||
$users = User::where('payment_methods', '=', NULL)->get();
|
||||
//$users = User::all();
|
||||
foreach ($users as $user){
|
||||
$user->payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'checkForAll'){
|
||||
$shopping_users = CustomerPriority::checkForAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,9 +177,9 @@ class CustomerController extends Controller
|
|||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
|
||||
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'wp_order_number'])
|
||||
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
|
||||
->where('shopping_users.member_id', '=', $user->id);
|
||||
//->groupBy('shopping_users.number');
|
||||
//->groupBy('shopping_users.number');
|
||||
|
||||
/*set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if(Request::get('filter_member_id') != ""){
|
||||
|
|
@ -187,8 +187,11 @@ class CustomerController extends Controller
|
|||
}*/
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span>' : '<a href="' . route('user_order_my_delivery', ['ot', $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> wählen</a>';
|
||||
})
|
||||
->addColumn('id', function (ShoppingUser $ShoppingUser) {
|
||||
return '<a href="' . route('user_customer_detail', [$ShoppingUser->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far 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);
|
||||
|
|
@ -205,16 +208,20 @@ class CustomerController extends Controller
|
|||
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
|
||||
return get_active_badge($ShoppingUser->subscribed);
|
||||
})
|
||||
->addColumn('status', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> in Prüfung</span> ' : '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> aktiv</span>';
|
||||
})
|
||||
->addColumn('extras', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->wp_order_number.($ShoppingUser->mode==='dev' ? ' <span class="badge badge-warning">dev</span>' : '');
|
||||
})
|
||||
->orderColumn('send_to', 'id $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('billing_country_id', 'billing_country_id $1')
|
||||
->orderColumn('billing_salutation', 'billing_salutation $1')
|
||||
->orderColumn('first_created_at', 'created_at $1')
|
||||
->orderColumn('orders', 'orders $1')
|
||||
->orderColumn('subscribed', 'subscribed $1')
|
||||
->rawColumns(['id', 'subscribed', 'extras'])
|
||||
->rawColumns(['send_to', 'id', 'subscribed', 'extras', 'status'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
187
app/Http/Controllers/User/OrderController.php
Executable file
187
app/Http/Controllers/User/OrderController.php
Executable file
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\Payment;
|
||||
use App\User;
|
||||
use Request;
|
||||
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.shop');
|
||||
}
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('user.order.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->member_id !== $user->id){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.shop.sales.order_detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function delivery($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
|
||||
/*if (Request::isMethod('post')) {
|
||||
$data = Request::all();
|
||||
if($data['switchers-radio-is-for'] === 'is-for-member'){
|
||||
return redirect(route('user_order_my_list', ['me']));
|
||||
}
|
||||
if($data['switchers-radio-is-for'] === 'is-for-customer'){
|
||||
//check ist customer
|
||||
return redirect(route('user_order_my_list', ['ot', $id]));
|
||||
}
|
||||
}*/
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if($for === 'ot'){
|
||||
$shopping_user = $this->checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
|
||||
}
|
||||
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'delivery_id' => $delivery_id,
|
||||
];
|
||||
return view('user.order.delivery', $data);
|
||||
}
|
||||
|
||||
public function list($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if($for === 'ot'){
|
||||
$shopping_user = $this->checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
}
|
||||
//$data = Request::all();
|
||||
//dd(session('switchers-radio-is-for'));
|
||||
//$shopping_user = new ShoppingUser();
|
||||
//$shopping_user->id = "new";
|
||||
//$shopping_user->same_as_billing = true;
|
||||
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'user' => $user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'delivery_id' => $delivery_id,
|
||||
|
||||
];
|
||||
return view('user.order.list', $data);
|
||||
}
|
||||
|
||||
private function checkShoppingUser($id, $user){
|
||||
if($id === null){
|
||||
abort(403, 'Error: Keine User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id !== $user->id){
|
||||
abort(403, 'Error: Falsche User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->is_like){
|
||||
abort(403, 'Error: Kunde in Prüfung');
|
||||
}
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
// $user = User::find(\Auth::user()->id);
|
||||
$query = Product::select('products.*')->where('active', true)
|
||||
->where('show_at', '=', 1); //Kunden und Berater
|
||||
//->orWhere('show_at', '=', 2); // Nur Berater
|
||||
//->orderBy('pos', 'DESC')
|
||||
//->orderBy('id', 'DESC');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('add_card', function (Product $product) {
|
||||
return '<a href="#" class="btn btn-sm btn-md-extra btn-secondary">
|
||||
<strong>€ '.$product->getFormattedPriceWith().'</strong> +<span class="ion ion-md-cart"></span>
|
||||
</a>';
|
||||
|
||||
/*'<a href="javascript:void(0)" class="btn btn-secondary btn-sm my-1 mx-2">
|
||||
<i class="ion ion-md-add"></i> <i class="ion ion-md-basket"></i>
|
||||
</a><br>
|
||||
<a href="javascript:void(0)" class="btn btn-outline-secondary btn-sm my-1 mx-2">
|
||||
<i class="ion ion-md-remove"></i> <i class="ion ion-md-basket"></i>
|
||||
</a>'*/;
|
||||
})
|
||||
->addColumn('quantity', function (Product $product) {
|
||||
//return '<input type="text" class="form-control text-center" value="0" style="width: 4em">';
|
||||
return '<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button class="btn btn-secondary icon-btn md-btn-extra" type="button">-</button>
|
||||
</span>
|
||||
<input type="text" class="form-control text-center input-extra" value="0">
|
||||
<span class="input-group-append">
|
||||
<button class="btn btn-secondary icon-btn md-btn-extra" type="button">+</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
})
|
||||
->addColumn('picture', function (Product $product) {
|
||||
if(count($product->images)){
|
||||
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('price', function (Product $product) {
|
||||
return $product->getFormattedPriceWith();
|
||||
})
|
||||
->addColumn('action', function (Product $product) {
|
||||
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
|
||||
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('number', 'number $1')
|
||||
->orderColumn('points', 'points $1')
|
||||
->orderColumn('price', 'price $1')
|
||||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
->rawColumns(['add_card', 'quantity', 'picture', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -41,16 +41,25 @@ class ContactController extends Controller
|
|||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
|
||||
$rules = array(
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'email'=>'required|email',
|
||||
'message'=>'required',
|
||||
'g-recaptcha-response'=>'required|recaptcha',
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'message' => 'required',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
'accepted_data_protection' => 'required',
|
||||
);
|
||||
if (!$user_shop || $user_shop->id === 22) {
|
||||
$rules['sales_partnership'] = 'required';
|
||||
if (Request::get('sales_partnership') === 'JA') {
|
||||
$rules['sales_partnership_message'] = 'required';
|
||||
}
|
||||
}
|
||||
|
||||
Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
|
||||
|
||||
Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
|
||||
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
||||
});
|
||||
|
||||
|
|
@ -60,15 +69,20 @@ class ContactController extends Controller
|
|||
}
|
||||
|
||||
|
||||
$contact = [];
|
||||
$contact['first_name'] = Request::get('first_name');
|
||||
$contact['last_name'] = Request::get('last_name');
|
||||
$contact['email'] = Request::get('email');
|
||||
$contact['phone'] = Request::get('phone');
|
||||
$contact['subject'] = Request::get('subject');
|
||||
$contact['message'] = Request::get('message');
|
||||
$contact = [];
|
||||
$contact['salutation'] = Request::get('salutation');
|
||||
$contact['first_name'] = Request::get('first_name');
|
||||
$contact['last_name'] = Request::get('last_name');
|
||||
$contact['email'] = Request::get('email');
|
||||
$contact['phone'] = Request::get('phone');
|
||||
$contact['message'] = Request::get('message');
|
||||
if (!$user_shop){
|
||||
$contact['sales_partnership'] = Request::get('sales_partnership');
|
||||
$contact['sales_partnership_message'] = Request::get('sales_partnership_message');
|
||||
}
|
||||
|
||||
$checkout_mail = config('app.checkout_mail');
|
||||
|
||||
$checkout_mail = config('app.checkout_mail');
|
||||
if($user_shop){
|
||||
Mail::to($contact['email'])->bcc([$user_shop->user->email, $checkout_mail])->send(new MailContact($contact));
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ class RegisterController extends Controller
|
|||
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'salutation' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
|
|
|
|||
|
|
@ -21,20 +21,32 @@ class MailContact extends Mailable
|
|||
{
|
||||
$this->data = $data;
|
||||
$this->user_shop = Util::getUserShop();
|
||||
$this->subject = __('email.request_from').' mivita.care';
|
||||
$this->subject = __('email.your_request_from').' mivita.care';
|
||||
if($this->user_shop){
|
||||
$this->subject = __('email.request_from')." ".$this->user_shop->slug.'.mivita.care';
|
||||
$this->subject = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
|
||||
}
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$salutation = __('email.salutation');
|
||||
$salutation = __('email.hello');
|
||||
if(isset($this->data['first_name'])){
|
||||
$salutation .= " ".$this->data['first_name'];
|
||||
}
|
||||
|
||||
if(isset($this->data['salutation'])){
|
||||
if($this->data['salutation'] === 'mr'){
|
||||
$this->data['salutation'] = 'Herr';
|
||||
}
|
||||
if($this->data['salutation'] === 'ms'){
|
||||
$this->data['salutation'] = 'Frau';
|
||||
}
|
||||
}
|
||||
$copy1line = __('email.your_request_from')." mivita.care";
|
||||
if($this->user_shop){
|
||||
$copy1line = __('email.your_request_from')." ".$this->user_shop->slug.'.mivita.care';
|
||||
}
|
||||
|
||||
return $this->view('emails.contact')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => $copy1line,
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class MailInfo extends Mailable
|
|||
if($this->action === "check_is_like_customer") {
|
||||
$copy1line = "Hier geht es zum Kunden:"."\n";
|
||||
$button = "zum Kunden";
|
||||
$title = "Ein Kunden muss überprüfen werden und einem Berater zugeordnet werden, da die Adresse nicht eindeutig ist.";
|
||||
$title = "Ein Kunden muss überprüft werden und einem Berater zugeordnet werden, da die Adresse nicht eindeutig ist.";
|
||||
$url = route('admin_customer_detail', $this->user->id);
|
||||
$content .= $this->user ? 'Firma: '.$this->user->billing_company."\n" : '';
|
||||
$content .= \App\Services\HTMLHelper::getSalutationLang($this->user->billing_salutation)." ";
|
||||
|
|
@ -85,7 +85,7 @@ class MailInfo extends Mailable
|
|||
if($this->action === "change_is_like_customer"){
|
||||
$copy1line = "Hier geht es zum Kunden:"."\n";
|
||||
$button = "zum Kunden";
|
||||
$title = "Ein Kunden muss erneut überprüfen werden, da bei einer Änderung eine bestehende Kundenhoheit gefunden wurde.";
|
||||
$title = "Ein Kunden muss erneut überprüft werden, da bei einer Änderung eine bestehende Kundenhoheit gefunden wurde.";
|
||||
$url = route('admin_customer_detail', $this->user->id);
|
||||
$content .= "Folgende Daten für die Kundenhoheit wurden geändert:"."\n";
|
||||
foreach ($this->data as $key=>$value){
|
||||
|
|
|
|||
63
app/Mail/MailSyS.php
Normal file
63
app/Mail/MailSyS.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class MailSyS extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $model;
|
||||
protected $action;
|
||||
|
||||
public $subject;
|
||||
|
||||
public function __construct($model, $action)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->action = $action;
|
||||
|
||||
if($this->action === "log"){
|
||||
$this->subject = 'mivita Logger';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
$content = "";
|
||||
if($this->action === "log"){
|
||||
|
||||
$title = "New Log";
|
||||
|
||||
|
||||
if($this->model->user_id && $this->model->user){
|
||||
$content .= "From User: ".$this->model->user->id." | ".$this->model->user->email."\n";
|
||||
}
|
||||
if($this->model->model && $this->model->model_id){
|
||||
$content .= "Apply: ".$this->model->model." | ".$this->model->model_id."\n";
|
||||
if($this->model->model === 'App\User'){
|
||||
$apply = User::find($this->model->model_id);
|
||||
$content .= $this->model->model.": ".$apply->email." | ".$this->model->model_id."\n";
|
||||
}
|
||||
}
|
||||
$content .= "\n";
|
||||
$content .= "Action: ".$this->model->action."\n";
|
||||
$content .= "Message: ".$this->model->message."\n";
|
||||
$content .= "\n";
|
||||
$content .= "Channel: ".$this->model->channel."\n";
|
||||
$content .= "Level: ".$this->model->getLevelType()."\n";
|
||||
$content .= "\n";
|
||||
$content .= "Time: ".$this->model->created_at->format("d.m.Y H:i");
|
||||
}
|
||||
|
||||
return $this->view('emails.sys')->with([
|
||||
'title' => $title,
|
||||
'content' => $content,
|
||||
]);
|
||||
}
|
||||
}
|
||||
71
app/Models/Logger.php
Normal file
71
app/Models/Logger.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Logger
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $model_id
|
||||
* @property string $model
|
||||
* @property string $action
|
||||
* @property string $channel
|
||||
* @property string $message
|
||||
* @property int $level
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Logger extends Model
|
||||
{
|
||||
protected $table = 'loggers';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'model_id' => 'int',
|
||||
'level' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'model_id',
|
||||
'model',
|
||||
'action',
|
||||
'channel',
|
||||
'message',
|
||||
'level'
|
||||
];
|
||||
|
||||
public $levelTypes = [
|
||||
1 => 'debug',
|
||||
2 => 'info',
|
||||
3 => 'notice',
|
||||
4 => 'warning',
|
||||
5 => 'error',
|
||||
6 => 'critical',
|
||||
7 => 'alert',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function getLevelType(){
|
||||
|
||||
return isset($this->levelTypes[$this->level]) ? $this->levelTypes[$this->level] : "";
|
||||
}
|
||||
|
||||
}
|
||||
77
app/Models/PaymentMethod.php
Normal file
77
app/Models/PaymentMethod.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class PaymentMethod
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $short
|
||||
* @property int $show_at
|
||||
* @property int $pos
|
||||
* @property bool $active
|
||||
* @property bool $default
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereDefault($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
|
||||
protected $table = 'payment_methods';
|
||||
|
||||
protected $casts = [
|
||||
'show_at' => 'int',
|
||||
'pos' => 'int',
|
||||
'active' => 'bool',
|
||||
'default' => 'bool',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'short',
|
||||
'show_at',
|
||||
'pos',
|
||||
'default',
|
||||
'active'
|
||||
];
|
||||
|
||||
public static $showATs = [
|
||||
0 => 'Nur Kunden Shop',
|
||||
1 => 'Nur Berater Shop',
|
||||
2 => 'Kunden + Berater Shop',
|
||||
3 => 'Nur Reg/Mitgliedschaft Berater',
|
||||
4 => 'Kunden + Berater Shop + Reg/Mitgliedschaft',
|
||||
5 => 'Berater Shop + Reg/Mitgliedschaft',
|
||||
9 => 'überall',
|
||||
];
|
||||
|
||||
public function getShowAtType(){
|
||||
return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-';
|
||||
}
|
||||
|
||||
public static function getDefaultAsArray(){
|
||||
return PaymentMethod::where('active', true)->where('default', true)->pluck('id');
|
||||
}
|
||||
}
|
||||
|
|
@ -103,6 +103,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $country_prices_count
|
||||
* @property int|null $wp_number
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereWpNumber($value)
|
||||
* @property bool|null $shipping_addon
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereShippingAddon($value)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -124,7 +126,9 @@ class Product extends Model
|
|||
'trans_usage' => 'array',
|
||||
'trans_ingredients' => 'array',
|
||||
'action' => 'array',
|
||||
'wp_number' => 'int'
|
||||
'wp_number' => 'int',
|
||||
'shipping_addon' => 'bool',
|
||||
'active' => 'bool'
|
||||
];
|
||||
use Sluggable;
|
||||
|
||||
|
|
@ -155,6 +159,7 @@ class Product extends Model
|
|||
'amount',
|
||||
'active',
|
||||
'show_at',
|
||||
'shipping_addon',
|
||||
'identifier',
|
||||
'action',
|
||||
'upgrade_to_id'
|
||||
|
|
@ -235,20 +240,20 @@ class Product extends Model
|
|||
}
|
||||
|
||||
public function setPriceAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
|
||||
|
||||
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceEkAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_ek'] = floatval(str_replace(',', '.', $value));
|
||||
|
||||
$this->attributes['price_ek'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setTaxAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
|
||||
|
||||
$this->attributes['tax'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
public function setPriceOldAttribute( $value ) {
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price_old'] = floatval(str_replace(',', '.', $value));
|
||||
|
||||
$this->attributes['price_old'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function getFormattedPrice()
|
||||
|
|
@ -271,6 +276,34 @@ class Product extends Model
|
|||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
}
|
||||
|
||||
/*price by user Factor*/
|
||||
private function calcPriceUserFactor($price){
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
$margin = ((\Auth::user()->user_level->margin -100)*-1) / 100;
|
||||
$price = $price * $margin;
|
||||
}
|
||||
return $price;
|
||||
}
|
||||
/*price net*/
|
||||
private function calcPriceNet($price){
|
||||
$tax_rate = ($this->attributes['tax'] + 100) / 100;
|
||||
|
||||
return $price / $tax_rate;
|
||||
}
|
||||
//price calu with
|
||||
public function getPriceWith(Bool $net = true, Bool $ufactor = true){
|
||||
$price = $this->attributes['price'];
|
||||
$price = $net ? $this->calcPriceNet($price) : $price;
|
||||
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
|
||||
return $price;
|
||||
}
|
||||
/*out*/
|
||||
public function getFormattedPriceWith(Bool $net = true, Bool $ufactor = true)
|
||||
{
|
||||
return isset($this->attributes['price']) ? Util::formatNumber($this->getPriceWith($net, $ufactor)) : "";
|
||||
}
|
||||
|
||||
|
||||
public function getBasePriceFormattedFull(){
|
||||
if($price = $this->getBasePrice()){
|
||||
$unit = $this->attributes['unit'];
|
||||
|
|
@ -310,6 +343,10 @@ class Product extends Model
|
|||
public function getUnitType(){
|
||||
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
|
||||
}
|
||||
public function getShowAtType(){
|
||||
return isset($this->showATs[$this->show_at]) ? $this->showATs[$this->show_at] : '-';
|
||||
}
|
||||
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
|
||||
* @property-read int|null $shipping_prices_count
|
||||
*/
|
||||
class Shipping extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
|
|
@ -34,13 +35,15 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightTo($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-write mixed $tax
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTaxRate($value)
|
||||
*/
|
||||
class ShippingPrice extends Model
|
||||
{
|
||||
protected $table = 'shipping_prices';
|
||||
|
||||
protected $fillable = [
|
||||
'shipping_id', 'price', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
|
||||
'shipping_id', 'price', 'price_comp', 'tax_rate', 'factor', 'total_from', 'total_to', 'weight_from', 'weight_to',
|
||||
];
|
||||
|
||||
public function shipping()
|
||||
|
|
@ -49,115 +52,65 @@ class ShippingPrice extends Model
|
|||
}
|
||||
|
||||
|
||||
public function _format_number($value)
|
||||
{
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
}
|
||||
|
||||
public function setPriceAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
|
||||
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setPriceCompAttribute($value)
|
||||
{
|
||||
$this->attributes['price_comp'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setFactorAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
if ($value == "") {
|
||||
$this->attributes['factor'] = null;
|
||||
} else {
|
||||
$this->attributes['factor'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
$this->attributes['factor'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setTaxAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
if ($value == "") {
|
||||
$this->attributes['tax_rate'] = null;
|
||||
} else {
|
||||
$this->attributes['tax_rate'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
$this->attributes['tax_rate'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
|
||||
public function setTotalFromAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
if ($value == "") {
|
||||
$this->attributes['total_from'] = null;
|
||||
} else {
|
||||
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
$this->attributes['total_from'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
public function setTotalToAttribute($value)
|
||||
{
|
||||
$value = $this->_format_number($value);
|
||||
if ($value == "") {
|
||||
$this->attributes['total_to'] = null;
|
||||
} else {
|
||||
|
||||
$this->attributes['total_to'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
$this->attributes['total_to'] = $value ? Util::reFormatNumber($value) : null;
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedPrice()
|
||||
{
|
||||
if ($this->attributes['price'] === NULL) {
|
||||
return $this->attributes['price'];
|
||||
}
|
||||
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 getFormattedPriceComp()
|
||||
{
|
||||
return isset($this->attributes['price_comp']) ? Util::formatNumber($this->attributes['price_comp']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedTaxRate()
|
||||
{
|
||||
if ($this->attributes['tax_rate'] === NULL) {
|
||||
return $this->attributes['tax_rate'];
|
||||
}
|
||||
if (\App::getLocale() == "en") {
|
||||
return number_format($this->attributes['tax_rate'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['tax_rate'], 2, ',', '.');
|
||||
return isset($this->attributes['tax_rate']) ? Util::formatNumber($this->attributes['tax_rate']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedFactor()
|
||||
{
|
||||
if ($this->attributes['factor'] === NULL) {
|
||||
return $this->attributes['factor'];
|
||||
}
|
||||
if (\App::getLocale() == "en") {
|
||||
return number_format($this->attributes['factor'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['factor'], 2, ',', '.');
|
||||
return isset($this->attributes['factor']) ? Util::formatNumber($this->attributes['factor']) : "";
|
||||
}
|
||||
|
||||
|
||||
public function getFormatTotalFrom()
|
||||
{
|
||||
if ($this->attributes['total_from'] === NULL) {
|
||||
return $this->attributes['total_from'];
|
||||
}
|
||||
if (\App::getLocale() == "en") {
|
||||
return number_format($this->attributes['total_from'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_from'], 2, ',', '.');
|
||||
return isset($this->attributes['total_from']) ? Util::formatNumber($this->attributes['total_from']) : "";
|
||||
}
|
||||
|
||||
public function getFormattedTotalTo()
|
||||
{
|
||||
if ($this->attributes['total_to'] === NULL) {
|
||||
return $this->attributes['total_to'];
|
||||
}
|
||||
if (\App::getLocale() == "en") {
|
||||
return number_format($this->attributes['total_to'], 2, '.', ',');
|
||||
}
|
||||
return number_format($this->attributes['total_to'], 2, ',', '.');
|
||||
return isset($this->attributes['total_to']) ? Util::formatNumber($this->attributes['total_to']) : "";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrder withoutTrashed()
|
||||
* @property-read \App\Models\ShippingCountry $shipping_country
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -90,6 +91,7 @@ class ShoppingOrder extends Model
|
|||
'weight',
|
||||
'paid',
|
||||
'txaction',
|
||||
'wp_invoice_path',
|
||||
'mode',
|
||||
];
|
||||
|
||||
|
|
@ -101,7 +103,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Sh','country_id');
|
||||
return $this->belongsTo('App\Models\ShippingCountry','country_id');
|
||||
}
|
||||
|
||||
public function shipping_country()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property float|null $tax_rate
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property string|null $user_deleted_at
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingOrderItem withoutTrashed()
|
||||
*/
|
||||
class ShoppingOrderItem extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withoutTrashed()
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMode($value)
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
{
|
||||
|
|
|
|||
64
app/Models/SySetting.php
Normal file
64
app/Models/SySetting.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class SySetting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $slug
|
||||
* @property string $message
|
||||
* @property string $action
|
||||
* @property int $status
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class SySetting extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
protected $table = 'sy_settings';
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'message',
|
||||
'action',
|
||||
'status',
|
||||
'active'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
1 => 'default',
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
}
|
||||
|
|
@ -26,9 +26,10 @@ class ProductRepository extends BaseRepository {
|
|||
{
|
||||
|
||||
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||
$data['shipping_addon'] = isset($data['shipping_addon']) ? 1 : 0;
|
||||
|
||||
|
||||
if($data['id'] == "new"){
|
||||
if($data['id'] === "new"){
|
||||
$this->model = Product::create($data);
|
||||
}
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserAccount;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
|
@ -27,6 +28,10 @@ class UserRepository extends BaseRepository {
|
|||
'email' => $data['email'],
|
||||
'password' => env('APP_KEY'),
|
||||
]);
|
||||
$this->model->payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
$this->model->save();
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
$this->model = $this->getById($data['user_id']);
|
||||
|
|
@ -67,6 +72,7 @@ class UserRepository extends BaseRepository {
|
|||
]);
|
||||
|
||||
$this->model->account_id = $account->id;
|
||||
$this->model->payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
$this->model->save();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Models\Category;
|
|||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserLevel;
|
||||
use App\User;
|
||||
|
||||
|
|
@ -299,4 +300,21 @@ class HTMLHelper
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserCustomerOptions($id, $all=false){
|
||||
$values = ShoppingUser::select(['id', 'billing_firstname', 'billing_lastname', 'billing_email', 'number'])
|
||||
->where('shopping_users.member_id', '=', \Auth::user()->id)->get();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
dump($value);
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$to = $value->billing_firstname." ".$value->billing_lastname." | ".$value->billing_email;
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.' #'.$value->number.'</option>\n';
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
78
app/Services/SysLog.php
Normal file
78
app/Services/SysLog.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\MailSyS;
|
||||
use App\Models\Logger;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class SysLog
|
||||
{
|
||||
|
||||
|
||||
/* protected $user_id;
|
||||
protected $model;
|
||||
protected $model_id;
|
||||
protected $message;
|
||||
protected $action;
|
||||
protected $channel;
|
||||
protected $level;*/
|
||||
|
||||
protected $log;
|
||||
|
||||
public $levelTypes = [
|
||||
1 => 'debug',
|
||||
2 => 'info',
|
||||
3 => 'notice',
|
||||
4 => 'warning',
|
||||
5 => 'error',
|
||||
6 => 'critical',
|
||||
7 => 'alert',
|
||||
];
|
||||
|
||||
function __construct($action = null, $channel = 'default', $level = 1)
|
||||
{
|
||||
$this->log = new Logger();
|
||||
$this->log->action = $action;
|
||||
$this->log->channel = $channel;
|
||||
$this->log->level = $level;
|
||||
}
|
||||
|
||||
public static function action($action = null, $channel = 'default', $level = 1)
|
||||
{
|
||||
//Return new instance of this model
|
||||
return new self($action, $channel, $level);
|
||||
}
|
||||
|
||||
public function setModel($id, $model){
|
||||
$this->log->model_id = $id;
|
||||
$this->log->model = $model;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUserId($user_id){
|
||||
$this->log->user_id = $user_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMessage($message){
|
||||
$this->log->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save(){
|
||||
$this->log->save();
|
||||
//send Mail
|
||||
if($this->log->level >= 3){
|
||||
$mail = config('app.info_test_mail');
|
||||
Mail::to($mail)->send(new MailSyS($this->log, 'log'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getLevelType(){
|
||||
return $this->levelTypes[$this->log->level];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -17,4 +17,5 @@ class UserService
|
|||
while(!$unique);
|
||||
return $confirmation_code;
|
||||
}
|
||||
|
||||
}
|
||||
17
app/User.php
17
app/User.php
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
|
@ -112,6 +113,8 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read int|null $clients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Token[] $tokens
|
||||
* @property-read int|null $tokens_count
|
||||
* @property array|null $payment_methods
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentMethods($value)
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
|
@ -134,6 +137,7 @@ class User extends Authenticatable
|
|||
|
||||
protected $casts = [
|
||||
'settings' => 'array',
|
||||
'payment_methods' => 'array'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -366,7 +370,6 @@ class User extends Authenticatable
|
|||
if(!$this->attributes['payment_account']){ return ""; }
|
||||
if(!$time){
|
||||
return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateDB());
|
||||
|
||||
}
|
||||
return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
|
@ -403,6 +406,18 @@ class User extends Authenticatable
|
|||
return isset($this->settings[$key]) ? $this->settings[$key] : $default;
|
||||
}
|
||||
|
||||
public function getPaymentMethodsShort(){
|
||||
$ret = "";
|
||||
if($this->payment_methods !== null){
|
||||
foreach ($this->payment_methods as $payment_method){
|
||||
if($find = PaymentMethod::find($payment_method)){
|
||||
$ret .= $find->short." | ";
|
||||
}
|
||||
}
|
||||
$ret = rtrim($ret, " | ");
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue