#10 Promotion Modul, Kommentar 2

This commit is contained in:
Kevin Adametz 2021-11-09 18:40:18 +01:00
parent f0da981737
commit c9e1545693
128 changed files with 8194 additions and 637 deletions

View file

@ -0,0 +1,99 @@
<?php
namespace App\Http\Controllers\Web;
use Request;
use Response;
use Validator;
use App\Services\Util;
use App\Models\Product;
use App\Models\PaymentMethod;
use App\Models\PromotionUser;
use App\Http\Controllers\Controller;
class PromotionController extends Controller
{
public function __construct()
{
}
public function serve($path = null)
{
if(!isset($path)){
abort(402);
}
//search for promo
$PromotionUser = PromotionUser::where('url', trim($path))->whereNull('user_deleted_at')->first();
if(!$PromotionUser){
abort(402);
}
if($PromotionUser->checkOutOfStock()){
$data = [
'promotion_user' => $PromotionUser,
];
return view('web.promotion.outofstock', $data);
}
$data = [
'promotion_user' => $PromotionUser,
'shop_products' => Product::where('active', true)->whereJsonContains('show_on', ['1', '2', '3'])->orderBy('pos', 'ASC')->get(),
'user_payment_methods' => PaymentMethod::getDefaultAsArray()->toArray(),
];
return view('web.promotion.index', $data);
}
public function goto($load, $id){
$PromotionUser = PromotionUser::findOrFail($id);
$data = [
'promotion_user' => $PromotionUser,
];
if($load === 'thanksreminder'){
return view('web.promotion.thanksreminder', $data);
}
if($load === 'thanksorder'){
return view('web.promotion.thanksorder', $data);
}
if($load === 'notactive'){
return view('web.promotion.notactive', $data);
}
}
public function store($id){
$PromotionUser = PromotionUser::findOrFail($id);
$data = Request::all();
if(!isset($data['action'])){
abort(402);
}
if($data['action'] === 'submit-reminder-service'){
return redirect(route('web_promotion_goto', ['thanksreminder', $PromotionUser->id]));
}
if($data['action'] === 'submit-promotion-order'){
return redirect(route('web_promotion_goto', ['thanksorder', $PromotionUser->id]));
}
dd($PromotionUser);
}
public function load(){
$data = Request::all();
$ret = "";
$status = false;
if(Request::ajax()){
if($data['action'] === 'web-show-product'){
$product = Product::find($data['id']); //current user form order
$ret = view("web.promotion.show_product", compact('product', 'data'))->render();
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
}
}
}