User Order step1
This commit is contained in:
parent
eb55b01b0d
commit
a5db985ae8
90 changed files with 6439 additions and 421 deletions
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue