Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 13 additions & 55 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\Cart;
use App\Models\User;
use DB;
use Auth;
use Hash;
Expand Down Expand Up @@ -100,83 +101,48 @@ public function chefs()
}
public function order_incomplete()
{


// dd($orders);

$orders=DB::table('carts')->where('product_order','yes')
->groupBy('invoice_no')
// dd($orders);
$orders=Cart::join('users','users.id','=','carts.user_id')->where('carts.product_order','yes')->where('users.usertype','0')
->groupBy('carts.invoice_no')
->get();



$adminOrders = Cart::join('users','users.id','=','carts.user_id')
->where('carts.product_order','yes')
->where('users.usertype','!=','0')->update(['carts.product_order'=>'approve']);
return view('admin.incomplete-orders',compact('orders'));



}
public function order_complete()
{


// dd($orders);

// dd($orders);
$orders=DB::table('carts')->where('product_order','delivery')
->groupBy('invoice_no')
->get();


return view('admin.complete_orders',compact('orders'));



return view('admin.complete_orders',compact('orders'));
}
public function reservation()
{


$reservations=DB::table('reservations')->get();


return view('admin.reservations',compact('reservations'));




}

public function add_menu()
{

return view('admin.add_menu');

return view('admin.add_menu');
}
public function add_chef()
{


return view('admin.add_chef');


}
public function coupon_show()
{

$coupons=DB::table('coupons')->get();


return view('admin.coupons',compact('coupons'));


}
public function admin_show()
{

$admins=DB::table('users')->where('usertype','1')->orWhere('usertype','3')->get();


return view('admin.admins',compact('admins'));


}
public function user_show()
{
Expand Down Expand Up @@ -230,17 +196,11 @@ public function banner_add()
public function menu_add_process(Request $req)
{


if($req->price < 0)
{

session()->flash('wrong','Negative Price value do not accept !');
session()->flash('wrong','Negative Price value do not accept !');
return back();


}


$this->validate(request(),[

'image'=>'mimes:jpeg,jpg,png',
Expand Down Expand Up @@ -273,8 +233,6 @@ public function menu_add_process(Request $req)
public function chef_add_process(Request $req)
{



$this->validate(request(),[

'image'=>'mimes:jpeg,jpg,png',
Expand Down
104 changes: 14 additions & 90 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -1,155 +1,79 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Auth;

use DB;
use PDF;
use Hash;


use Session;




use App\Models\Cart;
class HomeController extends Controller
{
public function index(){

$menu=DB::table('products')->where('catagory','regular')->get();

$breakfast=DB::table('products')->where('catagory','special')->where('session',0)->get();
$lunch=DB::table('products')->where('catagory','special')->where('session',1)->get();
$dinner=DB::table('products')->where('catagory','special')->where('session',2)->get();

$chefs=DB::table('chefs')->get();


if(Auth::user())
{

$cart_amount=DB::table('carts')->where('user_id',Auth::user()->id)->where('product_order','no')->count();


$cart_amount=DB::table('carts')->where('user_id',Auth::user()->id)->where('product_order','no')->count();
}
else
{

$cart_amount=0;

$cart_amount=0;
}

$about_us=DB::table('about_us')->get();
$banners=DB::table('banners')->get();



return view("home",compact('menu','breakfast','lunch','dinner','chefs','cart_amount','about_us','banners'));
}

public function redirects(){


if(!Auth::user())
{

return redirect()->route('login');


return redirect()->route('login');
}


$menu=DB::table('products')->where('catagory','regular')->get();

$breakfast=DB::table('products')->where('catagory','special')->where('session',0)->get();
$lunch=DB::table('products')->where('catagory','special')->where('session',1)->get();
$dinner=DB::table('products')->where('catagory','special')->where('session',2)->get();


$chefs=DB::table('chefs')->get();


if(Auth::user())
{

$cart_amount=DB::table('carts')->where('user_id',Auth::user()->id)->where('product_order','no')->count();


$cart_amount=DB::table('carts')->where('user_id',Auth::user()->id)->where('product_order','no')->count();
}
else
{

$cart_amount=0;

$cart_amount=0;
}



$about_us=DB::table('about_us')->get();
$banners=DB::table('banners')->get();


$usertype= Auth::user()->usertype;
if($usertype!='0')
{

$pending_order=DB::table('carts')->where('product_order','yes')->groupBy('invoice_no')->count();

$processing_order=DB::table('carts')->where('product_order','approve')->groupBy('invoice_no')->count();

$cancel_order=DB::table('carts')->where('product_order','cancel')->groupBy('invoice_no')->count();

$complete_order=DB::table('carts')->where('product_order','delivery')->groupBy('invoice_no')->count();


$pending_order=DB::table('carts')->where('product_order','yes')->groupBy('invoice_no')->get();
$processing_order=DB::table('carts')->where('product_order','approve')->groupBy('invoice_no')->get();
$cancel_order=DB::table('carts')->where('product_order','cancel')->groupBy('invoice_no')->get();
$complete_order=DB::table('carts')->where('product_order','delivery')->groupBy('invoice_no')->get();
$total=DB::table('carts')->sum('subtotal');


$cash_on_payment=DB::table('carts')->where('pay_method','Cash On Delivery')->sum('subtotal');


$online_payment=$total-$cash_on_payment;


$customer=DB::table('users')->where('usertype','0')->count();


$delivery_boy=DB::table('users')->where('usertype','2')->count();


$user=DB::table('users')->count();


$admin=$user-($customer + $delivery_boy);


$customer=DB::table('users')->where('usertype','0')->get();
$delivery_boy=DB::table('users')->where('usertype','2')->get();
$user=DB::table('users')->get();
$admin=($user->count())-($customer->count() + $delivery_boy->count());
$rates=DB::table('rates')->get();

$product=array();


foreach($rates as $rate)
{


$product[$rate->product_id]=0;
$voter[$rate->product_id]=0;
$per_rate[$rate->product_id]=0;



}



foreach($rates as $rate)
{


$product[$rate->product_id]=$product[$rate->product_id]+ $rate->star_value;


Expand Down
4 changes: 4 additions & 0 deletions app/Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ class Cart extends Model
protected $fillable = [
'name', 'price', 'quantity', 'subtotal'
];
public function CartUser(){
return $this->belongsTo('App\Models\User', 'user_id', 'id');

}
}
12 changes: 6 additions & 6 deletions resources/views/admin/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="row">
<div class="col-9">
<div class="d-flex align-items-center align-self-start">
<h3 class="mb-0">Amount : {{ $pending_order }}</h3>
<h3 class="mb-0">Amount : {{ $pending_order->count() }}</h3>
<p class="text-success ms-2 mb-0 font-weight-medium"></p>
</div>
</div>
Expand All @@ -32,7 +32,7 @@
<div class="row">
<div class="col-9">
<div class="d-flex align-items-center align-self-start">
<h3 class="mb-0">Amount : {{ $processing_order }}</h3>
<h3 class="mb-0">Amount : {{ $processing_order->count() }}</h3>
<p class="text-success ms-2 mb-0 font-weight-medium"></p>
</div>
</div>
Expand All @@ -52,7 +52,7 @@
<div class="row">
<div class="col-9">
<div class="d-flex align-items-center align-self-start">
<h3 class="mb-0">Amount : {{ $cancel_order }}</h3>
<h3 class="mb-0">Amount : {{ $cancel_order->count() }}</h3>
<p class="text-danger ms-2 mb-0 font-weight-medium"></p>
</div>
</div>
Expand All @@ -72,7 +72,7 @@
<div class="row">
<div class="col-9">
<div class="d-flex align-items-center align-self-start">
<h3 class="mb-0">Amount : {{ $complete_order }}</h3>
<h3 class="mb-0">Amount : {{ $complete_order->count() }}</h3>
<p class="text-success ms-2 mb-0 font-weight-medium"></p>
</div>
</div>
Expand Down Expand Up @@ -232,7 +232,7 @@
<div class="row">
<div class="col-8 col-sm-12 col-xl-8 my-auto">
<div class="d-flex d-sm-block d-md-flex align-items-center">
<h2 class="mb-0">{{ $customer }}</h2>
<h2 class="mb-0">{{ $customer->count() }}</h2>
<p class="text-success ms-2 mb-0 font-weight-medium"></p>
</div>
<h6 class="text-muted font-weight-normal"></h6>
Expand All @@ -251,7 +251,7 @@
<div class="row">
<div class="col-8 col-sm-12 col-xl-8 my-auto">
<div class="d-flex d-sm-block d-md-flex align-items-center">
<h2 class="mb-0">{{ $delivery_boy }}</h2>
<h2 class="mb-0">{{$delivery_boy->count() }}</h2>
<p class="text-success ms-2 mb-0 font-weight-medium"></p>
</div>
<h6 class="text-muted font-weight-normal"></h6>
Expand Down
6 changes: 0 additions & 6 deletions resources/views/admin/incomplete-orders.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
@extends('admin/adminlayout')

@section('container')






<div class="row ">
<div class="col-12 grid-margin">
<div class="card">
Expand Down
4 changes: 3 additions & 1 deletion resources/views/admin/invoice_details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<tbody>

@foreach($products as $product)
@if($product->product_order=="yes")
<tr>


Expand Down Expand Up @@ -167,8 +168,9 @@
<input type="datetime-local" name="time" value="2022-07-28T19:30" class="form-control" id="exampleInputName1">
</div>


@if($user->usertype == 0)
<button type="submit" class="btn btn-primary me-2">Approve Order</button>
@endif
<a href="{{ asset('/invoice/cancel-order/'.$product->invoice_no) }}" class="btn btn-danger">Cancel Order</a>
</form>

Expand Down
Loading