
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Based on the actual presentation and the report, the student presents parts: -Users’ requirements/User Story (page 3-4); ERD (page 5) ;Sitemap (page 4) ; GitHub repository; Images of final application; Demonstrates his/her part in the project and shows the source code and explain how it works (migration, model,table, controller, view, routes ); CRUD of application(order, checkout), relationships between tables;login/ register; authorization; -The student needs to evaluate more about: Implement API/ Javascript; -Individual score: 8, excluding group report score: 8.5 (group report score accounts for 30%)
Typology: Assignments
1 / 40
This page cannot be seen from the preview
Don't miss anything!

































Summative Feedback: Resubmission Feedback:
- Because the user needs to filter products by category, so that they can quickly find products
- Because the user needs to add products to their shopping, Carts that they can keep track of
- Because the user needs to track their orders, so that they can see the status of their orders
- Because the guest needs to see the home page of the store, so that they can view information
- Because the guest needs to register an account to become a member, so that they can access
- Because the guest needs to log in to their account, so that they can access their profile and
$table->timestamps(); ///foreign key $table->foreign('cart_ID')->references('id')->on('carts')- >onDelete('cascade'); $table->foreign('product_ID')->references('id')->on('products')- >onDelete('cascade'); }); } /**
use Illuminate\Database\Eloquent\Model; use App\Models\Category; use App\Models\Order; use App\Models\Cart; class Product extends Model { use HasFactory; protected $table = 'products'; protected $fillable = [ 'name','quantity','image', 'price', 'description' ]; public function categories() { return $this->belongsToMany(Category::class, 'category_product')- >withTimestamps(); } public function orders() { return $this->belongsToMany(Order::class, 'order_product')->withTimestamps()- >withPivot('quantity'); } public function carts() { return $this->belongsToMany(Cart::class, 'order_product')->withTimestamps()- >withPivot('quantity'); } } I will then design the models to hold all the relevant data and return types while using the data in the Controller. Here is an example of how I created the product model and its related data such as belonging, data table to populate and where to get the data.
use App\Models\CartProduct; use App\Models\OrderProduct; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; class OrderController extends Controller { /**
public function checkout(Request $request) { $user_id = Auth::user()->id; $order['user_ID'] = $user_id; $order['total'] = $request['total']; $order['status'] = 0 ; $cart = Cart::where('user_id', '=', $user_id)->get(); if ($order['total'] != 0 ) { // save order $order = Order::create($order); $cartProducts = CartProduct::where('cart_ID', '=', $cart[ 0 ]->id)->get(); foreach ($cartProducts as $cartProduct) { $orderProduct['order_ID'] = $order['id']; $orderProduct['product_ID'] = $cartProduct['product_ID']; $orderProduct['quantity'] = $cartProduct['quantity']; OrderProduct::create($orderProduct); $cartProduct->delete(); } } return view('cart.detail', compact('cart')); } /**
Back
ID User_ID Address Phone Status {{-- Created At Updated At --}} Action
@foreach ($orders as $order)
{{ $order->id }} {{ $order->user_ID }} {{ $order->address }} {{ $order->phone }}
@if ($order->status == 0 )
Canceled
@endif
@if ($order->status == 0 )
@csrf @method('put')
Confirm Payment
@endif @if ($order->status == 1 )
@csrf @method('put')
Confirm Delivered
@endif
@endforeach
@if ($orders->links())
{{ $orders->links() }}
@endif
After creating the order, the web owner can check to see if there are orders by whom and where. In addition, they can adjust the status and confirm the order has been delivered.
Items: {{ $items }}
Tax (5%): $ {{ $tax = ($total / 100 ) * 5 }}
Total:
{{ $order->total }}
@if ($order->status == 0 )
Pending
@elseif($order->status == 1 )
Accecpted
@elseif($order->status == 2 )
Delivered
@elseif($order->status == 3 )