Card + Products
This commit is contained in:
parent
5ff57a21a7
commit
c129a44383
38 changed files with 4489 additions and 1789 deletions
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||
|
||||
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Models\Account;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
|
|
@ -30,6 +31,23 @@ class AdminUserController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$kas = new KasController();
|
||||
$pra = array(
|
||||
'subdomain_name' => 'test',
|
||||
'domain_name' => 'mivita.care',
|
||||
'subdomain_path' => '/mein.mivita.care/public/',
|
||||
//'php_version' => '7.1',
|
||||
//'ssl_proxy' => 'Y',
|
||||
//'redirect_status' => 0
|
||||
|
||||
|
||||
);
|
||||
//add_subdomain
|
||||
$req = $kas->action('get_subdomains');
|
||||
//"is_active"]=> string(1) "Y" ["in_progress"
|
||||
|
||||
var_dump($req);
|
||||
die();
|
||||
$data = [
|
||||
//'values' => User::where('admin', 0)->get(),
|
||||
'values' => User::where('confirmation_code_remider', '!=', 2)->get(),
|
||||
|
|
|
|||
89
app/Http/Controllers/Api/KasController.php
Executable file
89
app/Http/Controllers/Api/KasController.php
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Input;
|
||||
use \SoapClient;
|
||||
|
||||
class KasController extends Controller
|
||||
{
|
||||
|
||||
|
||||
// Logindaten
|
||||
private $kas_user = 'w017f6e4'; // KAS-Logon
|
||||
private $kas_pass = '7mMJUF4YSVWNpp39'; // KAS-Passwort
|
||||
private $session_lifetime = 600; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung
|
||||
private $session_update_lifetime = 'Y'; // bei N läuft die Session nach <$session_lifetime> Sekunden ab, bei Y verlängert sich die Session mit jeder Benutzung
|
||||
private $CredentialToken = false;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->login();
|
||||
}
|
||||
|
||||
|
||||
public function action($func, $para = array()){
|
||||
|
||||
try
|
||||
{
|
||||
$Params = array(); // Parameter für die API-Funktion
|
||||
$SoapRequest = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl');
|
||||
$req = $SoapRequest->KasApi(json_encode(array(
|
||||
'KasUser' => $this->kas_user, // KAS-User
|
||||
'KasAuthType' => 'session', // Auth per Sessiontoken
|
||||
'KasAuthData' => $this->CredentialToken, // Auth-Token
|
||||
'KasRequestType' => $func, // API-Funktion
|
||||
'KasRequestParams' => $para // Parameter an die API-Funktion
|
||||
)));
|
||||
if(isset($req['Response']['ReturnString']) && $req['Response']['ReturnString'] == "TRUE"){
|
||||
return $req['Response']['ReturnInfo'];
|
||||
}
|
||||
return $req;
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
{
|
||||
trigger_error(" Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function login(){
|
||||
try
|
||||
{
|
||||
$SoapLogon = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl');
|
||||
$this->CredentialToken = $SoapLogon->KasAuth(json_encode(array(
|
||||
'KasUser' => $this->kas_user,
|
||||
'KasAuthType' => 'sha1',
|
||||
'KasPassword' => sha1($this->kas_pass),
|
||||
'SessionLifeTime' => $this->session_lifetime,
|
||||
'SessionUpdateLifeTime' => $this->session_update_lifetime
|
||||
)));
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
{
|
||||
trigger_error("Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
101
app/Http/Controllers/Web/CardController.php
Executable file
101
app/Http/Controllers/Web/CardController.php
Executable file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product;
|
||||
use Yard;
|
||||
use Input;
|
||||
|
||||
class CardController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Cart::instance('wishlist')->add('sdjk922', 'Product 2', 1, 19.95, ['size' => 'medium']);
|
||||
public function addToCardGet($id, $quantity = 1, $product_slug = false)
|
||||
{
|
||||
|
||||
$product = Product::find($id);
|
||||
if($product){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug]);
|
||||
}
|
||||
return back();
|
||||
|
||||
}
|
||||
|
||||
public function addToCardPost($id)
|
||||
{
|
||||
|
||||
$product = Product::find($id);
|
||||
|
||||
if($product){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$quantity = Input::get('quantity') ? Input::get('quantity') : 1;
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug]);
|
||||
}
|
||||
return back();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function showCard(){
|
||||
return view('web.templates.card');
|
||||
}
|
||||
|
||||
public function updateCard(){
|
||||
|
||||
$data = Input::all();
|
||||
if(isset($data['quantity'])){
|
||||
foreach ($data['quantity'] as $rowId => $qty){
|
||||
Yard::instance('shopping')->update($rowId, $qty);
|
||||
}
|
||||
}else{
|
||||
$this->deleteCard();
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function checkoutCard(){
|
||||
return view('web.templates.checkout');
|
||||
}
|
||||
|
||||
public function checkoutFinalCard(){
|
||||
return view('web.templates.checkout-final');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function removeCard($rowId){
|
||||
|
||||
Yard::instance('shopping')->remove($rowId);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function deleteCard(){
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,8 +6,6 @@ namespace App\Http\Controllers\Web;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
use Input;
|
||||
|
||||
class SiteController extends Controller
|
||||
|
|
@ -31,14 +29,14 @@ class SiteController extends Controller
|
|||
{
|
||||
|
||||
if($product_slug){
|
||||
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
$product = Product::where('slug', $product_slug)->where('active', true)->first();
|
||||
if ($category && $product) {
|
||||
|
||||
|
||||
$data = [
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'product' => $product,
|
||||
'p_count' => Product::where('active', true)->count(),
|
||||
|
||||
|
|
@ -54,7 +52,7 @@ class SiteController extends Controller
|
|||
if ($category) {
|
||||
$data = [
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'products' => Product::whereHas('categories', function ($query) use ($category) {
|
||||
$query->where('category_id', '=', $category->id);
|
||||
|
||||
|
|
@ -68,8 +66,8 @@ class SiteController extends Controller
|
|||
}
|
||||
$data = [
|
||||
'subsite' => 'alle-produkte',
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => Product::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'products' => Product::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'p_count' => Product::where('active', true)->count(),
|
||||
];
|
||||
return view('web.templates.'.$site, $data);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereSlug($value)
|
||||
*/
|
||||
class Attribute extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereSlug($value)
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
|
|
|
|||
30
app/Providers/YardServiceProvider.php
Executable file
30
app/Providers/YardServiceProvider.php
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Services\Yard;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class YardServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(Yard::class, function ($app) {
|
||||
return new Yard($app['session'], $app['events']);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
19
app/Services/Facade/Yard.php
Normal file
19
app/Services/Facade/Yard.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Facade;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Yard extends Facade {
|
||||
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return \App\Services\Yard::class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,10 +3,6 @@ namespace App\Services;
|
|||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\Category;
|
||||
use App\Models\Country;
|
||||
use App\Models\IndustrySector;
|
||||
use App\Models\Interest;
|
||||
use Form;
|
||||
|
||||
class HTMLHelper
|
||||
{
|
||||
|
|
@ -138,7 +134,6 @@ class HTMLHelper
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* public static function getCompanyOptions($company){
|
||||
$options = array(1 => __('business'), 0 => __('private'), );
|
||||
$ret = "";
|
||||
|
|
|
|||
167
app/Services/Yard.php
Normal file
167
app/Services/Yard.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use \Gloudemans\Shoppingcart\Cart;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
|
||||
class Yard extends Cart
|
||||
{
|
||||
|
||||
private $shipping = 0;
|
||||
|
||||
public function __construct(SessionManager $session, Dispatcher $events)
|
||||
{
|
||||
parent::__construct($session, $events);
|
||||
}
|
||||
|
||||
|
||||
public static function getTaxRate()
|
||||
{
|
||||
return config('cart.tax');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $shipping
|
||||
*/
|
||||
public function setShipping($shipping)
|
||||
{
|
||||
$this->shipping = floatval($shipping); ;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $decimals
|
||||
* @param null $decimalPoint
|
||||
* @param null $thousandSeperator
|
||||
* @return string
|
||||
*/
|
||||
public function shipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
return $this->numberFormat($this->shipping, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
//
|
||||
private function shippingTax($taxRate = -19){
|
||||
return ($this->shipping * ($taxRate / 100));
|
||||
}
|
||||
|
||||
|
||||
private function shippingSub($taxRate){
|
||||
return ($this->shipping + $this->shippingTax($taxRate));
|
||||
}
|
||||
|
||||
|
||||
public function subtotalWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$taxRate =config('cart.tax');
|
||||
$total = floatval($this->total(2, '.', '')) + $this->shipping;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate;
|
||||
return $this->numberFormat(($total - $totalTax), $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
public function taxWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$taxRate =config('cart.tax');
|
||||
$total = floatval($this->total(2, '.', '')) + $this->shipping;
|
||||
$totalTax = $total/ (100 + $taxRate) * $taxRate;
|
||||
return $this->numberFormat($totalTax, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
public function totalWithShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$total = floatval($this->total(2, '.', '')) + $this->shipping;
|
||||
return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the total price of the items in the cart.
|
||||
*
|
||||
* @param int $decimals
|
||||
* @param string $decimalPoint
|
||||
* @param string $thousandSeperator
|
||||
* @return string
|
||||
*/
|
||||
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
$total = $content->reduce(function ($total, CartItem $cartItem) {
|
||||
return $total + ($cartItem->qty * $cartItem->price);
|
||||
}, 0);
|
||||
|
||||
return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total tax of the items in the cart.
|
||||
*
|
||||
* @param int $decimals
|
||||
* @param string $decimalPoint
|
||||
* @param string $thousandSeperator
|
||||
* @return float
|
||||
*/
|
||||
public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
||||
$tax = $content->reduce(function ($tax, CartItem $cartItem) {
|
||||
$priceTax = $cartItem->price / (100 + $cartItem->taxRate) * $cartItem->taxRate;
|
||||
return $tax + ($cartItem->qty * $priceTax);
|
||||
}, 0);
|
||||
|
||||
return $this->numberFormat($tax, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subtotal (total - tax) of the items in the cart.
|
||||
*
|
||||
* @param int $decimals
|
||||
* @param string $decimalPoint
|
||||
* @param string $thousandSeperator
|
||||
* @return float
|
||||
*/
|
||||
public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
||||
$subTotal = $content->reduce(function ($subTotal, CartItem $cartItem) {
|
||||
$priceTax = $cartItem->price / (100 + $cartItem->taxRate) * $cartItem->taxRate;
|
||||
return $subTotal + ($cartItem->qty * ($cartItem->price - $priceTax));
|
||||
}, 0);
|
||||
|
||||
return $this->numberFormat($subTotal, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Formated number
|
||||
*
|
||||
* @param $value
|
||||
* @param $decimals
|
||||
* @param $decimalPoint
|
||||
* @param $thousandSeperator
|
||||
* @return string
|
||||
*/
|
||||
protected function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator)
|
||||
{
|
||||
if(is_null($decimals)){
|
||||
$decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals');
|
||||
}
|
||||
if(is_null($decimalPoint)){
|
||||
$decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point');
|
||||
}
|
||||
if(is_null($thousandSeperator)){
|
||||
$thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator');
|
||||
}
|
||||
|
||||
return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue