OwlCyberSecurity - MANAGER
Edit File: HomeController.php
<?php namespace App\Http\Controllers; use App\Models\Blog; use App\Models\Slider; use App\Models\Categories; use App\Models\Coupon; use App\Models\Store; // use Illuminate\Support\Str; class HomeController extends Controller { public $data = []; public function __construct() { // parent::__construct(); $this->data['categories'] = Categories::where('status', 1)->get(); } public function index() // public function index(\Request $request) { // if ($request::has('abc') && $request::get('abc') != '') { // $stores = \DB::table('categories')->where('slug', null)->get(); // foreach($stores as $store) { // \DB::table('categories')->where('id', $store->id)->update(['slug' => Str::slug($store->name)]); // } // die; // } $this->data['slider'] = Slider::where('status', 1)->get(); $this->data['stores'] = Store::where('status', 1)->where('is_top_store', 1)->take(12)->get(); // $this->data['latest_coupons'] = Coupon::selectRaw('coupons.id, stores.short_name, coupons.coupon_name, stores.title, coupons.description, code, coupons.destination_url') // ->leftjoin('stores', 'stores.id', '=', 'coupons.store_id') // ->where('coupons.status', 1) // ->where('stores.status', 1) // ->orderby('coupons.id', 'desc') // ->take(4) // ->get(); $this->data['featured_coupons_deals'] = Coupon::selectRaw('coupons.id, stores.short_name, coupons.coupon_name, stores.title, coupons.description, code, coupons.destination_url') ->leftjoin('stores', 'stores.id', '=', 'coupons.store_id') ->where('coupons.status', 1) ->where('stores.status', 1) ->where('code', '') ->where('coupons.featured', 1) ->orderby('coupons.order_number', 'asc') ->take(8) ->get(); $this->data['featured_coupons_codes'] = Coupon::selectRaw('coupons.id, stores.short_name, coupons.coupon_name, stores.title, coupons.description, code, coupons.destination_url') ->leftjoin('stores', 'stores.id', '=', 'coupons.store_id') ->where('coupons.status', 1) ->where('stores.status', 1) ->where('code', '<>', '') ->where('coupons.featured', 1) ->orderby('coupons.order_number', 'asc') ->take(8) ->get(); $this->data['latest_blogs'] = Blog::selectRaw('id, slug, title, short_description, header_image, DATE_FORMAT(created_at, "%d") as post_date, DATE_FORMAT(created_at, "%b / %Y") as post_month_year') ->orderby('id', 'DESC') ->where('status', 1)->paginate(3); $this->data['featured_stores'] = Store::where('status', 1) ->where('is_featured', 1) ->get(); $this->data['meta_title'] = 'Dingomo | A heaven for Discount Codes & Coupons'; $this->data['meta_keywords'] = 'coupon code, coupon codes, coupons, coupons code, coupons code, coupons codes, promo, promo code, promo codes, promotion, promotion code, promotion codes, promotions, promotions code, promotions codes, promotional code, promotional codes, discount, discount code, discount codes, discounts, discounts code, discounts codes, offer, offers, voucher, voucher code, voucher codes, vouchers, vouchers code, vouchers codes'; $this->data['meta_description'] = 'Dingomo - A heaven for all the latest discount codes, promo codes, coupons, vouchers, deals, cashback offers & much more. Get your discount now!'; $this->data['og_title'] = $this->data['meta_title']; $this->data['og_description'] = $this->data['meta_description']; // $this->data['og_image'] = asset('storage/blog_images/' . $this->data['blog']->header_image); return view('frontend.home', $this->data); } public function stores($slug = '') { $CategoryID = 0; if ($slug != "") { $this->data['category'] = Categories::where('status', 1)->where('slug', $slug)->first(); if (!empty($this->data['category'])) { $CategoryID = $this->data['category']->id; } } $Stores = Store::where('status', 1); $this->data['CategoryData'] = []; if ($CategoryID > 0) { $CategoryData = Categories::where('status', 1)->where('id', $CategoryID)->first(); if (!empty($CategoryData)) { $Stores->where('category_id', $CategoryID); } $this->data['CategoryData'] = $CategoryData->toArray(); } $this->data['all_stores_count'] = $Stores->count(); $this->data['stores'] = $Stores->orderby('title', 'ASC')->paginate(80); $this->data['meta_title'] = 'Best Discounts for The Stores You Love | Dingomo'; $this->data['meta_keywords'] = 'coupon code, coupon codes, coupons, coupons code, coupons code, coupons codes, promo, promo code, promo codes, promotion, promotion code, promotion codes, promotions, promotions code, promotions codes, promotional code, promotional codes, discount, discount code, discount codes, discounts, discounts code, discounts codes, offer, offers, voucher, voucher code, voucher codes, vouchers, vouchers code, vouchers codes'; $this->data['meta_description'] = 'Get the best discount codes, promo codes, deals and offers for stores & brands from all around the world. Avail the deal and save your money now!'; $this->data['og_title'] = $this->data['meta_title']; $this->data['og_description'] = $this->data['meta_description']; return view('frontend.stores', $this->data); } public function categories() { $this->data['categories'] = Categories::where('status', 1)->get(); $this->data['meta_title'] = 'Best Discounts For Every Category | Dingomo'; $this->data['meta_keywords'] = 'coupon code, coupon codes, coupons, coupons code, coupons code, coupons codes, promo, promo code, promo codes, promotion, promotion code, promotion codes, promotions, promotions code, promotions codes, promotional code, promotional codes, discount, discount code, discount codes, discounts, discounts code, discounts codes, offer, offers, voucher, voucher code, voucher codes, vouchers, vouchers code, vouchers codes'; $this->data['meta_description'] = 'Get the best discount codes, promo codes, deals and offers for any categories from all around the world. Avail the deal and save your money now!'; $this->data['og_title'] = $this->data['meta_title']; $this->data['og_description'] = $this->data['meta_description']; return view('frontend.categories', $this->data); } public function store_details($slug, \Request $request) { if(preg_match('/[A-Z]/', $slug)){ return redirect('/'.strtolower($slug)); } $Filter = ''; if ($request::has('filter') && $request::get('filter') != '') { $Filter = $request::get('filter'); if ($Filter != 'deals' && $Filter != 'codes') { $Filter = ''; } } $this->data['store'] = Store::where('status', 1)->where('slug', $slug)->first(); if (!empty($this->data['store'])) { $Coupons = Coupon::where('store_id', $this->data['store']->id)->where('status', 1); if ($Filter == 'deals') { $Coupons->whereRaw('(code = "" OR code is NULL)'); } if ($Filter == 'codes') { $Coupons->where('code', '<>', ''); } $Coupons->whereRaw('(ending_date >= NOW() OR ending_date is null)'); $this->data['coupons'] = $Coupons->orderby('coupons.order_number', 'asc')->get(); $this->data['coupons_codes_count'] = Coupon::where('store_id', $this->data['store']->id) ->where('code', '<>', '') ->where('status', 1) ->whereRaw('(ending_date >= NOW() OR ending_date is null)') ->count(); $this->data['coupons_deals_count'] = Coupon::where('store_id', $this->data['store']->id) ->whereRaw('(code = "" OR code is null)') ->where('status', 1) ->whereRaw('(ending_date >= NOW() OR ending_date is null)') ->count(); $this->data['expired_coupons'] = Coupon::where('store_id', $this->data['store']->id)->where('status', 1) ->whereRaw('(ending_date < NOW())')->orderby('coupons.order_number', 'asc')->get(); $this->data['meta_title'] = $this->data['store']->meta_title; $this->data['meta_keywords'] = $this->data['store']->meta_keywords; $this->data['meta_description'] = $this->data['store']->meta_description; $this->data['og_title'] = $this->data['store']->meta_title; $this->data['og_description'] = $this->data['store']->meta_description; $this->data['og_image'] = asset('storage/store_images/' . $this->data['store']->og_image); $this->data['RemoveExtraJs'] = true; return view('frontend.store-details', $this->data); } return redirect('/stores'); } public function blogs() { $this->data['blogs'] = Blog::selectRaw('id, slug, title, short_description, header_image, DATE_FORMAT(created_at, "%d") as post_date, DATE_FORMAT(created_at, "%b / %Y") as post_month_year') ->where('status', 1)->paginate(12); $this->data['featured_stores'] = Store::selectRaw('id, slug, title, image') ->where('status', 1) ->where('is_featured', 1) ->limit(8) ->get(); $this->data['meta_title'] = 'Shopping Hacks & Savings Tips & Tricks | Dingomo'; $this->data['meta_keywords'] = 'coupon code, coupon codes, coupons, coupons code, coupons code, coupons codes, promo, promo code, promo codes, promotion, promotion code, promotion codes, promotions, promotions code, promotions codes, promotional code, promotional codes, discount, discount code, discount codes, discounts, discounts code, discounts codes, offer, offers, voucher, voucher code, voucher codes, vouchers, vouchers code, vouchers codes'; $this->data['meta_description'] = 'All the hacks, tips and tricks to save your money and shop smartly. Read our blog to become a smart shopper. Dingomo'; $this->data['og_title'] = $this->data['meta_title']; $this->data['og_description'] = $this->data['meta_description']; return view('frontend.blogs', $this->data); } public function blog_details($slug) { $this->data['blog'] = Blog::selectRaw('id, title, content, meta_title, meta_keywords, meta_description, category_id, short_description, header_image, DATE_FORMAT(created_at, "%d") as post_date, DATE_FORMAT(created_at, "%b / %Y") as post_month_year')->where('status', 1)->where('slug', $slug)->first(); if (!empty($this->data['blog'])) { $this->data['related_blogs'] = Blog::selectRaw('id, slug, title, header_image') ->where('category_id', $this->data['blog']->category_id) ->where('id', '<>', $this->data['blog']->id) ->where('status', 1) ->limit(12) ->get(); $this->data['related_stores'] = Store::selectRaw('id, slug, title, image') ->where('category_id', $this->data['blog']->category_id) ->where('status', 1) ->limit(6) ->get(); $this->data['meta_title'] = $this->data['blog']->meta_title; $this->data['meta_keywords'] = $this->data['blog']->meta_keywords; $this->data['meta_description'] = $this->data['blog']->meta_description; $this->data['og_title'] = $this->data['blog']->meta_title; $this->data['og_description'] = $this->data['blog']->meta_description; $this->data['og_image'] = asset('storage/blog_images/' . $this->data['blog']->header_image); // dd($this->data); return view('frontend.blog-details', $this->data); } return redirect('/blogs'); } public function about_us() { $this->data['meta_title'] = 'About Us | Dingomo'; $this->data['meta_keywords'] = 'coupon code, coupon codes, coupons, coupons code, coupons code, coupons codes, promo, promo code, promo codes, promotion, promotion code, promotion codes, promotions, promotions code, promotions codes, promotional code, promotional codes, discount, discount code, discount codes, discounts, discounts code, discounts codes, offer, offers, voucher, voucher code, voucher codes, vouchers, vouchers code, vouchers codes'; $this->data['meta_description'] = 'Discover our mission to help you save money while shopping. Explore discount codes, deals, and tips at Dingomo - your dingomo shopping ally'; $this->data['og_title'] = $this->data['meta_title']; $this->data['og_description'] = $this->data['meta_description']; return view('frontend.about-us', $this->data); } public function privacy_policy() { $this->data['no_index'] = true; $this->data['meta_title'] = 'Privacy Policy | Dingomo'; return view('frontend.privacy-policy', $this->data); } public function get_store_names(\Request $request) { $search_keyword = $request::get('search_keyword'); $stores = Store::select('id', 'slug', 'title') ->where('status', 1) ->whereRaw('(title LIKE "%' . $search_keyword . '%")') ->take(5) ->get(); return response()->json(['success' => true, 'stores' => $stores], 200); } public function sitemap() { $stores = Store::where('status', 1)->get(); $blogs = Blog::where('status', 1)->get(); return response()->view('frontend.sitemap_xml', [ 'stores' => $stores, 'blogs' => $blogs ])->header('Content-Type', 'text/xml'); } }