Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Abu-Salah-Musha-Lemon committed Aug 5, 2024
1 parent f90810a commit 46c6b8c
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 32 deletions.
60 changes: 54 additions & 6 deletions app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use App\Models\category;
use App\Models\subcategory;
use App\Models\product;
use App\Models\Card;
use Illuminate\Support\Facades\Auth;

class ClientController extends Controller
{

Expand Down Expand Up @@ -37,23 +40,68 @@ public function singleProduct($id) {
}

public function addToCart(){
$user_id = Auth::id();
$items = Card::where('user_id',$user_id)->get();
return view('userTemp.addToCard',compact('items'));
}

return view('userTemp.singlePage');
public function addProductToCart(Request $request, $id) {
$product_qty = Product::where('id', $id)->value('product_quantity');
$requested_qty = $request->input('quantity');

if ($requested_qty > $product_qty) {
// Redirect back with an error message
return redirect()->back()->with([
'message' => 'Product quantity exceeds the stock available.',
'alert-type' => 'error'
]);
}
// echo '<pre>';
// echo '<pre>';
$product_qty = $request->input('product_qty');
$product_price = $request->input('product_price');
$product_new_price = $product_qty * $product_price;
// echo $product_new_price;exit;

Card::create([
'user_id'=>Auth::id(),
'product_id'=>$request->product_id,
'product_quantity'=>$request->product_qty,
'product_price'=>$product_new_price,
]);

// Proceed with adding the product to the cart
// Your cart logic here

return redirect()->back()->with([
'message' => 'Product added to cart successfully!',
'alert-type' => 'success'
]);
}
public function checkout(){
return view('userTemp.checkOut');
return view('userTemp.checkOut');
}

public function userProfile(){
return view('userTemp.userProfile');
return view('userTemp.userProfile');
}
public function pendingOrder(){
return view('userTemp.pendingOrder');
}
public function userHistory(){
return view('userTemp.userHistory');
}

public function newRelease(){
return view('userTemp.newRelease');
return view('userTemp.newRelease');
}

public function todaysDeal(){
return view('userTemp.todaysDeal');
return view('userTemp.todaysDeal');
}

public function customerService(){
return view('userTemp.customerService');
return view('userTemp.customerService');
}


Expand Down
12 changes: 12 additions & 0 deletions app/Models/Card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Card extends Model
{
use HasFactory;
protected $fillable = ['user_id', 'product_id', 'product_qty', 'product_price'];
}
31 changes: 31 additions & 0 deletions database/migrations/2024_08_04_020350_create_cards_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cards', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('product_id');
$table->integer('product_qty');
$table->decimal('product_price', 8, 2); // Make sure this matches your actual use case
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cards');
}
};
51 changes: 49 additions & 2 deletions resources/views/userTemp/addToCard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,55 @@

@section('main')

<div class="fashion_section">
<h4>Add to card</h4>


<div class="fashion_section" style="margin-top:10px">
<div id="electronic_main_slider" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container">
<h1 class="fashion_taital"> </h1>
<div class="fashion_section_2">

<div class="row">

<div class="col-lg-12 col-sm-4">
<div class="box_main">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Product Name</th>
<th scope="col">Product qty</th>
<th scope="col">Product Price</th>
<th scope="col">Product action</th>
</tr>
</thead>
<tbody>
@php $sr =1;@endphp
@foreach( $items as $item)
<tr>
<th scope="row">{{$sr++}}</th>
<td>{{$item->product_quantity}}</td>

<td>{{$item->product_quantity}}</td>
<td>{{$item->product_price}}</td>
<td><a href="#" class="btn btn-warning">remove</a></td>

</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>

</div>
</div>
</div>
</div>
</div>
</div>


@endsection
21 changes: 15 additions & 6 deletions resources/views/userTemp/categoryPage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,35 @@
<div class="fashion_section_2">
<div class="row">

@foreach ($product as $items)
<div class="col-lg-4 col-sm-4">
@foreach ($product as $items)
<div class="col-lg-4 col-sm-4">
<div class="box_main">
<h4 class="shirt_text">{{$items->product_name}}</h4>
<p class="price_text">Start Price <span style="color: #262626;">$ {{$items->product_price}}</span></p>
<div class="electronic_img"><img src="{{ asset('products/' . $items->product_img) }}" alt="{{ $items->product_name }}">
<div class="electronic_img"><img src="{{ asset('products/' . $items->product_img) }}"
alt="{{ $items->product_name }}">
</div>
<div class="btn_main">
<div class="buy_bt"><a href="#">Buy Now</a></div>
<div class="buy_bt">

