9/8/22
####################################################Homepage Controller:
<?php
namespace App\Http\Controllers;
use App\Mail\GeneralMail;
use App\Models\Author;
use App\Models\Banner;
use App\Models\Blog;
use App\Models\BookRequest;
use App\Models\Category;
use Illuminate\Http\Request;
use App\Traits\GeneralTrait;
use Illuminate\Support\Facades\DB;
use App\Models\User;
use App\Models\Coupon;
use App\Models\Product;
use App\Models\RecentlyViewed;
use App\Models\ShoppingCart;
use App\Models\Store;
use Exception;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Eloquent\Collection;
class HomepageController extends Controller
{
use GeneralTrait;
//
public function __construct()
{
if(session()->has('user.id'))
{
config()->set(['items_in_cart' => ShoppingCart::where('user_id', session()->get('user.id'))->count()]);
}
elseif(session()->has('cart.session_id'))
{
config()->set(['items_in_cart' => ShoppingCart::where('cart_session_id', session()->get('cart.session_id'))->count()]);
}
else
{
config()->set(['items_in_cart' => 0]);
}
}
public function index()
{
$data['pageheader'] = "Home";
$data['bestsellers'] = '';
$data['banners'] = Banner::where('status', 'A')->get();
$data['newreleases'] = Product::where('status', 'A')->orderBy('created_at', 'DESC')->get();
$data['featured_products'] = Product::where('status', 'A')->where('is_featured', 1)->get();
$data['recentsolds'] = '';
$data['featured_authors'] = Author::where('status', 'A')->where('is_featured', 1)->get();
return view('frontend.index', $data);
//Dashboard
}
public function product_details(Request $request)
{
$data['pageheader'] = "Product Detail";
$this->recently_viewed($request); //Adding to recently viewed table
$data['product'] = Product::where('slug', $request->slug)->where('status', 'A')->first();
// $data['types'] = DB::table('attribute_category_product')
// ->join('category_attribute', 'attribute_category_product.attribute_category_id', '=', 'category_attribute.id')
// ->join('products', 'attribute_category_product.product_id', '=', 'products.id')
// ->join('attributes', 'category_attribute.attribute_id', '=', 'attributes.id')
// ->where('attributes.title', 'Type')
// ->select('attribute_category_product.attribute_value')
// ->get();
// // ->pluck('attribute_category_product.attribute_value');
// dd($data['types']);
if($request->session()->has('user.id'))
$data['recents'] = RecentlyViewed::where('user_id', $request->session()->get('user.id'))->orderBy('updated_at', 'DESC')->with('products')->take(10)->get();
else
$data['recents'] = RecentlyViewed::where(['visitor_ip'=> $request->ip(), 'user_id'=> null])->orderBy('updated_at', 'DESC')->with('products')->take(10)->get();
//dd($data);
return view('frontend.product-details', $data);
//Dashboard
}
public function product_listing()
{
$data['pageheader'] = "Product List";
return view('frontend.product-listing', $data);
//Dashboard
}
public function validate_user(Request $request)
{
// dd($request->all());
$u_id = decrypt($request->_utoken);//decrypting to get email
$user = User::where('email', $u_id)->get();
$u = $user->first();
// if(!empty($user->items))//Had been created earlier, but can't rember why
if(!empty($user))
{
if($u->email_verified_at == null)
{
$u->email_verified_at = date("Y-m-d h:i:s");
$u->save();
if($u->role_id == 1)
return redirect()->route('customer.login')->with('success', 'Customer account verified'); //should redirect to customer login
elseif($u->role_id == 2)
return redirect()->route('login')->with('success', 'Admin account verified'); //Admin page
}
else if(!$u->email_verified_at == null)
{
return redirect()->route('customer.login')->with('success', 'Account was already verified');
}
}
else
{
dump('User does not exist');
return abort(500); //User not found
}
}
public function redeem_coupon(Request $request)
{
auth()->user;$request->code;
$coupon = Coupon::where('code', $request->code)->first();
if($coupon->status == "A")//Coupon can still be redeemed
{
if(date('Y-m-d h:i:s') >= $coupon->start_date && date('Y-m-d h:i:s') <= $coupon->end_date)//Within start and end date
{
if($coupon->coupon_type == 'single')
{
//assign coupon to user and deactivate coupon
}
elseif($coupon->coupon_type == 'multiple')
{
//count how many times coupon already redeemed from middle table
}
}
else
{
return response()->json(['status' => 'Coupon expired'], 400);
}
}
else
{
return response()->json(['status' => 'Coupon not active'], 400);
}
}
public function getsearchdata(Request $request)
{
$value = $request->val;
$category_id = $request->cat_id;
$pro_arr=[];
// $pro = Product::where('status', 'A')->where('name','LIKE','%'.$value.'%')->skip(0)->take(10)->get();
$pro = Product::where('status', 'A')/*->where('category_id', $category_id)*/->where('name','LIKE','%'.$value.'%')->take(10)->get();
$arr=$pro;
if(!empty($arr)){
foreach($arr as $row){
$pro_arr[]=$row->name;
}
}
echo json_encode($pro_arr);
}
public function search_get(Request $request)
{
$data['pageheader'] = "Search Result";
try{
$search_category = $request->filled('search_category')?$request->search_category : 'empty';
$search_name = $request->filled('search_name')?$request->search_name : 'empty';
$record_per_page = 32;
if($search_category == 'Books')
{
$results = Product::where('name', 'LIKE', '%'.$search_name.'%')->where('status', 'A'); //category's logic will be their
if(!empty($results))
{
$data['highest_price'] = Product::orderBy('price', 'DESC')->first()->price;
$data['lowest_price'] = Product::orderBy('price', 'ASC')->first()->price;
}
}
elseif($search_category == 'Authors')
{
$authors = Product::whereLike(['authors.name'], $search_name);//DB::Query being used not Eloquent
if(empty($authors))
{}
else
{
$results = $authors;
$data['highest_price'] = Product::orderBy('price', 'DESC')->first()->price;//This needs to be changed
$data['lowest_price'] = Product::orderBy('price', 'ASC')->first()->price;
}
}
elseif($search_category == 'Publishers')
{
$publishers = Product::whereLike(['publishers.name'], $search_name);//DB::Query being used not Eloquent
if(empty($publishers))
{}
else
{
$results = $publishers;
$data['highest_price'] = Product::orderBy('price', 'DESC')->first()->price;//This needs to be changed
$data['lowest_price'] = Product::orderBy('price', 'ASC')->first()->price;
}
}
elseif($search_category == 'Stationeries')
{
$results = Product::where('name', 'LIKE', '%'.$search_name.'%')->where('status', 'A');
if(!empty($results))
{
$data['highest_price'] = Product::orderBy('price', 'DESC')->first()->price;
$data['lowest_price'] = Product::orderBy('price', 'ASC')->first()->price;
}
}
else
{
dd('Nothing provided in Search category');
}
}
catch(Exception $e1)
{
dd($e1->getMessage());
}
$data['categories'] = Category::where('status', 'A')->where('parent_id', 0)->get();
$data['results'] = $results->paginate($record_per_page);
$data['page_type'] = 'search';
return view('frontend.product-listing', $data);
}
public function filter(Request $request)
{
// dd($request->All());
$search_category = $request->filled('search_category')?$request->search_category : 'empty';
$search_name = $request->filled('search_name')?$request->search_name : 'empty';
$record_per_page = 32;
if($search_category == 'Books')
{
$results = Product::where('name', 'LIKE', '%'.$search_name.'%')->where('status', 'A'); //category's logic will be their
if(!empty($results))
{
$data['highest_price'] = Product::orderBy('price', 'DESC')->first()->price;
$data['lowest_price'] = Product::orderBy('price', 'ASC')->first()->price;
}
if(isset($request->price_range_start) && isset($request->price_range_end))
{
$results = $results->whereBetween('price', [$request->price_range_start, $request->price_range_end]);
}
}
$data['categories'] = Category::where('status', 'A')->where('parent_id', 0)->get();
$data['results'] = $results->paginate($record_per_page);
$data['page_type'] = 'filter';
return view('partials.filter_data', $data);
}
public function listing(Request $request)
{
$record_per_page = 32;
if($request->type == "new-releases")
{
$data['pageheader'] = "New Releases";
$results = Product::where('status', 'A')->orderBy('created_at', 'DESC');
}
elseif($request->type == "bestsellers")
{
$data['pageheader'] = "Best Sellers";
$results = '';
}
elseif($request->type == "featured-books")
{
$data['pageheader'] = "Featured Books";
$results = Product::where('status', 'A')->where('is_featured', 1);
}
elseif($request->type == "recently-sold")
{
$data['pageheader'] = "Recently Sold";
$results = '';
}
$data['categories'] = Category::where('status', 'A')->where('parent_id', 0)->get();
$data['results'] = $results->paginate($record_per_page);
$data['page_type'] = $request->type;
return view('frontend.product-listing', $data);
}
public function book_request()
{
$data['pageheader'] = "Book Request";
return view('frontend.book-request', $data);
}
public function book_request_post(Request $request)
{
$data['pageheader'] = "Book Request";
$rules=[
'name' => 'required',
'email' => 'required|email',
'city' => 'required',
'phone' => 'required|min:9',
'book_title' => 'required',
'author_name' => 'required',
'book_info' => 'required',
];
$validator = Validator::make($request->All(), $rules);
if($validator->fails()){
foreach($validator->errors()->messages() as $key => $value){
return response()->json([ 'status' => $value[0]], 400);
}
}
try{
$res = BookRequest::create($request->All());
$txt = '';
$txt .= '<p>Book Request Submitted Successfully</p>';
$txt .= '<p><strong>Customer Name: </strong>'.$request->name.'</p>';
$txt .= '<p><strong>Customer Email: </strong>'.$request->email.'</p>';
$txt .= '<p><strong>Customer City: </strong>'.$request->city.'</p>';
$txt .= '<p><strong>Customer Phone: </strong>'.$request->phone.'</p>';
$txt .= '<p><strong>Book Title: </strong>'.$request->book_title.'</p>';
$txt .= '<p><strong>Author Name: </strong>'.$request->author_name.'</p>';
$txt .= '<p><strong>Book Information: </strong>'.$request->book_info.'</p>';
//$txt .= URL::to("validate-user/?_token=".encrypt($request->email));
$subject = 'Book Request - '.config()->get('app.name');
$mailFromId = config()->get('mail.from.address');
// return (new GeneralMail('Admin', $mailFromId, $txt, $subject))->render();
Mail::to($request->email)->send(new GeneralMail($request->name, $mailFromId, $txt, $subject));
$txt = '';
$txt = '<p>A new Book Request has been submitted</p>';
$txt .= '<p><strong>Customer Name: </strong>'.$request->name.'</p>';
$txt .= '<p><strong>Customer Email: </strong>'.$request->email.'</p>';
$txt .= '<p><strong>Customer City: </strong>'.$request->city.'</p>';
$txt .= '<p><strong>Customer Phone: </strong>'.$request->phone.'</p>';
$txt .= '<p><strong>Book Title: </strong>'.$request->book_title.'</p>';
$txt .= '<p><strong>Author Name: </strong>'.$request->author_name.'</p>';
$txt .= '<p><strong>Book Information: </strong>'.$request->book_info.'</p>';
Mail::to(config()->get('mail.from.address'))->send(new GeneralMail('Admin', $mailFromId, $txt, $subject));
}
catch(Exception $e1)
{
return response()->json(['status'=>$e1->getMessage()], 400);
}
if($res->wasRecentlyCreated)
return response()->json(['status'=>'Book Request Submitted successfully'], 200);
else
return response()->json(['status'=>'Updated Successfully'], 200);
}
public function stores_view()
{
$data['pageheader'] = "Stores";
$data['stores'] = Store::where('status', 'A')->get();
return view('frontend.store-view', $data);
}
public function blog_list()
{
$data['pageheader'] = "Blogs";
$data['blogs'] = Blog::where('status', 'A')->where('approved_by_admin', 1)->cursorPaginate(3);
return view('frontend.blog-list', $data);
}
public function blog_detail(Request $request)
{
$data['pageheader'] = "Blog Detail";
$data['blog'] = Blog::where('slug', $request->slug)->first();
$data['f_blogs'] = Blog::whereNotIn('slug', [$request->slug])->where('status', 'A')->where('approved_by_admin', 1)->paginate(4);
return view('frontend.blog-detail', $data);
}
public function cart()
{
$data['pageheader'] = "Cart";
if(session()->has('user.id')) //If user logged in then cart session id wont be required
{
$data['carts'] = ShoppingCart::where('user_id', session()->get('user.id'))->get();
return view('frontend.cart-page', $data);
}
elseif(session()->has('cart.session_id'))//user is not logged in but cart data present
{
$data['carts'] = ShoppingCart::where('cart_session_id', session()->get('cart.session_id'))->get();
return view('frontend.cart-page', $data);
}
else
{
$data['carts'] = collect();
return view('frontend.cart-page', $data);
}
}
public function add_to_cart(Request $request)//sdgfdsgsfgsdfsd
{
// session()->forget('cart');
try{
if(session()->has('user.id'))
{
$rec_count = ShoppingCart::where('user_id', session()->get('user.id'))->count(); // if shopping cart already has logged in user's records
if( $rec_count > 0)//logged in user already had records in shopping cart
{
$prev_rec = ShoppingCart::where(['user_id' => session()->get('user.id'), 'product_id' => $request->product_id])->first();
ShoppingCart::where(['user_id' => session()->get('user.id'), 'product_id' => $request->product_id])->delete();
if($prev_rec != null)//if product existed aginst user, shopping cart, updating the cart value
{
$res = $prev_rec->create([
'user_id' => session()->get('user.id'),
'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $prev_rec->net_price + ($request->order_qty * $request->price),
'quantity' => $prev_rec->quantity + $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
else //adding new product for logged in user in the cart
{
$res = ShoppingCart::create([
'user_id' => session()->get('user.id'),
'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $request->order_qty * $request->price,
'quantity' => $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
return response()->json([
'status'=>'Cart updated for logged in user',
], 200);
}
}
if(session()->has('cart.session_id')) //cart update code
{
if(!session()->has('user.id'))//if user not logged in
{
$prev_rec = ShoppingCart::where(['cart_session_id' => session()->get('cart.session_id'), 'product_id' => $request->product_id])->first();
if($prev_rec != null)//if product existed in session id, shopping cart, upgrading the cart value
{
// dd($prev_rec, $request->All());
$res = $prev_rec->update([
//'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $prev_rec->net_price + ($request->order_qty * $request->price),
'quantity' => $prev_rec->quantity + $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
else //if adding a new product which wasn't in session id, shopping cart
{
$res = ShoppingCart::create([
'cart_session_id' => session()->get('cart.session_id'),
'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $request->order_qty * $request->price,
'quantity' => $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
}
return response()->json([
'status'=>'Cart updated',
], 200);
}
elseif(!session()->has('cart.session_id')) //creating new cart for guest user
{
if(!session()->has('user.id')) //guest user
{
$cart_id = $this->generate_cart_id();
session()->put([
'cart.session_id' => $cart_id,
]);
$res = ShoppingCart::create([
'cart_session_id' => $cart_id,
'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $request->order_qty * $request->price,
'quantity' => $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
elseif(session()->has('user.id')) //if user logged in
{
if($rec_count == 0) //logged in user has never added anything in cart
{
$res = ShoppingCart::create([
'user_id' => session()->get('user.id'),
'cart_session_id' => null,
'product_id' => $request->product_id,
'price' => $request->price,
'net_price' => $request->order_qty * $request->price,
'quantity' => $request->order_qty,
'discount' => null,
'status' => 'A',
]);
}
if($rec_count > 0)
{
return response()->json([
'status'=>'Code should not enter here',
], 400);
}
}
return response()->json([
'status'=>'Cart created',
], 200);
}
}
catch(Exception $e1)
{
return response()->json([
'status' => $e1->getMessage(),
], 400);
}
}
public function remove_from_cart(Request $request)
{
$res = ShoppingCart::where('id', $request->cart_id)->delete();
return response()->json(['status'=>$res], 200);
}
public function empty_cart() //created for only debugging purpose
{
session()->forget('cart');
}
}
###########################################################################
LoginController Frontend
#############################################################################
<?php
namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Auth;
use App\Listener\SetDataInSession;
use App\Mail\GeneralMail;
use App\Models\ShoppingCart;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class LoginController extends Controller
{
//
//use
public const HOME = '/customer/dashboard';
public function __construct()
{
$this->middleware('frontendguest')->except('logout');
}
public function showLoginForm()
{
$data['pageheader'] = "Login";
$data['activemenu']['main'] = "login";
return view('frontend.login', $data);
}
public function login(Request $request)
{
//dd($request->All());
$rules = array(
'email' => 'required|email|exists:users',
'password' => 'required'
);
$validator = Validator::make($request->all(), $rules);
if($validator->fails()){
foreach($validator->errors()->messages() as $key => $value){
return response()->json(['status' => $value[0]], 400);
}
}
$user = User::where('email', $request->email)->first();
if(!$user){
return response()->json(['status' => 'The email address you entered is invalid'], 400);
}
if($user->role_id == 2){
return response()->json(['status' => 'Admin cannot login to Frontend.'], 400);
}
if($user->status == 0){
return response()->json(['status' => 'Your account has been deactivated. To activate your account contact admin.'], 400);
}
elseif($user->email_verified_at == null){
return response()->json(['status' => 'Please verify your Email and then proceed to login.'], 400);
}
elseif($user->mobile_verified_at == null){
return response()->json(['status' => 'Please verify your mobile OTP and then proceed to login.'], 400);
}
if(Auth::validate(['email' => $request->email, 'password' => $request->password])){
if(Auth::attempt(['email' => $request->email, 'password' => $request->password, 'role_id' => 1])) //If customer
{
if(!session()->has('cart.session_id')){
(new SetDataInSession)->handle($user->toArray());
return response()->json(['status' => 'Customer Logging in'], 200);
}else{
$mycartsItem = ShoppingCart::where('cart_session_id',session()->get('cart.session_id'))->count();
if($mycartsItem > 0){
// $cart_data = ['cart_session_id'=>null,'user_id'=>$user->id];
$cart_items_with_session_id = ShoppingCart::where('cart_session_id',session()->get('cart.session_id'))->get();
$cart_items_with_user_id = ShoppingCart::where('user_id',$user->id)->get();
// dump($cart_items_with_session_id);
// dd($cart_items_with_user_id);
foreach($cart_items_with_session_id as $item_session)
{
$var = 0;
foreach($cart_items_with_user_id as $item_user)
{
if($item_session->product_id == $item_user->product_id)
{
$var++;
$item_session->where(['user_id' => $user->id, 'product_id' => $item_session->product_id]) //replace cart session id with user id in all existing records on logging in
->update([
'cart_session_id'=>null,
'user_id'=>$user->id,
'price'=>$item_user->price,
'net_price'=>$item_session->net_price + $item_user->net_price,
'quantity'=>$item_session->quantity + $item_user->quantity,
]);
ShoppingCart::where(['cart_session_id' => session()->get('cart.session_id'), 'product_id' => $item_session->product_id])->delete(); //deleteing old data cuz user logging in
}
}
if($var == 0)
{
$item_session->where(['cart_session_id' => session()->get('cart.session_id'), 'product_id' => $item_session->product_id]) //replace cart session id with user id in all existing records on logging in
->update([
'cart_session_id'=>null,
'user_id'=>$user->id,
]);
}
}
// ShoppingCart::where('cart_session_id', session()->get('cart.session_id')) //replace cart session id with user id in all existing records on logging in
// ->update($cart_data);
}
(new SetDataInSession)->handle($user->toArray());
return response()->json(['status' => 'Customer Logging in and cart details updated'], 200);
//return response()->json(['status' => 'Customer Logging in', 'user_type' => 'customerCart'], 200);
}
}
// else if(Auth::attempt(['email' => $request->email, 'password' => $request->password, 'role_id' => 2]))
// {
// //$request->session()->invalidate();
// //Auth::logout();
// return response()->json(['status' => 'Admin cannot login to frontend'], 400);
// }
else
return response()->json(['status' => 'Invalid credentials.'], 400);
} else{
return response()->json(['status' => 'Invalid credentials.'], 400);
}
}
public function otp_form()
{
$data['pageheader'] = "OTP";
$data['activemenu']['main'] = "otp";
return view('frontend.otp_verify', $data);
}
public function logout(Request $request)
{
//$this->guard()->logout();
Auth::logout();
$request->session()->invalidate();
return redirect()->route('customer.login');
}
/*Password Reset code below*/
public function forgot_password()
{
$data['pageheader'] = 'Forgot Password';
return view('frontend.frgt-pass', $data);
}
public function forgot_password_post(Request $request)
{
$rules = [
'email'=>'required|email',
];
$validator = Validator::make($request->all(), $rules);
if($validator->fails()){
foreach($validator->errors()->messages() as $key => $value){
return response()->json(['status' => $value[0]], 400);
}
}
$user = User::where('email', $request->email)->whereNotIn('role_id', [2])->first();
if (empty($user)) {
return response()->json(['status' => 'No User records found with that email'], 400);
}
DB::table('password_resets')->insert([
'email' => $request->email,
'token' => Str::random(60),
'created_at' => Carbon::now()
]);
//Get the token just created above
$tokenData = DB::table('password_resets')
->where('email', $request->email)->first();
if ($this->sendResetEmail($request->email, $tokenData->token)) {
return response()->json(['status' => 'Email reset link has been sent to your email'], 200);
} else {
return response()->json(['status' => 'A Network Error occurred. Please try again.'], 400);
}
}
private function sendResetEmail($email, $token)
{
//Retrieve the user from the database
$user = User::where('email', $email)->select('name', 'email')->first();
//Generate, the password reset link. The token generated is embedded in the link
$link = URL::to("password-reset-form/?token=".$token."&email=".$user->email);
try
{
//Here send the link with CURL with an external email API
$subject = 'Password Reset Form - '.config()->get('app.name');
$txt = '';
$txt .= '<p>Below given is the form link to reset your Oxford Bookstore account password</p>';
$txt .= '<a href="'.$link.'"><button type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Reset Password</button></a>';
$mailFromId = config()->get('mail.from.address');
Mail::to($user->email)->send(new GeneralMail($user->name, $mailFromId, $txt, $subject));
// Mail::to($user->email)->send(new FrontEndPasswordResetMail($user->name, $mailFromId, $link));
return response()->json(['status' => 'Email reset link has been sent'], 200);
} catch (\Exception $e)
{
return false;
}
}
public function pass_reset_form_show()
{
return view('frontend.password_reset_form')->with(['email'=>request()->email, 'token'=>request()->token]);
}
public function resetPassword(Request $request)
{
//Validate input
$validator = Validator::make($request->all(), [
'email' => 'required|email|exists:users,email',
'password' => 'required|confirmed',
'token' => 'required' ]);
//check if payload is valid before moving on
if ($validator->fails()) {
$arr = array('status' => implode(",",$validator->errors()->all()));
return response()->json($arr, 400);
}
$password = $request->password;
// Validate the token
$tokenData = DB::table('password_resets')
->where('token', $request->token)->first();
// Redirect the user back to the password reset request form if the token is invalid
// if (!$tokenData) return view('auth.passwords.email');
$user = User::where('email', $tokenData->email)->first();
// Redirect the user back if the email is invalid
if (!$user) return response()->json(['status' => 'Email not found'], 400);
//Hash and update the new password
$user->password = Hash::make($password);
$user->update(); //or $user->save();
// //login the user immediately they change password successfully
// Auth::login($user);
//Delete the token
DB::table('password_resets')->where('email', $user->email)
->delete();
//Send Email Reset Success Email
$mailFromId = config()->get('mail.from.address');
$subject = 'Password Updated - '.config()->get('app.name');
$txt = '';
$txt .= '<p>You have successfully reset your password</p>';
Mail::to($user->email)->send(new GeneralMail($user->name, $mailFromId, $txt, $subject));
// Mail::to($user->email)->send(new OnlyTextMail($user->name, $mailFromId, $txt, $subject));
return response()->json(['status' => 'Password has been updated successfully'], 200);
// if ($this->sendSuccessEmail($tokenData->email)) {
// return response()->route('login');
// } else {
// return response()->json(['status' => 'Network error occured'], 400);
// }
}
/*Password reset section over*/
}
############################################################################
ShoppingCart Model:
#################################################################################
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ShoppingCart extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'cart_session_id',
'product_id',
'price',
'net_price',
'quantity',
'discount',
'status',
];
protected $with = ['products'];
public function products()
{
return $this->belongsTo(Product::class, 'product_id');
}
}
####################################################################################
cart-page.blade.php
##############################################################################################
@extends('layouts.frontendLayout')
@push('head_script')
@endpush
@section('content')
<section class="sectiongap cartpage-main">
<div class="container">
<div class="d-flex mb-4 justify-content-between align-items-center">
<div class="title-cart"><h1><span>Your Cart</span> (3 items)</h1></div>
<div class="con-spoping">
<a class="con-spoping-btn" href="#0">Continue Shopping</a>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="product-list">
@forelse($carts as $key => $cart)
<div class="pr-listbox">
<div class="list-primg">
<img src="{{asset('uploads/product_images/'.$cart->products->featured_image)}}">
</div>
<div class="checkdetails">
<h3>{{$cart->products->name}}</h3>
<h6><span>Book Author:</span>
@foreach($cart->products->authors as $author)
{{$author->name}}
@endforeach
</h6>
<p>1 Offer Applied <i class="fa fa-info-circle"></i> <b> 34% Off</b></p>
<ul class="redting-div">
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star-half-o"></i></li>
</ul>
</div>
<div class="qunatity-check ml-auto">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="quantity-left-minus btn btn-number" data-type="minus" data-field="">
<i class="fa fa-minus"></i>
</button>
</span>
<input type="text" id="quantity" name="quantity" class="form-control input-number" value="{{$cart->quantity}}" min="1" max="100">
<span class="input-group-btn">
<button type="button" class="quantity-right-plus btn btn-number" data-type="plus" data-field="">
<i class="fa fa-plus"></i>
</button>
</span>
</div>
</div>
<div class="price-check">
<h5> <del>₹disc_prc</del> <span>₹{{$cart->price}}</span></h5>
<a class="rm-btn" onclick="remove_from_cart({{$cart->id}})" >Remove</a>
</div>
</div>
@empty
EMPTY
@endforelse
</div>
</div>
@if(!$carts->isEmpty())
<div class="col-md-4">
<div class="checkoutslip">
<h2>Order Summary</h2>
<div class="row">
<div class="col-7">
<h5>Price (3 Items)</h5>
</div>
<div class="col-5 text-right">
<h5>₹1,997.00</h5>
</div>
<div class="col-7">
<h5>Discount</h5>
</div>
<div class="col-5 text-right text-danger">
<h5>- ₹140.00</h5>
</div>
<div class="col-7">
<h5>Delivery Charges</h5>
</div>
<div class="col-5 text-right text-danger">
<h5>Free</h5>
</div>
</div>
<hr class="mt-0">
<div class="row">
<div class="col-7">
<h4>Total Amount</h4>
</div>
<div class="col-5 text-right">
<h4> ₹1,857.00</h4>
</div>
</div>
<hr>
<p class="denger mb-5">You will save ₹140 on this order</p>
<button class="btn chakeout-btn w-100">Proceed To Checkout</button>
</div>
</div>
@else
EMPTY
@endif
</div>
</div>
</section>
<section class="sectiongap pt-3 recent-view-main">
<div class="container">
<div class="d-flex mb-4 justify-content-between align-items-center">
<div class="title-cart"><h4 class="mb-0">You May Also Like</h4></div>
<div class="con-spoping">
<a class="con-load-more" href="#0"> <i class="fa fa-refresh" aria-hidden="true"></i> Continue Shopping</a>
</div>
</div>
<div class="owl-carousel product-slide">
<div class="item">
<div class="product-box">
<div class="product-img">
<a class="hardicon" href="#0">
<img src="images/wishlist-white.png">
</a>
<a class="book-img" href="#0">
<img src="images/book-1.png" alt="">
</a>
</div>
<div class="product-describe">
<a href="#0">
<h3>The Nutmeg’s Curse</h3>
<h5><b>Book Author:</b> Amitav Ghosh</h5>
<div class="price">
<span>₹539.00</span> <del>₹599.00</del>
</div>
</a>
<div class="rating">
<ul>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star"></i></li>
<li><i class="fa fa-star-half-o"></i></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
@endsection
@push('footer_script')
<script>
$('#loginform').validate({
rules: {
email: {
required: true,
email: true
},
},
messages: {
email: {
required: "Please enter your email address",
email: "The inserted email address must be a email"
},
},
errorElement: "p",
submitHandler: function() {
var form = $('#loginform');
form.ajaxSubmit({
dataType:'json',
beforeSubmit:function(){
//data.find('button[type="submit"]').button('loading');
},
success:function(data){
// form.find('button[type="submit"]').button('reset');
form[0].reset();
notify(data.status, 'success');
window.location.href = "{{route('customer.forgotpass')}}";
},
error: function(errors) {
//form.find('button[type="submit"]').button('reset');
showErrors(errors, form);
}
});
}
});
</script>
@endpush
##############################################################################################
below code is for adding rs
###########################################################################################
<h2><span>Best Sellers ₹</span></h2>
###############################################################################################
frontendlayout.blade.php
#############################################################################################
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="{{asset('customResource/apeejay-frontend/images/oxfordLogo.jpg')}}" type="image/x-icon">
<title>{{isset($pageheader)?$pageheader : 'Home'}} | {{config('app.name', 'ApeejayOxford')}}</title>
<link href="{{asset('customResource/apeejay-frontend/font-awesome-4.7.0/css/font-awesome.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/css/bootstrap.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/css/style.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/css/responsive.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/fonts/stylesheet.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/fonts/aos.css')}}" rel="stylesheet">
<link href="{{asset('customResource/apeejay-frontend/images/favicon.png')}}" rel="shortcut icon">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.css" integrity="sha512-8D+M+7Y6jVsEa7RD6Kv/Z7EImSpNpQllgaEIQAtqHcI0H6F4iZknRj0Nx1DCdB+TwBaS+702BGWYC0Ze2hpExQ==" crossorigin="anonymous" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <!-- For dropwdown search-->
<link rel="stylesheet" type="text/css" href="{{asset('customResource/ul-css.css')}}"> <!-- For dropwdown search-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css" rel="stylesheet"><!-- Bootstrap Icons -->
@stack('head_script')
</head>
<body>
<header class="menudiv">
<div id="loadList" class="loader">
<div style="width: 100%;height: 100%;display: flex;flex-wrap: nowrap;justify-content: center;align-items: center;">
<div class="col-12">
<img src="{{asset('customResource/LoaderFrontend.gif')}}"><br>
<p style="color: #fff;">Please wait... </p>
</div>
</div>
</div>
<div class="had-offer">
<div class="container">
<h5>Buy one, get one 50% off our monthly picks! <a href="#0">Shop Now</a></h5>
</div>
</div>
<div class="menumd-div">
<div class="container">
<div class="d-flex">
<ul class="myacnav">
<li><a href="{{route('frontend.store')}}"><img src="{{asset('customResource/apeejay-frontend/images/location.png')}}"> Store Location</a></li>
<li><a href="#0">About Us</a></li>
<li><a href="{{route('frontend.blog')}}">Blog</a></li>
<li><a href="#0">Contact Us</a></li>
</ul>
<ul class="myacnav ml-auto">
<li class="dropdown">
@if(!session()->has('user.roles.slug'))
{{-- @if(session()->get('user.roles.slug') == 'customer') --}}
<a href="{{route('customer.login')}}">Login</p>
@else
@endif
@if(session()->has('user.roles.slug'))
<a class="dropdown-toggle" href="JavaScript: void(0)" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="{{asset('customResource/apeejay-frontend/images/account.png')}}"> My Account
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="{{route('customer.dashboard')}}">Dashboard</a>
<a class="dropdown-item" href="{{route('customer.logout')}}">Logout</a>
{{-- <a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a> --}}
</div>
@endif
</li>
<li><a href="#0"><img src="{{asset('customResource/apeejay-frontend/images/wishlist.png')}}"> Wishlist</a></li>
</ul>
</div>
</div>
</div>
<div class="had-brand">
<div class="container">
<div class="d-flex align-items-center">
<a class="navbar-brand" href="{{route('frontend.index')}}">
<img src="{{asset('customResource/apeejay-frontend/images/logo.png')}}">
</a>
<div class="serch-div ml-auto">
<form class="serchbar-main" action="{{route('search_get')}}" method="GET">
<select class="form-control" id="search_dropdown" name="search_category">
{{-- <option value="0">All</option>
@forelse(config()->get('categories') as $category)
<option value="{{$category->id}}">{{$category->title}}</option>
@empty
<option value="0">No Categories</option>
@endforelse --}}
@forelse(config()->get('categories') as $category)
<option value="{{$category}}">{{$category}}</option>
@empty
<option value="0">No Categories</option>
@endforelse
</select>
<input type="text" onkeypress="get_prod('search_name')" id="search_name" name="search_name" placeholder="Search By Book, Author, Publisher, Book Type, Category, Binding and Combo">
<button class="btn"><img src="{{asset('customResource/apeejay-frontend/images/search.png')}}"></button>
</form>
<div class="search-block" id="pro_search"></div>
</div>
<div class="right-mm">
<ul>
<li><a href="{{route('frontend.cart')}}"><span class="cart"><img src="{{asset('customResource/apeejay-frontend/images/cart.png')}}"> <span class="count" id="cart_count">20</span></span> Cart</a></li>
<li><a class="all-offer" href="#0">See All Offers</a></li>
</ul>
</div>
</div>
</div>
</div>
<nav class="navbar navbar-expand-lg">
<div class="container">
<div class="menuright ">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li><a class="nav-active" href="{{route('frontend.index')}}">Home</a></li>
<li><a href="#0">Gift voucher</a></li>
<li><a href="#0">Bestsellers </a></li>
<li><a href="{{route('frontend.list',['type' => 'new-releases'])}}">New Releases </a></li>
<li><a href="{{route('frontend.book_request')}}">Book Request </a></li>
<li><a href="#0">Cha Bar </a></li>
<li><a href="#0">Toys & Games</a></li>
<li><a href="#0">Stationery & Gifts </a></li>
<li><a href="#0">Festivals </a></li>
</ul>
</div>
</div>
</div>
</nav>
</header>
<section class="offer">
<a href="#0">
<img class="w-100" src="{{asset('customResource/apeejay-frontend/images/offer-code.png')}}" alt="offer-code">
</a>
</section>
@yield('content')
<footer class="footer-main">
<div class="container">
<div class="footer-top">
<div class="row">
<div class="col-md-4">
<h4>FIND A STORE</h4>
<form class="serch-box">
<input type="text" name="" placeholder="Store Name, Location, or ZIP Code">
<button><img src="{{asset('customResource/apeejay-frontend/images/Email-Arrow.png')}}"></button>
</form>
<h4>SIGN UP FOR SAVINGS, NEWS, AND UPDATES</h4>
<form class="serch-box">
<input type="text" name="" placeholder="Enter Your Email Address">
<a href="{{'customer.login'}}"><button><img src="{{asset('customResource/apeejay-frontend/images/Email-Arrow.png')}}"></button></a>
</form>
<p>Submit your email address to receive Apeejay Oxford Bookstores Pvt. Ltd offers & updates. You can view Apeejay Oxford Bookstores Pvt. Ltd Privacy Policy here. Unsubscribe from our emails at any time.</p>
<ul class="sochal">
<li>Follow Us</li>
<li><a target="_blank" href="#0"><i class="fa fa-facebook"></i></a></li>
<li><a target="_blank" href="#0"><i class="fa fa-twitter"></i></a></li>
<li><a target="_blank" href="#0"><i class="fa fa-instagram"></i></a></li>
<li><a target="_blank" href="#0"><i class="fa fa-youtube-play"></i></a></li>
</ul>
</div>
<div class="col-md-3 ml-auto pl-5">
<h4>SHOPPING GUIDE</h4>
<ul>
<li><a href="#0">FAQ’s</a></li>
<li><a href="{{route('frontend.store')}}">Store Locator</a></li>
<li><a href="#0">Return Policy</a></li>
<li><a href="#0">Payments & Shipping</a></li>
</ul>
</div>
<div class="col-md-3">
<h4>INFORMATION</h4>
<ul>
<li><a href="#0">About Us</a></li>
<li><a href="{{route('frontend.blog')}}">Blog</a></li>
<li><a href="#0">Careers</a></li>
<li><a href="#0">Contact Us</a></li>
<li><a href="#0">Privacy policy</a></li>
<li><a href="#0">Customer service</a></li>
<li><a href="#0">Terms & condition</a></li>
</ul>
</div>
<div class="col-md-2">
<h4>QUICK HELP</h4>
<ul>
<li><a href="#0">Help Centre</a></li>
<li><a href="#0">Shipping & Returns</a></li>
<li><a href="#0">Buy Online, Pick up in Store</a></li>
<li><a href="#0">Order Status</a></li>
<li><a href="#0">Gift Cards</a></li>
</ul>
</div>
</div>
</div>
<div class="footer-bottom d-flex flex-wra align-items-center justify-content-between">
<p>Copyright © 2022 <span style="text-transform: uppercase; font-weight: 600;">Apeejay Oxford Bookstores Pvt. Ltd</span> | Designed and Developed By <a target="_blank" style="color: red;" href="https://www.ivaninfotech.com/">Ivan Infotech</a></p>
<div class="right-cardicon">
<img src="{{asset('customResource/apeejay-frontend/images/payment.png')}}">
</div>
</div>
</div>
</footer>
<!-- ========================JavaScript========================== -->
<script src="{{asset('customResource/apeejay-frontend/js/jquery.min.js')}}" ></script>
<script src="{{asset('customResource/apeejay-frontend/js/popper.min.js')}}"></script>
<script src="{{asset('customResource/apeejay-frontend/js/bootstrap.min.js')}}"></script>
<script src="{{asset('customResource/apeejay-frontend/js/owl.carousel.js')}}"></script>
<script src="{{asset('customResource/apeejay-frontend/js/custom.js')}}"></script>
<script src="{{asset('customResource/apeejay-frontend/js/aos.js')}}"></script>
<script src="{{asset('js/custom.js')}}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-toast-plugin/1.3.2/jquery.toast.min.js" integrity="sha512-zlWWyZq71UMApAjih4WkaRpikgY9Bz1oXIW5G0fED4vk14JjGlQ1UmkGM392jEULP8jbNMiwLWdM8Z87Hu88Fw==" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.3.0/jquery.form.min.js" integrity="sha512-YUkaLm+KJ5lQXDBdqBqk7EVhJAdxRnVdT2vtCzwPHSweCzyMgYV/tgGF4/dCyqtCC2eCphz0lRQgatGVdfR0ww==" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <!-- For dropwdown search-->
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> <!-- Sweet Alert2 -->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <!-- For Axios -->
<script>
function get_prod(text_id){
var textLength = $("#"+text_id).val().length;
if(textLength > 1){
var cat_id = $('#search_dropdown').val();
$( "#"+text_id ).autocomplete({
source: function(request, response) {
$.ajax({
url: "{{route('getsearchdata')}}",
data:{'_token':'{{csrf_token()}}','val':$("#"+text_id).val(),'cat_id':cat_id},
dataType: "json",
type: "POST",
success: function(data){
var arr_data=data.pro;
$("#pro_search").val(arr_data);
response(data);
}
});
},
});
}
}
async function remove_from_cart(cart_rec_id) { //deleting item from cart
try {
const response = await axios.post("{{route('frontend.remove_from_cart')}}", {
cart_id:cart_rec_id,
});
console.log(response.data.status);
location.reload();
} catch (error) {
console.error(error);
}
}
$(document).ready(function () { //for updating cart icon value
$("#cart_count").text({{config()->get('items_in_cart')}});
});
</script>
@stack('footer_script')
</body>
</html>
#####################################################################################################
web.php
##########################################################################################################
<?php
use App\Http\Controllers\Admin\GeneralAdminController;
use App\Http\Controllers\Admin\MembersController;
use App\Http\Controllers\Admin\AttributeController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\TypeController;
use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\AuthorPublisher;
use App\Http\Controllers\Admin\CouponController;
use App\Http\Controllers\Admin\BannerController;
use App\Http\Controllers\Admin\ReportController;
use App\Http\Controllers\Admin\BlogController;
use App\Http\Controllers\Admin\BlogCategoryController;
use App\Http\Controllers\Admin\BookRequestController;
use App\Http\Controllers\Admin\StoreController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomepageController;
use App\Http\Controllers\Auth;
use App\Http\Controllers\Customer;
use App\Http\Controllers\Customer\GeneralCustomerController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//middleware auth for chceking and redirection
//customer also for customer chcek and redirection
//roleif for role check
// Route::get('/', function () {
// return view('welcome');
// });
Route::middleware('common')->group(function() {
Route::get('validate-user', [HomepageController::class, 'validate_user'])->name('validate_user');
Route::post('getsearchdata', [HomepageController::class, 'getsearchdata'])->name('getsearchdata');
Route::get('search', [HomepageController::class, 'search_get'])->name('search_get');
//Admin panel Authentication Routes...
Route::get('admin/login', [Auth\LoginController::class, 'showLoginForm'])->name('login');
Route::post('admin/login', [Auth\LoginController::class, 'login'])->name('login');
Route::any('admin/logout', [Auth\LoginController::class, 'logout'])->name('logout');
Route::get('admin/register', [Auth\RegisterController::class, 'showRegistrationForm'])->name('register');
Route::post('admin/register', [Auth\RegisterController::class, 'register'])->name('register');
//Customer panel Authentication Routes
Route::name('customer.')->group(function(){
Route::get('login', [Customer\LoginController::class, 'showLoginForm'])->name('login');
Route::post('login', [Customer\LoginController::class, 'login'])->name('login');
Route::get('otp-verify', [Customer\LoginController::class, 'otp_form'])->name('otp');
Route::post('otp-verify', [Customer\LoginController::class, 'otp_verify'])->name('otp');
Route::get('register', [Customer\RegisterController::class, 'showRegistrationForm'])->name('register');
Route::post('register', [Customer\RegisterController::class, 'register_post'])->name('register');
Route::any('logout', [Customer\LoginController::class, 'logout'])->name('logout');
Route::get('forgot-password', [Customer\LoginController::class, 'forgot_password'])->name('forgotpass');
Route::post('forgot-password', [Customer\LoginController::class, 'forgot_password_post'])->name('forgotpass');
Route::get('password-reset-form/', [Customer\LoginController::class, 'pass_reset_form_show'])->name('pass_reset_form');
Route::post('password-reset-form', [Customer\LoginController::class, 'resetPassword'])->name('pass_reset_form');
});
Route::name('admin/password.')->group(function() {
Route::get('admin/password/reset', [Auth\ForgotPasswordController::class, 'showLinkRequestForm'])->name('request');
Route::post('admin/password/email', [Auth\ForgotPasswordController::class, 'sendResetLinkEmail'])->name('email');
Route::get('admin/password/reset/{token}', [Auth\ResetPasswordController::class, 'showResetForm'])->name('reset');
Route::post('admin/password/reset', [Auth\ResetPasswordController::class, 'reset'])->name('reset');
});
// Route::get('/login', [Auth\LoginController::class, 'showLoginForm'])->name('login');
// Route::post('/login', [Auth\LoginController::class, 'login'])->name('login');
// Route::any('/logout', [Auth\LoginController::class, 'logout'])->name('logout');
// Route::get('register', [Auth\RegisterController::class, 'showRegistrationForm'])->name('register');
// Route::post('register', [Auth\RegisterController::class, 'register'])->name('register');
// Password Reset Routes...
Route::name('frontend.')->group(function(){
Route::get('/', [HomepageController::class, 'index'])->name('index');
Route::get('/product-listing', [HomepageController::class, 'product_listing'])->name('product_listing');
Route::get('/product-details/{slug}', [HomepageController::class, 'product_details'])->name('product_details');
Route::get('/book-request', [HomepageController::class, 'book_request'])->name('book_request');
Route::post('/book-request', [HomepageController::class, 'book_request_post'])->name('book_request');
Route::get('/stores', [HomepageController::class, 'stores_view'])->name('store');
Route::get('/blogs', [HomepageController::class, 'blog_list'])->name('blog');
Route::get('/blog/{slug}', [HomepageController::class, 'blog_detail'])->name('blog_detail');
Route::post('/filter', [HomepageController::class, 'filter'])->name('filter');
Route::get('/list/{type}', [HomepageController::class, 'listing'])->name('list');
Route::post('/add-to-cart', [HomepageController::class, 'add_to_cart'])->name('add_to_cart');
Route::get('/cart', [HomepageController::class, 'cart'])->name('cart');
Route::post('/remove_from_cart', [HomepageController::class, 'remove_from_cart'])->name('remove_from_cart');
Route::get('/empty_cart', [HomepageController::class, 'empty_cart'])->name('frgt'); //only for dev purpose
// Route::get('/services', [HomepageController::class, 'services'])->name('services');
// Route::get('/service-detail/{slug}', [HomepageController::class, 'service_detail'])->name('service_detail');
// Route::get('/fog-maker', [HomepageController::class, 'fog_maker'])->name('fog_maker');
// Route::get('/contact-us', [HomepageController::class, 'contact_us'])->name('contact_us');
// Route::post('/contact-us', [HomepageController::class, 'contact_us_post'])->name('contact_us_post');
// Route::get('/fire-evacuation-plans', [HomepageController::class, 'fire_evacuation'])->name('fire_evacuation');
// Route::get('/community-audits', [HomepageController::class, 'community_audits'])->name('community_audits');
// Route::get('/about-us', [HomepageController::class, 'about_us'])->name('about_us');
// Route::get('/terms-conditions', [HomepageController::class, 'terms_conditions'])->name('terms_conditions');
// Route::get('/privacy-policy', [HomepageController::class, 'privacy_policy'])->name('privacy_policy');
// Route::post('/subscribe-newsletter', [HomepageController::class, 'subscribe_news'])->name('subscribe_news');
});
Route::prefix('/admin')->name('admin.')->middleware('adminauth','roleif:admin')->group(function (){
Route::get('/dashboard', [GeneralAdminController::class, 'dashboard'])->name('dashboard');
Route::get('/profile', [GeneralAdminController::class, 'profile'])->name('profile');
Route::get('/setting', [GeneralAdminController::class, 'setting'])->name('setting');
Route::post('/setting', [GeneralAdminController::class, 'setting_submit'])->name('setting');
Route::get('/password-change', [GeneralAdminController::class, 'password_change'])->name('admin_password_change');
Route::post('/password-change', [GeneralAdminController::class, 'password_change_post'])->name('admin_password_change');
Route::prefix('/members')->name('member.')->group(function (){
Route::get('/index', [MembersController::class, 'index'])->name('index');
Route::post('/change', [MembersController::class, 'change'])->name('change');
Route::get('editOrCreate', [MembersController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('editOrCreate', [MembersController::class, 'editOrCreate_post'])->name('editOrCreate');
});
Route::prefix('/attributes')->name('attribute.')->group(function (){
Route::get('/index', [AttributeController::class, 'index'])->name('index');
Route::get('/editOrCreate', [AttributeController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [AttributeController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [AttributeController::class, 'change'])->name('change');
});
Route::prefix('/banners')->name('banner.')->group(function (){
Route::get('/index', [BannerController::class, 'index'])->name('index');
Route::get('/editOrCreate', [BannerController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [BannerController::class, 'editOrCreate_post'])->name('editOrCreate_post');
Route::post('/change', [BannerController::class, 'change'])->name('change');
});
Route::prefix('/types')->name('type.')->group(function (){
Route::get('/index', [TypeController::class, 'index'])->name('index');
Route::get('/editOrCreate', [TypeController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [TypeController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [TypeController::class, 'change'])->name('change');
});
Route::prefix('/categories')->name('category.')->group(function (){
Route::get('/index', [CategoryController::class, 'index'])->name('index');
Route::get('/editOrCreate', [CategoryController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [CategoryController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [CategoryController::class, 'change'])->name('change');
});
Route::prefix('/products')->name('product.')->group(function (){
Route::get('/index', [ProductController::class, 'index'])->name('index');
Route::get('/editOrCreate', [ProductController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [ProductController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [ProductController::class, 'change'])->name('change');
Route::post('/get_attributes', [ProductController::class, 'get_attributes'])->name('get_attributes');
});
Route::prefix('/authors')->name('author.')->group(function(){
Route::get('/index', [AuthorPublisher::class, 'index'])->name('index');
Route::get('/editOrCreate', [AuthorPublisher::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [AuthorPublisher::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [AuthorPublisher::class, 'change'])->name('change');
});
Route::prefix('/publishers')->name('publisher.')->group(function(){
Route::get('/index', [AuthorPublisher::class, 'index'])->name('index');
Route::get('/editOrCreate', [AuthorPublisher::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [AuthorPublisher::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [AuthorPublisher::class, 'change'])->name('change');
});
Route::prefix('/coupons')->name('coupon.')->group(function(){
Route::get('/index', [CouponController::class, 'index'])->name('index');
Route::get('/editOrCreate', [CouponController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [CouponController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [CouponController::class, 'change'])->name('change');
});
Route::prefix('/reports')->name('report.')->group(function(){
Route::get('/index', [ReportController::class, 'index'])->name('index');
Route::post('/generate', [ReportController::class, 'generate'])->name('generate');
// Route::post('/editOrCreate', [ReportController::class, 'editOrCreate_post'])->name('editOrCreate');
// Route::post('/change', [ReportController::class, 'change'])->name('change');
});
Route::prefix('/blogs')->name('blog.')->group(function(){
Route::get('/index', [BlogController::class, 'index'])->name('index');
Route::get('/editOrCreate', [BlogController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [BlogController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [BlogController::class, 'change'])->name('change');
});
Route::prefix('/blog-categories')->name('blog_category.')->group(function (){
Route::get('/index', [BlogCategoryController::class, 'index'])->name('index');
Route::get('/editOrCreate', [BlogCategoryController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [BlogCategoryController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [BlogCategoryController::class, 'change'])->name('change');
Route::post('/changeDefault', [BlogCategoryController::class, 'changeDefault'])->name('changeDefault');
});
Route::prefix('/stores')->name('store.')->group(function(){
Route::get('/index', [StoreController::class, 'index'])->name('index');
Route::get('/editOrCreate', [StoreController::class, 'editOrCreate'])->name('editOrCreate');
Route::post('/editOrCreate', [StoreController::class, 'editOrCreate_post'])->name('editOrCreate');
Route::post('/change', [StoreController::class, 'change'])->name('change');
});
Route::prefix('/book-request')->name('book_request.')->group(function(){
Route::get('/index', [BookRequestController::class, 'index'])->name('index');
Route::get('/view', [BookRequestController::class, 'view'])->name('view');
// Route::get('/editOrCreate', [StoreController::class, 'editOrCreate'])->name('editOrCreate');
// Route::post('/editOrCreate', [StoreController::class, 'editOrCreate_post'])->name('editOrCreate');
// Route::post('/change', [StoreController::class, 'change'])->name('change');
});
});
Route::prefix('/customer')->name('customer.')->middleware('customer','roleif:customer')->group(function (){
//coupon checkout code here
Route::get('/dashboard', [GeneralCustomerController::class, 'dashboard'])->name('dashboard');
});
});
########################################################################################################