Uploaded by waqasahmadmir123

Lab Terminal Report (FA19-BCS-087)

advertisement
Lab Terminal Report
Web Technologies
Submitted by:
Waqas Ahmad (FA19-BCS-087/ISB)
Submitted to:
Sir Waseem Abbas
Submission Date:
18-01-22
BSCS-5B (2019 - 2023)
Department of Computer Science, CU, Islamabad
Outputs (User Side):
Login:
Register:
Contact US
Menu:
Outputs (Admin Side):
Added Items:
Added Items:
Code Section
AdminController:
<?php
namespace App\Http\Controllers;
use App\Models\Admin;
use App\Models\items;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AdminController extends Controller
{
public function forsubmit(Request $request)
{
$admin = new Admin();
$admin->name = $request->input('name');
$admin->email = $request->input('email');
$admin->password = $request->input('password');
$admin->save();
}
public function AboutAdmin()
{
$about = Admin::all();
return view('aboutAdmin', compact('about'));
}
public function loginvalidation(Request $request){
$email=$request->input("email");
$password=$request->input("password");
$check= Admin::where('email',$email)->first();
if( $check->email==$email && $check->password==$password ) {
return view('adminHome',compact('check'));
}
else{
$error='This Admin is not in database';
return view('login')->with('error',$error);
}
}
public function resetpass($id){
$item=Admin::find($id);
return view ('resetpassword',compact('item'));
}
public function
reset($id ,Request $request){
$item=Admin::find($id);
$pass=$request->input('password');
$pass2=$request->input('password2');
if( $pass==$pass2 ) {
$item->password=$request->input('password');
$item->save();
$admin=Admin::find($id);
return view ('adminHome',compact('admin'));
return view('adminHome',compact('admin'));
}
else{
$error='Password Not match';
return view('resetpassword',compact('item'))>with('error',$error);
}
}
public function update_admin($id){
$admin=Admin::find($id);
return view ('updateAdmin',compact('admin'));
}
public function update($id,Request $request){
$item=Admin::find($id);
$item->name=$request->input('name');
$item->email=$request->input('email');
$item->password=$request->input('password');
$item->save();
$admin=Admin::find($id);
return view ('adminHome',compact('admin'));
}
}
OrderController:
<?php
namespace App\Http\Controllers;
use App\Models\Order;
use Illuminate\Http\Request;
class OrderController extends Controller
{
public function add_order(Request $request)
{
$order = new Order();
$order->name = $request->input('name');
$order->contact = $request->input('contact');
$order->address = $request->input('address');
$order->itemname = $request->input('iname');
$order->price = $request->input('price');
$order->quantity = $request->input('quantity');
$order->total = $request->input('total');
$order->save();
return redirect()->back();
}
public function view_orders(){
$orders=Order::all();
return view ('viewOrder',compact('orders'));
}
public function delete_order($id){
$item=Order::find($id);
$item->delete();
return redirect()->back();
}
}
UserController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\user;
use Illuminate\Support\Facades\Auth;
class userController extends Controller
{
public function add_user(Request $request){
$users=new user();
$users->uname=$request->input('name');
$users->uemail=$request->input('email');
$users->contact=$request->input('contact');
$users->address=$request->input('address');
$users->password=$request->input('password');
$users->save();
return view('userlogin');
}
public function showUsers(){
$customer=user::all();
return view ('customers',compact('customer'));
}
public function loginvalidation(Request $request){
$email=$request->input("email");
$password=$request->input("password");
$check= user::where('uemail',$email)->first();
if( $check->uemail==$email && $check->password==$password ) {
return view('order',compact('check'));
}
else{
$error='Invalid password or Email';
return view('userlogin')->with('error',$error);
}
}
}
ItemController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\items;
use App\Models\user;
class itemController extends Controller
{
public function aditems(Request $request){
$item=new items();
$item->item_name=$request->input('iname');
$item->item_ingrediants=$request->input('ingarediant');
$item->price=$request->input('price');
$item->image=$request->input('image');
$item->save();
return view('adminHome');
}
public function view_item(){
$view_all=items::all();
return view ('view_Items',compact('view_all'));
}
public function for_order($id){
$items=items::all();
$user=user::find($id);
return view ('orderplace',compact('items'),compact('user'));
}
public function delete_item($id){
$item=items::find($id);
$item->delete();
return redirect()->back();
}
public function updateitems($id){
$item=items::find($id);
return view ('updateitem',compact('item'));
}
public function update($id ,Request $request){
$item=items::find($id);
$item->item_name=$request->input('iname');
$item->item_ingrediants=$request->input('ingarediant');
$item->price=$request->input('price');
$item->image=$request->input('image');
$item->save();
return view("adminHome");
}
public function ordering($itemid,$userid){
$item=items::find($itemid);
$user=user::find($userid);
return view ('finalorder',compact('item'),compact('user'));
}
}
ContactController:
<?php
namespace App\Http\Controllers;
use App\Models\Contact;
use Illuminate\Http\Request;
class contactController extends Controller
{
public function submitContact(Request $request){
$contacts=new Contact();
$contacts->fname=$request->input('fname');
$contacts->lname=$request->input('lname');
$contacts->address=$request->input('address');
$contacts->message=$request->input('message');
$contacts->save();
return view('order');
}
public function show_Contacts(){
$showContact=Contact::all();
return view ('view_ContactUs',compact('showContact'));
}
}
Models
Admin Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Admin extends Model
{
use HasFactory;
protected $table='admin';
protected $fillable=[
'name',
'email',
'password',
];
}
Contact Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Contact extends Model
{
use HasFactory;
protected $table='contactus';
protected $fillable=[
'fname',
'lname',
'address',
'message',
];
}
Item Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class items extends Model
{
use HasFactory;
protected $table='food_item';
protected $fillable=[
'image',
'item_name',
'item_ingrediants',
'price',
];
}
Order Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasFactory;
protected $table='_order';
protected $fillable=[
'name',
'contact',
'address',
'itemname',
'price',
'quantity',
'total',
];
}
User Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class user extends Model
{
use HasFactory;
protected $table='user';
protected $fillable=[
'uname',
'uemail',
'contact',
'address',
'password',
];
}
Views ss:
Download