<form action="{{ route('addProductToCart', $items->id) }}" method="post">
@csrf
<input type="hidden" name="product_id" value="{{ $items->id }}">
<input type="submit" class="btn btn-warning" value="Buy Now">
</form>

</div>
<div class="seemore_bt"><a href="{{route('singleProduct',$items->id)}}">See More</a></div>
</div>
</div>
</div>
@endforeach

</div>
</div>
</div>
</div>

</div>
</div>
</div>
Expand Down
21 changes: 15 additions & 6 deletions resources/views/userTemp/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,34 @@
<div class="fashion_section_2">
<div class="row">

@foreach ($product as $items)
<div class="col-lg-4 col-sm-4">
@foreach ($product as $items)
<div class="col-lg-4 col-sm-4">
<div class="box_main">
<h4 class="shirt_text">{{$items->product_name}}</h4>
<p class="price_text">Start Price <span style="color: #262626;">$ {{$items->product_price}}</span></p>
<div class="electronic_img"> <img src="{{ asset('products/' . $items->product_img) }}" alt="{{ $items->product_name }}"></div>
<div class="electronic_img"> <img src="{{ asset('products/' . $items->product_img) }}"
alt="{{ $items->product_name }}"></div>
<div class="btn_main">
<div class="buy_bt"><a href="#">Buy Now</a></div>
<div class="buy_bt">

<form action="{{ route('addProductToCart', $items->id) }}" method="post">
@csrf
<input type="hidden" name="product_id" value="{{ $items->id }}">
<input type="submit" class="btn btn-warning" value="Buy Now">
</form>

</div>
<div class="seemore_bt"><a href="{{route('singleProduct',$items->id)}}">See More</a></div>
</div>
</div>
</div>
@endforeach

</div>
</div>
</div>
</div>

</div>
</div>
</div>
Expand Down
34 changes: 34 additions & 0 deletions resources/views/userTemp/layout/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<!-- font awesome -->
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- -->
<!-- toster -->
<link rel="stylesheet" href="{{asset('customcssjs/toster.min.css')}}" />
<link rel="stylesheet" href="{{asset('customcssjs/bootstrap-icons.min.css')}}" />


<!-- owl stylesheets -->
<link href="https://fonts.googleapis.com/css?family=Great+Vibes|Poppins:400,700&display=swap&subset=latin-ext" rel="stylesheet">
<link rel="stylesheet" href="{{asset('userTemp/css/owl.carousel.min.css')}}">
Expand Down Expand Up @@ -234,5 +239,34 @@ function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>

<!-- /* Toastr Notifications */ -->
<script src="{{asset('customcssjs/toster.min.js')}}"></script>
<script>
/* Toastr Notifications */
$(document).ready(function () {
@if (Session:: has('message'))
var type = "{{ Session::get('alert-type', 'info') }}";
switch (type) {
case 'info':
toastr.info("{{ Session::get('message') }}");
break;
case 'success':
toastr.success("{{ Session::get('message') }}");
break;
case 'warning':
toastr.warning("{{ Session::get('message') }}");
break;
case 'danger':
toastr.warning("{{ Session::get('message') }}");
break;
case 'error':
toastr.error("{{ Session::get('message') }}");
break;
}
@endif
});
</script>

</body>
</html>
49 changes: 49 additions & 0 deletions resources/views/userTemp/layout/user.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@extends('userTemp.layout.layout')

@section('main')
<style>
.txl {
text-align: left;
}
</style>
<!-- fashion section start -->
<div class="fashion_section" style="margin-top:10px">
<div id="electronic_main_slider" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container">
<h1 class="fashion_taital"> USER </h1>
<div class="fashion_section_2">

<div class="row">
<!-- Display the current product details -->

<div class="col-lg-3 col-sm-3">
<div class="box_main">
<ul>

<li><a href="{{route('userProfile')}}">Dashboard</a></li>
<li><a href="{{route('pendingOrder')}}">Pending Order</a></li>
<li><a href="{{route('userHistory')}}">History</a></li>
</ul>
</div>
</div>

<div class="col-lg-8 col-sm-4">
<div class="box_main">
@yield('userProfile')
</div>
</div>

</div>

</div>
</div>
</div>
</div>
</div>




@endsection
8 changes: 8 additions & 0 deletions resources/views/userTemp/pendingOrder.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@extends('userTemp.layout.user')

@section('userProfile')


<h4>Pending Order</h4>

@endsection
Loading

0 comments on commit 46c6b8c

Please sign in to comment.