Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 3.137.212.81
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : HomeController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Http\Response;
use App\Models\Banner;
use App\Models\Cms;
use App\Models\Service;
use App\Models\Faq;
use App\Models\Product;
use Mail;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    // public function __construct()
    // {
    //     $this->middleware('auth');
    // }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        // Banner
       // Fetch banners with IDs 1, 2, and 3
       
        $banners = Banner::whereIn('banner_id', [1, 2, 3])->where('banner_status', 1)->get();

       

        // Sections
        $data['sec_1_1'] = DB::table('cms')->where('cms_id', '=', 1)->first();
        $data['sec_1_2'] = DB::table('cms')->where('cms_id', '=', 2)->first();
        $data['sec_1_3'] = DB::table('cms')->where('cms_id', '=', 3)->first();
        $data['sec_2'] = DB::table('cms')->where('cms_id', '=', 4)->first();
        $data['sec_3_1'] = DB::table('cms')->where('cms_id', '=', 5)->first();
        $data['sec_3_2'] = DB::table('cms')->where('cms_id', '=', 6)->first();
        $data['sec_3_3'] = DB::table('cms')->where('cms_id', '=', 7)->first();
        $data['sec_3_4'] = DB::table('cms')->where('cms_id', '=', 8)->first();
        $data['sec_3_5'] = DB::table('cms')->where('cms_id', '=', 9)->first();
        $data['sec_4_1'] = DB::table('cms')->where('cms_id', '=', 10)->first();
        $data['sec_4_2'] = DB::table('cms')->where('cms_id', '=', 11)->first();
        $data['sec_4_3'] = DB::table('cms')->where('cms_id', '=', 12)->first();
        $data['sec_5'] = DB::table('cms')->where('cms_id', '=', 13)->first();
        $data['sec_6'] = DB::table('cms')->where('cms_id', '=', 14)->first();
        $data['sec_7'] = DB::table('cms')->where('cms_id', '=', 15)->first();
        $data['sec_8'] = DB::table('cms')->where('cms_id', '=', 16)->first();

        // Products
        $data['products'] = Product::where('product_status', 1)->inRandomOrder()->limit(8)->get();

        $data['testimonial'] = DB::select("SELECT * FROM `testimonials` WHERE `testimonial_status` = 1 && `client_image` IS NOT NULL");

        return view('index', $data, compact('banners'));

        
        // ActiveWear
        $data['activewear'] = Product::where('product_status', 1)->orwhere('product_category_id', 10)->orwhere('product_category_id', 2)->orwhere('product_category_id', 11)->orwhere('product_category_id', 4)->inRandomOrder()->limit(4)->get();

        // Accessories
        $data['accessories'] = Product::where('product_category_id', 12)->where('product_status', 1)->orderBy('product_id', 'ASC')->limit(3)->get();

        // Services
        $data['services'] = Service::all();

        // Testimonials
        $data['testimonial'] = DB::select("SELECT * FROM `testimonials` WHERE `testimonial_status` = 1 && `client_image` IS NOT NULL");

        // Faqs
        $data['faqs'] = Faq::where('faq_status',1)->get();
        return view('index',$data);
    }

    public function newsletter(Request $req)
    {
        // $ip = $req->ip();
        // echo $ip;
        // exit();
        $email = $req->email;
        
        $data = [
                'to'=>'info@easybuyer.com',
                'fromEmail'=>$email,
            ];

            Mail::send('newsletter_email',$data,function($messages) use ($data){
                $messages->to($data['to']);
                $messages->subject('Newsletter');
            });
            
        $data2 = [
                'to'=>$email,
                'fromEmail'=>$email,
            ];

            Mail::send('newsletter_email',$data2,function($messages) use ($data2){
                $messages->to($data2['to']);
                $messages->subject('Thankyou For Subscription Our Newsletter');
            });
            
            return redirect()->back();
        
        // $validation = Validator::make($req->all(),[
        //     'email' => 'required',
        // ],[
        //     'email.required' => 'Enter Email',
        // ]);

        // if(!$validation->passes())
        // {
        //     return response()->json(['error'=>$validation->errors()]);
        // }
        // else
        // {
        //     $data = [
        //         'to'=>'developer.bilal124@gmail.com',
        //         'fromEmail'=>$req->email,
        //     ];

        //     Mail::send('newsletter_email',$data,function($messages) use ($data){
        //         $messages->to($data['to']);
        //         $messages->subject('Newsletter');
        //     });
        //     return response()->json(['success'=>'Thanks For Subscription']);
        // }
    }

    public function register()
    {
        $data['banner'] = collect(DB::select("SELECT * FROM `banners` WHERE `banner_id` = 10 && `banner_status` = 1"))->first();
        return view('create_new',$data);
    }

    public function thanku()
    {
        return view('thank_you');
    }
}
© 2025 GrazzMean-Shell