<repo_name>ucking44/mobileApp<file_sep>/database/migrations/2020_12_27_033440_create_products_table.php
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->bigIncrements('product_id');
            //$table->bigInteger('user_id')->unsigned();
            $table->unsignedBigInteger('category_id');
            $table->unsignedBigInteger('manufacture_id');
            $table->string('product_name');
            $table->longText('product_description');
            //$table->float('product_price');
            $table->double('product_price', 14, 2);
            $table->unsignedBigInteger('stock');
            $table->string('product_image');
            $table->string('product_size');
            $table->string('product_color');
            $table->string('status')->default('disable');
            $table->float('rating_cache', 2, 1)->default(3.0);
            $table->unsignedBigInteger('rating_count')->default(0);
            $table->string('icon');
            $table->foreign('category_id')->references('category_id')->on('categories')->onDelete('cascade');
            $table->foreign('manufacture_id')->references('manufacture_id')->on('manufactures')->onDelete('cascade');
            $table->timestamps();

            // $table->foreign('user_id')
            //     ->references('user_id')
            //     ->on('users')
            //     ->onDelete('cascade');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
<file_sep>/app/Http/Controllers/ServiceCategoryController.php
<?php

namespace App\Http\Controllers;

use App\ServiceCategory;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;

class ServiceCategoryController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $serviceCates = ServiceCategory::paginate(4);
        return view('admin.serviceCategory.index', compact('serviceCates'));
        //$serviceCate = ServiceCategory::paginate(4);
        //return response()->json($serviceCate, 200);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.serviceCategory.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'category_name' => 'required',
            'category_description' => 'required',
        ]);

        $serviceCate = new ServiceCategory();
        $serviceCate->category_name = $request->category_name;
        $serviceCate->category_description = $request->category_description;
        if ($request->status)
        {
            $serviceCate->status = 'enable';
        } else {
            $serviceCate->status = 'disable';
        }
        $serviceCate->save();

        return Redirect::to('/service-category')->with('successMsg', 'Service Categories Saved Successfully ):');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $serviceCate = ServiceCategory::findOrFail($id);
        return view('admin.serviceCategory.edit', compact('serviceCate'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'category_name' => 'required',
            'category_description' => 'required',
        ]);

        $serviceCate = ServiceCategory::findOrFail($id);
        $serviceCate->category_name = $request->category_name;
        $serviceCate->category_description = $request->category_description;
        if ($request->status)
        {
            $serviceCate->status = 'enable';
        } else {
            $serviceCate->status = 'disable';
        }
        $serviceCate->save();

        return Redirect::to('/service-category')->with('successMsg', 'Service Categories Updated Successfully ):');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $serviceCate = ServiceCategory::findOrFail($id);
        $serviceCate->delete();
        return Redirect::to('/service-category')->with('successMsg', 'Service Categories Deleted Successfully):');
    }

    public function unactive_service_category($id)
    {
        $unactive_category = ServiceCategory::findOrFail($id);
        $unactive_category->update(['status' => 'disable']);
        return Redirect::to('/service-category')->with('successMsg', 'Service Category Un-activated Successfully ):');
    }

    public function active_service_category($id)
    {
        $active_category = ServiceCategory::findOrFail($id);
        $active_category->update(['status' => 'enable']);
        return Redirect::to('/service-category')->with('successMsg', 'Service Category Activated Successfully ):');
    }

    public function search($category_name)
    {
        $search = ServiceCategory::where("category_name", "like", "%" . $category_name . "%")
                    ->get();
        return $search;
    }

}
<file_sep>/app/Service.php
<?php

namespace App;
//use App\ServiceCategory;
use App\Appointment;

use Illuminate\Database\Eloquent\Model;

class Service extends Model
{
    protected $table = 'services';

    protected $primaryKey = 'id';

    protected $fillable = [
        'service_name',
        'fee',
        'duration',
        'status',
    ];

    // public function serviceCategory()
    // {
    //     return $this->belongsTo(ServiceCategory::class);
    // }

    public function appointments()
    {
        return $this->hasMany(Appointment::class);
    }

}

<file_sep>/app/Http/Controllers/UsersController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UsersController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth.role:admin', ['only' => ['blockUser']]);
    }
    public function blockUser()
    {
        return '<b><h1>This is an admin route.</h1></b>';
    }
    public function profile()
    {
        return '<b><h1>This route is for all users.</h1></b>';
    }

}
<file_sep>/app/Http/Controllers/Admin/CheckoutController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Carbon;
use App\Http\Requests;
//use Session;
use Cart;

session_start();

class CheckoutController extends Controller
{
    public $loginAfterSignUp = true;

    public function login_check()
    {
        return view('pages.login');
    }

    public function customer_registration(Request $request)
    {
        $this->validate($request, [
            'customer_name' => 'required',
            'customer_email' => 'required',
            'password' => '<PASSWORD>',
            'mobile_number' => 'required',
        ]);

        $data = array();
        $data['customer_name'] = $request->customer_name;
        $data['customer_email'] = $request->customer_email;
        $data['password'] = md5($request->password);
        $data['mobile_number'] = $request->mobile_number;
        $data['created_at'] = Carbon::now(); //->toDateString();
        $data['updated_at'] = Carbon::now(); //->toDateString();

        // if ($this->loginAfterSignUp) {
        //     return $this->login($request);
        // }

        $customer_id = DB::table('customer')
                       ->insertGetId($data);

        // return response()->json([
        //     'success' => true,
        //     'data' => $customer_id
        // ], 200);

                Session::put('customer_id', $customer_id);
                Session::put('customer_name', $request->customer_name);
                return Redirect('/checkout');
    }

    public function checkout()
    {
        // $all_published_category = DB::table('category')
        //                           ->where('publication_status', 1)
        //                           ->get();
        // return view('pages.checkout', compact('all_published_category'));

        return view('pages.checkout');
    }

    public function save_shipping_details(Request $request)
    {
        $data = array();
        $data['shipping_email'] = $request->shipping_email;
        $data['shipping_first_name'] = $request->shipping_first_name;
        $data['shipping_last_name'] = $request->shipping_last_name;
        $data['shipping_address'] = $request->shipping_address;
        $data['shipping_mobile_number'] = $request->shipping_mobile_number;
        $data['shipping_city'] = $request->shipping_city;
        $data['created_at'] = Carbon::now(); //->toDateString();
        $data['updated_at'] = Carbon::now(); //->toDateString();

        $shipping_id = DB::table('shipping')
                       ->insertGetId($data);
            Session::put('shipping_id', $shipping_id);
            return Redirect::to('/payment');
    }

    public function customer_login(Request $request)
    {
        $customer_email = $request->customer_email;
        $password = md5($request->password);
        $result = DB::table('customer')
                  ->where('customer_email', $customer_email)
                  ->where('password', $password)
                  ->first();

            if ($result) {
                Session::put('customer_id', $result->customer_id, 'customer_name', $result->customer_name);
                //Session::put('customer_name', $result->customer_name);
                return Redirect::to('/checkout');
            }
            else {
                return Redirect::to('/login-check');
            }
    }

    public function payment()
    {
        return view('pages.payment');
    }

    public function order_place(Request $request)
    {
        $payment_gateway = $request->payment_method;

        $paymentData = array();
        $paymentData['payment_method'] = $payment_gateway;
        $paymentData['payment_status'] = 'pending';
        $paymentData['created_at'] = Carbon::now(); //->toDateString();
        $paymentData['updated_at'] = Carbon::now(); //->toDateString();
        $payment_id = DB::table('payment')
                      ->insertGetId($paymentData);

        $orderData = array();
        $orderData['customer_id'] = Session::get('customer_id');
        $orderData['shipping_id'] = Session::get('shipping_id');
        $orderData['payment_id'] = $payment_id;
        $orderData['order_total'] = Cart::total();
        $orderData['order_status'] = 'pending';
        $orderData['created_at'] = Carbon::now(); //->toDateTimeString();
        $orderData['updated_at'] = Carbon::now(); //->toDateString();
        $order_id = DB::table('order')
                    ->insertGetId($orderData);

        $contents = Cart::content();
        $orderData = array();

        foreach ($contents as $v_content)
        {
            $odData['order_id'] = $order_id;
            $odData['product_id'] = $v_content->id;
            $odData['tax'] = Cart::tax();
            $odData['total'] = Cart::total();
            $odData['product_name'] = $v_content->name;
            $odData['product_price'] = $v_content->price;
            $odData['product_sales_quantity'] = $v_content->qty;
            $odData['created_at'] = Carbon::now()->toDateTimeString();
            $odData['updated_at'] = Carbon::now()->toDateTimeString();

            DB::table('order_details')
                ->insert($odData);
        }

        if ($payment_gateway == 'handcash') {
            Cart::destroy();
            return view('pages.handcash');
            // Cart::destroy();
        }

        elseif ($payment_gateway == 'card') {
            echo "Successfully Done By Card";
        }

        elseif ($payment_gateway == 'paypal') {
            echo "Successfully Done By Paypal";
        }

        else {
            echo "No Payment Method Selected";
        }

    }

    public function manage_order()
    {
        $all_order_info = DB::table('order')
                   ->join('customer', 'order.customer_id', '=', 'customer.customer_id')
                   ->select('order.*', 'customer.customer_name')
                   ->get();

        return view('admin.manage_order', compact('all_order_info'));
    }

    public function view_order($order_id)
    {
        $order_by_id = DB::table('order')
                   ->join('customer', 'order.customer_id', '=', 'customer.customer_id')
                   ->join('order_details', 'order.order_id', '=', 'order_details.order_id')
                   ->join('shipping', 'order.shipping_id', '=', 'shipping.shipping_id')
                   ->select('order.*', 'order_details.*', 'shipping.*', 'customer.*')
                   ->get();

        return view('admin.view_order', compact('order_by_id'));
    }

    public function customer_logout()
    {
        Session::flush();
        return Redirect::to('/');
    }

    // private function sslapi()
    // {

    // }
}
<file_sep>/app/Http/Controllers/AppointmentController.php
<?php

namespace App\Http\Controllers;

use App\Appointment;
use App\Service;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;

class AppointmentController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $appointments = DB::table('appointments')
                    ->join('services', 'appointments.service_id', '=', 'services.id')
                    ->select('appointments.*', 'services.service_name', 'services.duration', 'services.fee')
                    //->oldest()
                    ->latest()
                    //->paginate(3);
                    ->get();
        //return view('admin.appointment.index', compact('appointments'));
        return response()->json($appointments, 200);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $services = Service::pluck('service_name', 'id');
        return view('appointment.create', compact('services'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'service_name' => 'required',
            'firstName' => 'required',
            'lastName' => 'required',
            'date' => 'required',
            'time' => 'required',
            'gender' => 'required',
            'email' => 'required | email',
            'phone' => 'required | numeric',
            'message' => 'required',
        ]);

        $appointment = new Appointment();
        $appointment->service_id = $request->service_name;
        $appointment->firstName = $request->firstName;
        $appointment->lastName = $request->lastName;
        $appointment->date = Carbon::now();
        $appointment->time = $request->time;
        $appointment->gender = $request->gender;
        $appointment->email = $request->email;
        $appointment->phone = $request->phone;
        $appointment->message = $request->message;
        if ($request->status)
        {
            $appointment->status = 'enable';
        } else {
            $appointment->status = 'disable';
        }

        $appointment->save();
        return Redirect::back()->with('successMsg', 'You Have Successfully Booked An Appointment !!!');

    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $service = Service::all();
        $appointment = Appointment::all();
        return view('admin.appointment.edit', compact('service', 'appointment'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'service_name' => 'required',
            'firstName' => 'required',
            'lastName' => 'required',
            'date' => 'required',
            'gender' => 'required',
            'email' => 'required | email',
            'phone' => 'required | phone',
            'message' => 'required',
        ]);

        $appointment = Appointment::findOrFail($id);
        $appointment->service_id = $request->service_name;
        $appointment->firstName = $request->firstName;
        $appointment->date = Carbon::now();
        $appointment->gender = $request->gender;
        $appointment->email = $request->email;
        $appointment->phone = $request->phone;
        $appointment->message = $request->message;
        if ($request->status)
        {
            $appointment->status = 'enable';
        } else {
            $appointment->status = 'disable';
        }

        $appointment->save();
        return Redirect::to('')->with('successMsg', 'Your Appointment Have Been Successfully Updated !!!');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $appointment = Appointment::findOrFail($id);
        $appointment->delete();
        return Redirect::to('')->with('successMsg', 'Appointment Was Successfully Deleted !!!');
    }
}
<file_sep>/routes/api.php
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\OminiPaymentController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });

Route::post('login', 'CheckoutController@login');
//Route::post('customer-register', 'CustomerApiController@customerRegister');
Route::post('register', 'CheckoutController@register');

// Route::post('login', 'ApiController@login');
// //Route::post('customer-register', 'CustomerApiController@customerRegister');
// Route::post('register', 'ApiController@register');
Route::post('/customer_registration', 'CheckoutController@customer_registration');

Route::group(['middleware' => 'auth.jwt'], function () {
    // Route::get('logout', 'ApiController@logout');
    Route::get('logout', 'CheckoutController@logout');

    //Route::get('user', 'ApiController@getAuthUser');
    Route::get('user', 'CheckoutController@getAuthUser');

    /////////////////////////  PRODUCT ROUTE  ////////////////////////////
    Route::get('products', 'ProductController@index');

    //////////////////  SHIPPING ROUTE  //////////////////
    Route::post('/save-shipping-details', 'CheckoutController@save_shipping_details');

    ////////////////// ORDER ROUTE ///////////////////
    Route::post('/order-place', 'CheckoutController@order_place');
    Route::get('/manage-order', 'CheckoutController@manage_order');
    Route::get('/view-order/{order_id}', 'CheckoutController@view_order');

    /////////////////////////////////  REVIEW ROUTE  ////////////////////////////////////
    Route::post('/reviews', 'ReviewsController@store');

});

Route::get('users/profile', ['uses' => 'UsersController@profile', 'as' => 'users.profile']);
Route::get('users/block', ['uses' => 'UsersController@blockUser', 'as' => 'users.block']);

///////////////////////////////////// SERVICE ROUTE ////////////////////////////////////////////
Route::get('/service', 'ServiceController@index');
Route::get('/create/service', 'ServiceController@create');
Route::post('/store/service', 'ServiceController@store');
Route::get('/edit/service/{id}', 'ServiceController@edit');
Route::put('/update/service/{id}', 'ServiceController@update');
Route::get('/delete/service/{id}', 'ServiceController@destroy');
Route::get('/service/unactive/{id}', 'ServiceController@unactive_service');
Route::get('/service/active/{id}', 'ServiceController@active_service');

///////////////////////  APPOINTMENT ROUTE  //////////////////////////////
Route::get('/appointment', 'AppointmentController@index');
Route::get('/create/appointment', 'AppointmentController@create');
Route::post('/save/appointment', 'AppointmentController@store');

Route::get('/', 'HomesController@index');

////////////////////////  SHOWING PRODUCT ROUTE  /////////////////////////
Route::get('/product_by_category/{category_id}', 'HomesController@show_product_by_category');
Route::get('/product_by_manufacture/{manufacture_id}', 'HomesController@show_product_by_manufacture');
Route::get('/view_product/{product_id}', 'HomesController@product_details_by_id');


////////////////////   CART ROUTE   ////////////////////////
Route::post('/add-to-cart', 'CartController@add_to_cart');
Route::get('/show-cart', 'CartController@show_cart');
Route::delete('/delete-to-cart/{rowId}', 'CartController@delete_to_cart');
Route::post('/update-cart', 'CartController@update_cart');

///////////////////  WISHLIST ROUTE  //////////////////
Route::post('/addToWishList', 'HomeController@wishList');
Route::get('/wishList', 'HomeController@view_wishList');
Route::get('/removeWishList/{id}', 'HomeController@removeWishList');

//////////////////////////////    PAYMENT ROUTE   ///////////////////////////////
/////////////////// OMINI PACKAGE IS OK ////////////////////////
//Route::get('payment', [OminiPaymentController::class, 'index']);
Route::post('/store/payment', [OminiPaymentController::class, 'store']);
Route::get('/success/payment', [OminiPaymentController::class, 'success']);
Route::put('/payment/details/{id}', [OminiPaymentController::class, 'payment_details']);


///////////////////   REVIEWS ROUTE  ///////////////////
Route::get('/product-show-review/{product_id}', 'HomeController@productReview');
Route::get('/show-reviews/{id}', 'ProductController@showReview');


//////////////////////  CATEGORY ROUTE  ////////////////////////
Route::get('/category', 'CategoryController@index');
Route::get('/category-id/{category_id}', 'CategoryController@category_by_id');


//////////////////////  MANUFACTURE ROUTE  ////////////////////////
Route::get('/manufacture', 'ManufactureController@index');
Route::get('/manufacture-id/{manufacture_id}', 'ManufactureController@manufacture_by_id');


// /////////////////////////  PRODUCT ROUTE  ////////////////////////////
// Route::get('products', 'ProductController@index');
Route::get('/products/{product_id}', 'ProductController@show_product_by_id');

////////////////////////  SEARCH ROUTE  ///////////////////////////
Route::get('/search-product', 'ProductController@search');
// Route::get('/search-product/{product_name}', 'ProductController@search');

Route::get('/search-category/{category_name}', 'CategoryController@search');

Route::get('/search-manufacture/{manufacture_name}', 'ManufactureController@search');

/////////////////////////////////  REVIEW ROUTE  ////////////////////////////////////
Route::get('/review', 'ReviewsController@index');

//Route::apiResource('products/{product}/reviews', 'ReviewController')->only('store', 'update', 'destroy');

<file_sep>/app/Http/Controllers/CheckoutController.php
<?php

namespace App\Http\Controllers;

use App\Http\Requests\RegisterAuthRequest;
use App\User;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Cart;

class CheckoutController extends Controller
{
    public $loginAfterSignUp = true;

    public function register(RegisterAuthRequest $request)
    {
        $user = new User();
        $user->name = $request->name;
        $user->email = $request->email;
        $user->phone = $request->phone;
        $user->password = <PASSWORD>($request->password);
        $user->save();

        if ($this->loginAfterSignUp) {
            return $this->login($request);
        }

        return response()->json([
            'success' => true,
            'data' => $user
        ], 200);
    }

    public function login(Request $request)
    {
        $input = $request->only('email', 'password');
        $jwt_token = null;

        if (!$jwt_token = JWTAuth::attempt($input)) {
            return response()->json([
                'success' => false,
                'message' => 'Invalid Email or Password',
            ], 401);
        }

        return response()->json([
            'success' => true,
            'token' => $jwt_token,
        ]);
    }

    public function logout(Request $request)
    {
        $this->validate($request, [
            'token' => 'required'
        ]);

        try {
            JWTAuth::invalidate($request->token);

            return response()->json([
                'success' => true,
                'message' => 'User logged out successfully'
            ]);
        } catch (JWTException $exception) {
            return response()->json([
                'success' => false,
                'message' => 'Sorry, the user cannot be logged out'
            ], 500);
        }
    }

    public function getAuthUser(Request $request)
    {
        $this->validate($request, [
            'token' => 'required'
        ]);

        $user = JWTAuth::authenticate($request->token);

        return response()->json(['user' => $user]);
    }

    public function save_shipping_details(Request $request)
    {
        $data = array();
        $data['shipping_email'] = $request->shipping_email;
        $data['shipping_first_name'] = $request->shipping_first_name;
        $data['shipping_last_name'] = $request->shipping_last_name;
        $data['shipping_address'] = $request->shipping_address;
        $data['shipping_mobile_number'] = $request->shipping_mobile_number;
        $data['shipping_city'] = $request->shipping_city;
        $data['created_at'] = Carbon::now(); //->toDateString();
        $data['updated_at'] = Carbon::now(); //->toDateString();

        $shipping_id = DB::table('shipping')
                       ->insertGetId($data);
            Session::put('shipping_id', $shipping_id);

        return response()->json([
            'success' => true,
            'data' => $shipping_id
        ], 200);
            //return Redirect::to('/payment');
    }

    public function payment()
    {
        return view('pages.payment');
    }

    public function order_place(Request $request)
    {
        $payment_gateway = $request->payment_method;

        $paymentData = array();
        $paymentData['payment_method'] = $payment_gateway;
        $paymentData['payment_status'] = 'pending';
        $paymentData['created_at'] = Carbon::now(); //->toDateString();
        $paymentData['updated_at'] = Carbon::now(); //->toDateString();
        $payment_id = DB::table('payment')
                      ->insertGetId($paymentData);

        $orderData = array();
        $orderData['user_id'] = Session::get('user_id');
        $orderData['shipping_id'] = Session::get('shipping_id');
        $orderData['payment_id'] = $payment_id;
        $orderData['order_total'] = Cart::total();
        $orderData['order_status'] = 'pending';
        $orderData['created_at'] = Carbon::now(); //->toDateTimeString();
        $orderData['updated_at'] = Carbon::now(); //->toDateString();
        $order_id = DB::table('order')
                    ->insertGetId($orderData);

        $contents = Cart::content();
        $orderData = array();

        foreach ($contents as $v_content)
        {
            $odData['order_id'] = $order_id;
            $odData['product_id'] = $v_content->id;
            $odData['tax'] = Cart::tax();
            $odData['total'] = Cart::total();
            $odData['product_name'] = $v_content->name;
            $odData['product_price'] = $v_content->price;
            $odData['product_sales_quantity'] = $v_content->qty;
            $odData['created_at'] = Carbon::now()->toDateTimeString();
            $odData['updated_at'] = Carbon::now()->toDateTimeString();

            DB::table('order_details')
                ->insert($odData);
        }

        if ($payment_gateway == 'handcash') {
            Cart::destroy();
            return view('pages.handcash');
            // Cart::destroy();
            return response()->json([
                'success' => true,
                'message' => 'Transaction Successfully Done By Handcash !!!',
            ], 200);
            //return response()->json('handcash', 200);
        }

        elseif ($payment_gateway == 'card') {
            echo "Successfully Done By Card";
        }

        elseif ($payment_gateway == 'paypal') {
            echo "Successfully Done By Paypal";
        }

        else {
            echo "No Payment Method Selected";
        }

    }

    public function manage_order()
    {
        $all_order_info = DB::table('order')
                   ->join('users', 'order.user_id', '=', 'users.user_id')
                   ->select('order.*', 'users.name')
                   ->get();

        //return view('admin.manage_order', compact('all_order_info'));
        return response()->json([
            'success' => true,
            'data' => $all_order_info,
            'message' => 'This is all successfully placed orders !!!',
        ], 200);
    }

    public function view_order($order_id)
    {
        $order_by_id = DB::table('order')
                   ->join('users', 'order.user_id', '=', 'users.user_id')
                   ->join('order_details', 'order.order_id', '=', 'order_details.order_id')
                   ->join('shipping', 'order.shipping_id', '=', 'shipping.shipping_id')
                   ->select('order.*', 'order_details.*', 'shipping.*', 'users.*')
                   ->get();

        //return view('admin.view_order', compact('order_by_id'));

        return response()->json([
            'success' => true,
            'data' => $order_by_id,
            'message' => 'This is a successfully placed order !!!',
        ], 200);
    }

    // public function customer_logout()
    // {
    //     Session::flush();
    //     return Redirect::to('/');
    // }

}
<file_sep>/app/Http/Controllers/AboutUsController.php
<?php

namespace App\Http\Controllers;

use App\AboutUs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;

class AboutUsController extends Controller
{
    public function aboutUs()
    {
        $aboutUs = AboutUs::simplePaginate(3);
        return view('admin.aboutUs.index', compact('aboutUs'));
    }

    public function createAboutUs()
    {
        return view('admin.aboutUs.create');
    }

    public function saveAboutUs(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'years_of_experience' => 'required',
            'email' => 'required | email',
            'company' => 'required',
            'website' => 'required | url',
        ]);

        $aboutUs = new AboutUs();
        $aboutUs->name = $request->name;
        $aboutUs->years_of_experience = $request->years_of_experience;
        $aboutUs->email = $request->email;
        $aboutUs->company = $request->company;
        $aboutUs->website = $request->website;
        if ($request->status)
        {
            $aboutUs->status = 'enable';
        } else {
            $aboutUs->status = 'disable';
        }
        $aboutUs->save();

        return Redirect::to('/aboutus')->with('successMsg', 'About Us Page Created Successfully !!!');

    }

    public function editAboutUs($id)
    {
        $aboutUs = AboutUs::findOrFail($id);
        return view('admin.aboutUs.edit', compact('aboutUs'));
    }

    public function updateAboutUs(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required',
            'years_of_experience' => 'required',
            'email' => 'required | email',
            'company' => 'required',
            'website' => 'required | url',
        ]);

        $aboutUs = AboutUs::findOrFail($id);
        $aboutUs->name = $request->name;
        $aboutUs->years_of_experience = $request->years_of_experience;
        $aboutUs->email = $request->email;
        $aboutUs->company = $request->company;
        $aboutUs->website = $request->website;
        if ($request->status)
        {
            $aboutUs->status = 'enable';
        } else {
            $aboutUs->status = 'disable';
        }
        $aboutUs->save();

        return Redirect::to('/aboutus')->with('successMsg', 'About Us Page Updated Successfully !!!');

    }

    public function deleteAboutUs($id)
    {
        $aboutUs = AboutUs::findOrFail($id);
        $aboutUs->delete();
        return Redirect::to('/aboutus')->with('successMsg', 'About Us Page Deleted Successfully !!!');
    }

    public function unactive_aboutUs($id)
    {
        $unactive_aboutUs = AboutUs::findOrFail($id);
        $unactive_aboutUs->update(['status' => 'disable']);
        return Redirect::to('/aboutus')->with('successMsg', 'About Us Un-activated Successfully ):');
    }

    public function active_aboutUs($id)
    {
        $active_aboutUs = AboutUs::findOrFail($id);
        $active_aboutUs->update(['status' => 'enable']);
        return Redirect::to('/aboutus')->with('successMsg', 'About Us Activated Successfully ):');
    }

}

// 'name',
//         'email',
//         'company',
//         'website',
<file_sep>/app/Http/Controllers/BlogController.php
<?php

namespace App\Http\Controllers;

use App\Blog;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Str;

class BlogController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $blogs = Blog::latest()->get();
        return view('admin.blog.index', compact('blogs'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.blog.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'title' => 'required',
            'body' => 'required',
            'image' => 'required | file',
        ]);

        $image = $request->file('image');
        $slug = Str::slug($request->name);

        if (isset($image))
        {
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug . '-' . $currentDate . '-' . uniqid() . '.' . $image->getClientOriginalExtension();

            if (!file_exists('uploads/blog'))
            {
                mkdir('uploads/blog', 0777, true);
            }

            $image->move('uploads/blog', $imagename);
        }

        else
        {
            $imagename = 'default.png';
        }

        $blog = new Blog();
        $blog->title = $request->title;
        $blog->body = $request->body;
        $blog->image = $imagename;
        if ($request->status)
        {
            $blog->status = 'enable';
        } else {
            $blog->status = 'disable';
        }
        $blog->save();

        return redirect('/blogs')->with('successMsg', 'Your Post Has been Successfully Saved !');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $blog = Blog::findOrFail($id);
        return view('admin.blog.edit', compact('blog'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'title' => 'required',
            'body' => 'required',
        ]);

        $image = $request->file('image');
        $slug = Str::slug($request->name);
        //$slug = str_slug($request->name);
        $blog = Blog::findOrFail($id);

        if (isset($image))
        {
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug . '-' . $currentDate . '-' . uniqid() . '.' . $image->getClientOriginalExtension();

            if (!file_exists('uploads/blog'))
            {
                mkdir('uploads/blog', 0777, true);
            }

            $image->move('uploads/blog', $imagename);
        }

        else
        {
            $imagename = 'default.png';
        }

        $blog->title = $request->title;
        $blog->body = $request->body;
        $blog->image = $imagename;
        if ($request->status)
        {
            $blog->status = 'enable';
        } else {
            $blog->status = 'disable';
        }
        $blog->save();

        return redirect('/blogs')->with('successMsg', 'Your Post Has been Successfully Updated !');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $blog = Blog::findOrFail($id);
        $blog->delete();
        return redirect('/blogs')->with('successMsg', 'Your Post Has been Successfully Deleted !');
    }

    public function unactive_blog($id)
    {
        $unactive_blog = Blog::findOrFail($id);
        $unactive_blog->update(['status' => 'disable']);
        return Redirect::to('/blogs')->with('successMsg', 'Blog Post Un-activated Successfully ):');
    }

    public function active_blog($id)
    {
        $active_blog = Blog::findOrFail($id);
        $active_blog->update(['status' => 'enable']);
        return Redirect::to('/blogs')->with('successMsg', 'Blog Post Activated Successfully ):');
    }

    // public function search($blog_title)
    // {
    //     $search = Blog::where("category_name", "like", "%" . $blog_title . "%")
    //                 ->get();
    //     return $search;
    // }

}

<file_sep>/app/Http/Controllers/ContactUsController.php
<?php

namespace App\Http\Controllers;

use App\ContactUs;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;

class ContactUsController extends Controller
{
    public function contacts()
    {
        $contacts = ContactUs::simplePaginate(3);
        return view('admin.contactUs.index', compact('contacts'));
    }

    public function createContact()
    {
        return view('contactUs.create');
    }

    public function saveContact(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'email' => 'required | email',
            'phone' => 'required | numeric',
            'message' => 'required',
        ]);

        $contact = new ContactUs();
        $contact->name = $request->name;
        $contact->email = $request->email;
        $contact->phone = $request->phone;
        $contact->message = $request->message;
        $contact->save();

        return Redirect::back()->with('successMsg', 'Thanks for contacting us, we will get back to you shortly !!!');

    }

}
<file_sep>/app/Http/Controllers/OminiPaymentController.php
<?php

namespace App\Http\Controllers;

use App\Payment;
use App\User;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Omnipay\Omnipay;

class OminiPaymentController extends Controller
{
    public $gateway;

    public function __construct()
    {
        $this->gateway = Omnipay::create('PayPal_Pro');
        $this->gateway->setUsername(env('PAYPAL_API_USERNAME', 'sb-ni47s46317465_api1.business.example.com'));
        $this->gateway->setPassword(env('PAYPAL_API_PASSWORD', '<PASSWORD>'));
        $this->gateway->setSignature(env('PAYPAL_API_SIGNATURE', 'A02X.K7GjnEoug.blfyz-e3rD5F9APMmKnNonXliUkjyy06S.iF0288n'));
        $this->gateway->setTestMode(true); // here 'true' is for sandbox. Pass 'false' when go live
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('payment.payment');
    }

    public function store(Request $request)
    {
        $arr_expiry = explode("/", $request->input('expiry'));

        $formData = array(
            'firstName' => $request->input('first-name'),
            'lastName' => $request->input('last-name'),
            'number' => $request->input('number'),
            'expiryMonth' => trim($arr_expiry[0]),
            'expiryYear' => trim($arr_expiry[1]),
            'cvv' => $request->input('cvc'),
            //'user' => Auth::user()
        );

        try {
            // Send purchase request
            $response = $this->gateway->purchase([
                'amount' => $request->input('amount'),
                'currency' => 'USD',
                'card' => $formData
            ])->send();

            // Process response
            if ($response->isSuccessful()) {

                // Payment was successful
                $arr_body = $response->getData();
                $amount = $arr_body['AMT'];
                $currency = $arr_body['CURRENCYCODE'];
                $transaction_id = $arr_body['TRANSACTIONID'];
                //$message = $arr_body['SUCCESS'];

                //$isPaymentExist = Payment::where('payment_id', auth()->user()->id)->first();
                $isPaymentExist = Payment::where('user_id', auth()->user()->id)->first();

                if(!$isPaymentExist)
                {
                    $payment = new Payment();
                    //$payment->payment_id = $request->transaction_id;
                    $payment->payer_email = $request->email; //['payer']['payer_info']['payer_id'];
                    $payment->firstName = Auth::user()->firstName;;
                    $payment->lastName = Auth::user()->lastName;;
                    $payment->user_email = Auth::user()->email; //$request->email; //$arr_body['payer']['payer_info']['email'];
                    $payment->amount = $request->amount; //$arr_body['transactions'][0]['amount']['total'];
                    //$payment->currency = env('PAYPAL_CURRENCY');
                    $payment->user_id = Auth::user()->id;
                    // $payment->associate_id = $request->associate_id;
                    // $payment->corporate_id = $request->corporate_id;
                    // $payment->fellow_id =  $request->fellow_id;
                    // $payment->full_id = $request->full_id;
                    // $payment->student_id = $request->student_id;
                    $payment->payment_status = true; //$arr_body['state'];
                    if(!isset($request->payment))
                    {
                        $payment->payment = 'paid';
                    } else {
                        $payment->payment = 'not-paid';
                    }
                    $payment->save();

                    // if ($payment->payment_status == true)
                    // {
                    //     Student::where('payment_id', 0)->update([
                    //         'payment_id' => 1
                    //     ]);
                    // }

                    // DB::table('users')->where('users.id', $id)->where('usertype', 'null')
                    //                   ->update(['usertype' => 'student']);
                    // DB::table('users')
                    //                 ->where('users.id', $id)
                    //                 ->where('usertype', 'null')->update([
                    //     'usertype' => 'student'
                    // ]);

                }


                //$user = User::where('usertype', '=', 'admin')->get();

                //// $data = [];
                //// $data['firstName'] = Auth::user();
                //// $data['title'] = 'Title';

                //$data = Auth::user()->email;
                //Notification::send($user, new PaymentNotification($data));

                return response()->json([
                    'success' => true,
                    'payment' => $amount,
                    'currency' => $currency,
                    'transaction_id' => $transaction_id,
                    //'data' => $user
                ], 200);

                //return Redirect::to('/success/payment')->with('success', 'Payment of ' . $amount .' '. $currency  . ' is successful.  Your Transaction ID is : ' . $transaction_id);

                //echo "Payment of $amount $currency is successful. Your Transaction ID is: $transaction_id";
            } else {
                // Payment failed
                return response()->json([
                    'success' => false,
                    'message' => 'Payment failed. ' . $response->getMessage(),
                ], 401);
                //return Redirect::to('/failed/payment')->with('error', 'Payment failed. ' . $response->getMessage());
                //echo "Payment failed. ". $response->getMessage();
            }
        } catch(Exception $e) {
            echo $e->getMessage();
        }

    }

}
<file_sep>/app/Http/Controllers/CategoryController.php
<?php

namespace App\Http\Controllers;

use App\Category;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use App\Http\Requests;
use Carbon\Carbon;
use Session;
session_start();

class CategoryController extends Controller
{
    public function admin_index()
    {
        return view('admin.category.create');
    }

    public function index()
    {
        $dataC = Category::paginate(4);
        return response()->json($dataC, 200);

    }

    public function all_category()
    {
        $categories = Category::paginate(4);
        // $all_category_info = DB::table('category')->paginate(5); //->get();
        return view('admin.category.index', compact('categories'));
    }

    public function category_by_id($category_id)
    {
        $category_by_id = Category::findOrFail($category_id);
        return response()->json($category_by_id, 200);

    }

    public function save_category(Request $request)
    {
        $this->validate($request, [
            'category_name' => 'required',
            'category_description' => 'required',
        ]);

        $data = new Category();
        $data['category_id'] = $request->category_id;
        $data['category_name'] = $request->category_name;
        $data['category_description'] = $request->category_description;

        if(isset($request->status))
        {
            $data->status = 'enable';
        } else {
            $data->status = 'disable';
        }

        $data->save();
        return redirect('all-category')->with('successMsg', 'Category Saved Successfully ):');
    }

    public function edit_category($category_id)
    {
        $category_info = Category::findOrFail($category_id);
        return view('admin.category.edit', compact('category_info'));
    }

    public function update_category(Request $request, $category_id)
    {
        $category = Category::findOrFail($category_id);
        $category->category_name = $request->category_name;
        $category->category_description = $request->category_description;
        //$category->updated_at = $request->updated_at;
        $category->updated_at     = Carbon::now();
        $category->save();
        return Redirect::to('/all-category')->with('successMsg', 'Category Updated Successfully ):');
    }

    public function delete_category($category_id)
    {
        $deleteC = Category::findOrFail($category_id);
        $deleteC->delete();
        return Redirect::to('/all-category')->with('successMsg', 'Category Deleted Successfully ):');
    }

    public function unactive_category($category_id)
    {
        $unactive_category = Category::findOrFail($category_id);
        $unactive_category->update(['status' => 'disable']);
        return Redirect::to('/all-category')->with('successMsg', 'Category Un-activated Successfully ):');
    }

    public function active_category($category_id)
    {
        $active_category = Category::findOrFail($category_id);
        $active_category->update(['status' => 'enable']);
        return Redirect::to('/all-category')->with('successMsg', 'Category Activated Successfully ):');
    }

    public function search($category_name)
    {
        $search = Category::where("category_name", "like", "%" . $category_name . "%")
                    ->get();
        return $search;
    }

}
<file_sep>/app/Http/Controllers/ServiceController.php
<?php

namespace App\Http\Controllers;

use App\Service;
use App\ServiceCategory;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;

class ServiceController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $services = Service::all();
        return response()->json($services, 200);
        //return view('admin.service.index', compact('services'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.service.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'service_name' => 'required',
            'fee' => 'required | numeric',
            'duration' => 'required',
        ]);

        $service = new Service();
        $service->service_name = $request->service_name;
        $service->fee = $request->fee;
        $service->duration = $request->duration;
       
        if ($request->status)
        {
            $service->status = 'enable';
        } else {
            $service->status = 'disable';
        }

        $service->save();
        return Redirect::to('/service')->with('successMsg', 'Service Saved Successfully ):');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $service = Service::findOrFail($id);
        return view('admin.service.edit', compact('service'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'service_name' => 'required',
            'fee' => 'required | numeric',
            'duration' => 'required',
        ]);

        $service = Service::findOrFail($id);
        $service->service_name = $request->service_name;
        $service->fee = $request->fee;
        $service->duration = $request->duration;
        
        if ($request->status)
        {
            $service->status = 'enable';
        } else {
            $service->status = 'disable';
        }

        $service->save();
        return Redirect::to('/service')->with('successMsg', 'Service Updated Successfully ):');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $service = Service::findOrFail($id);
        $service->delete();
        return Redirect::to('/service')->with('successMsg', 'Service Deleted Successfully ):');
    }

    public function unactive_service($id)
    {
        $unactive_service = Service::findOrFail($id);
        $unactive_service->update(['status' => 'disable']);
        return Redirect::to('/service')->with('successMsg', 'Service Un-activated Successfully ):');
    }

    public function active_service($id)
    {
        $active_service = Service::findOrFail($id);
        $active_service->update(['status' => 'enable']);
        return Redirect::to('/service')->with('successMsg', 'Service Activated Successfully ):');
    }

    // public function search($category_name)
    // {
    //     $search = ServiceCategory::where("category_name", "like", "%" . $category_name . "%")
    //                 ->get();
    //     return $search;
    // }

}
<file_sep>/app/WishList.php
<?php

namespace App;

use App\Customer;
use App\User;
use Illuminate\Database\Eloquent\Model;

class WishList extends Model
{
    protected $table = 'wish_lists';

    protected $primaryKey = 'id';

    protected $fillable = [
        'user_id',
        'product_id',
    ];

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }

}
<file_sep>/app/Http/Controllers/Admin/CustomerApiiController.php
<?php

namespace App\Http\Controllers;

use App\Http\Requests\CustomerRegisterRequest;
use App\Customer;
use Illuminate\Http\Request;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;


class CustomerApiController extends Controller
{
    public $loginAfterSignUp = true;

    public function customerRegister(CustomerRegisterRequest $request)
    {
        $customer = new Customer();
        $customer->customer_name = $request->customer_name;
        $customer->customer_email = $request->customer_email;
        $customer->password = <PASSWORD>($request->password);
        $customer->mobile_number = bcrypt($request->mobile_number);
        $customer->save();

        if ($this->loginAfterSignUp) {
            return $this->login($request);
        }

        return response()->json([
            'success' => true,
            'data' => $customer
        ], 200);
    }

    public function login(Request $request)
    {
        $input = $request->only('email', 'password');
        $jwt_token = null;

        if (!$jwt_token = JWTAuth::attempt($input)) {
            return response()->json([
                'success' => false,
                'message' => 'Invalid Email or Password',
            ], 401);
        }

        return response()->json([
            'success' => true,
            'token' => $jwt_token,
        ]);
    }

    public function logout(Request $request)
    {
        $this->validate($request, [
            'token' => 'required'
        ]);

        try {
            JWTAuth::invalidate($request->token);

            return response()->json([
                'success' => true,
                'message' => 'User logged out successfully'
            ]);
        } catch (JWTException $exception) {
            return response()->json([
                'success' => false,
                'message' => 'Sorry, the user cannot be logged out'
            ], 500);
        }
    }

    public function getAuthUser(Request $request)
    {
        $this->validate($request, [
            'token' => 'required'
        ]);

        $customer = JWTAuth::authenticate($request->token);

        return response()->json(['customer' => $customer]);
    }
}
<file_sep>/routes/web.php
<?php

/*
|--------------------------------------------------------------------------
| 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!
|
*/

// Route::get('/', function () {
//     return view('layout');
// });

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\CheckoutController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\OminiPaymentController;

Route::get('/', function () {
    return view('/welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::group(['middleware' => ['auth', 'admin']], function () {

    ////////////////////////////// DASHBOARD /////////////////////////////
    Route::get('/dashboard', 'Admin\DashboardController@dashboard')->name('dashboard');
    Route::get('/dashboard', 'Admin\DashboardController@index')->name('dashboard');


    ////////////////////////////  REGISTER ROLE ///////////////////////////////
    Route::get('/role-register', 'Admin\AdminController@registered')->name('role-register');
    Route::get('/edit/{id}', 'Admin\AdminController@edit')->name('edit');
    Route::put('/update/{id}', 'Admin\AdminController@update')->name('update');
    Route::delete('/delete/{id}', 'Admin\AdminController@delete')->name('delete');


    /////////////////////////// CATEGORY ROUTE /////////////////////////
    Route::get('/add-category', 'CategoryController@admin_index');
    Route::get('/all-category', 'CategoryController@all_category');
    Route::post('/save-category', 'CategoryController@save_category');
    Route::get('/edit-category/{category_id}', 'CategoryController@edit_category');
    Route::put('/update-category/{category_id}', 'CategoryController@update_category');
    Route::get('/delete-category/{category_id}', 'CategoryController@delete_category');
    Route::get('/unactive_category/{category_id}', 'CategoryController@unactive_category');
    Route::get('/active_category/{category_id}', 'CategoryController@active_category');

    ////////////////////////////// SERVICE CATEGORIES ROUTE ////////////////////////////////////
    Route::get('/service-category', 'ServiceCategoryController@index');
    Route::get('/create/service-category', 'ServiceCategoryController@create');
    Route::post('/store/service-category', 'ServiceCategoryController@store');
    Route::get('/edit/service-category/{id}', 'ServiceCategoryController@edit');
    Route::put('/update/service-category/{id}', 'ServiceCategoryController@update');
    Route::get('/delete/service-category/{id}', 'ServiceCategoryController@destroy');
    Route::get('/service/unactive_category/{id}', 'ServiceCategoryController@unactive_service_category');
    Route::get('/service/active_category/{id}', 'ServiceCategoryController@active_service_category');

    ///////////////////////////////////// SERVICE ROUTE ////////////////////////////////////////////
    Route::get('/service', 'ServiceController@index');
    Route::get('/create/service', 'ServiceController@create');
    Route::post('/store/service', 'ServiceController@store');
    Route::get('/edit/service/{id}', 'ServiceController@edit');
    Route::put('/update/service/{id}', 'ServiceController@update');
    Route::get('/delete/service/{id}', 'ServiceController@destroy');
    Route::get('/service/unactive/{id}', 'ServiceController@unactive_service');
    Route::get('/service/active/{id}', 'ServiceController@active_service');


    ////////////////////////////    MANUFACTURE ROUTE ////////////////////////
    Route::get('/all-manufacture', 'ManufactureController@all_manufacture');
    Route::get('/add-manufacture', 'ManufactureController@manufacture_create');
    Route::post('/save-manufacture', 'ManufactureController@save_manufacture');
    Route::get('/show-manufacture/{manufacture_id}', 'ManufactureController@show');
    Route::get('/edit-manufacture/{id}', 'ManufactureController@edit_manufacture');
    Route::post('/update-manufacture/{id}', 'ManufactureController@update_manufacture');
    Route::get('/delete-manufacture/{id}', 'ManufactureController@delete_manufacture');
    Route::get('/unactive_manufacture/{id}', 'ManufactureController@unactive_manufacture');
    Route::get('/active_manufacture/{id}', 'ManufactureController@active_manufacture');


    ///////////////////////////     PRODUCT ROUTE  /////////////////////////
    Route::get('/add-product', 'ProductController@product_create');
    Route::post('/save-product', 'ProductController@save_product');
    Route::get('/all-product', 'ProductController@all_product');
    Route::get('/show-product/{product_id}', 'ProductController@show');
    Route::get('/edit-product/{product_id}', 'ProductController@edit');
    Route::put('/update-product/{product_id}', 'ProductController@update_product');
    Route::get('/delete-product/{id}', 'ProductController@delete_product');
    Route::get('/unactive_product/{product_id}', 'ProductController@unactive_product');
    Route::get('/active_product/{product_id}', 'ProductController@active_product');

    ////////////////////////////// BLOG ROUTE /////////////////////////////
    Route::get('/blogs', [BlogController::class, 'index']);
    Route::get('/create/blogs', [BlogController::class, 'create']);
    Route::post('/store/blogs', [BlogController::class, 'store']);
    Route::get('/show/blogs/{id}', [BlogController::class, 'show']);
    Route::get('/edit/blogs/{id}', [BlogController::class, 'edit']);
    Route::put('/update/blogs/{id}', [BlogController::class, 'update']);
    Route::delete('/delete/blogs/{id}', [BlogController::class, 'destroy']);
    Route::get('/blog/unactive/{id}', [BlogController::class, 'unactive_blog']);
    Route::get('/blog/active/{id}', [BlogController::class, 'active_blog']);

    ///////////////////////  ABOUT US ROUTE  /////////////////////////////
    Route::get('/aboutus', 'AboutUsController@aboutUs');
    Route::get('/create/aboutus', 'AboutUsController@createAboutUs');
    Route::post('/save/aboutus', 'AboutUsController@saveAboutUs');
    Route::get('/edit/aboutus/{id}', 'AboutUsController@editAboutUs');
    Route::put('/update/aboutus/{id}', 'AboutUsController@updateAboutUs');
    Route::get('/delete/aboutus/{id}', 'AboutUsController@deleteAboutUs');
    Route::get('/aboutus/unactive/{id}', 'AboutUsController@unactive_aboutUs');
    Route::get('/aboutus/active/{id}', 'AboutUsController@active_aboutUs');

    ///////////////////////  APPOINTMENT ROUTE  //////////////////////////////
    Route::get('/appointment', 'AppointmentController@index');

    ///////////////////////  CONTACT US ROUTE  ////////////////////////////
    Route::get('/contact-us', 'ContactUsController@contacts');

});


Route::get('/', 'HomeController@index');

Route::get('/product_by_category/{category_id}', 'HomeController@show_product_by_category');
Route::get('/product_by_manufacture/{manufacture_id}', 'HomeController@show_product_by_manufacture');
Route::get('/view_product/{product_id}', 'HomeController@product_details_by_id');

///////////////////////  APPOINTMENT ROUTE  //////////////////////////////
Route::get('/create/appointment', 'AppointmentController@create');
Route::post('/save/appointment', 'AppointmentController@store');

///////////////////////  CONTACT US ROUTE  ////////////////////////////
Route::get('/create/contact-us', 'ContactUsController@createContact');
Route::post('/save/contact-us', 'ContactUsController@saveContact');

////////////////////   CART ROUTE   ////////////////////////
Route::post('/add-to-cart', 'CartController@add_to_cart');
Route::get('/show-cart', 'CartController@show_cart');
Route::get('/delete-to-cart/{rowId}', 'CartController@delete_to_cart');
Route::post('/update-cart', 'CartController@update_cart');

///////////////////////// CHECKOUT ROUTE   ////////////////////////
Route::get('/login-check', 'CheckoutController@login_check');
Route::post('/customer_registration', 'CheckoutController@customer_registration');
Route::get('/checkout', 'CheckoutController@checkout');
Route::post('/save-shipping-details', 'CheckoutController@save_shipping_details');

////////////////////  CUSTOMER LOGIN AND LOGOUT ROUTE  ////////////////
Route::post('/customer_login', 'CheckoutController@customer_login');
Route::get('/customer_logout', 'CheckoutController@customer_logout');

Route::get('/payment', 'CheckoutController@payment');
Route::post('/order-place', 'CheckoutController@order_place');

Route::get('/manage-order', 'CheckoutController@manage_order');
Route::get('/view-order/{order_id}', 'CheckoutController@view_order');

//////////////////////////////    PAYMENT ROUTE   ///////////////////////////////
/////////////////// OMINI PACKAGE IS OK ////////////////////////
Route::get('payment', [OminiPaymentController::class, 'index']);
Route::post('/store/payment', [OminiPaymentController::class, 'store']);
Route::get('/success/payment', [OminiPaymentController::class, 'success']);
Route::put('/payment/details/{id}', [OminiPaymentController::class, 'payment_details']);




////////////////////////////    SLIDER ROUTE   ////////////////////////
Route::get('/sliders', 'SliderController@index');
Route::get('/create/slider', 'SliderController@create');
Route::post('/save-slider', 'SliderController@save_slider');
//Route::get('/all-slider', 'SliderController@all_slider');
Route::delete('/delete-slider/{id}', 'SliderController@delete_slider');
Route::get('/unactive_slider/{id}', 'SliderController@unactive_slider');
Route::get('/active_slider/{id}', 'SliderController@active_slider');

///////////////////  SEARCH ROUTE  ////////////////////////
Route::get('/search', 'ProductController@search');


///////////////////   REVIEWS ROUTE  ///////////////////
Route::get('/product-show-review/{product_id}', 'HomeController@productReview');
Route::get('/show-reviews/{id}', 'ProductController@showReview');
Route::post('/reviews', 'ReviewsController@store');


///////////////////  ADD TO WISHLIST ROUTE  //////////////////
Route::post('/addToWishList', 'HomeController@wishList');
Route::get('/wishList', 'HomeController@view_wishList');
Route::get('/removeWishList/{id}', 'HomeController@removeWishList');






// Route::post('products/{product_id}/#reviews-anchor', 'ReviewController@storeReview'); //->only('store', 'update', 'destroy');
// Route::post('/products/{product_id}', 'ReviewController@storeReview'); //->only('store', 'update', 'destroy');
// Route::get('/product-review/{product_id}', 'ReviewController@product_review_by_id');
// Route::get('/product-review/{product_id}/#reviews-anchor', 'ReviewController@reviews_anchor');
// Route::get('/productReviews/{product_id}', 'ReviewController@index');

// Route::get('/search-category/{category_name}', 'CategoryController@search');

// Route::get('/search-manufacture/{manufacture_name}', 'ManufactureController@search');

<file_sep>/app/Http/Controllers/ProductController.php
<?php

namespace App\Http\Controllers;

use App\Category;
use App\Product;
use JWTAuth;
//use Tymon\JWTAuth\Facades\JWTAuth;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use App\Http\Requests;
use App\Manufacture;
use App\Review;
use Carbon\Carbon;
use Session;
session_start();

class ProductController extends Controller
{
    protected $user;

    /**
     * The attributes that is for user authentication
     *
     *
     */
    // public function __construct()
    // {
    //     $this->user = JWTAuth::parseToken()->authenticate();
    // }

    public function __construct()
    {
        //$this->middleware('auth.role:admin');
        //$this->middleware('auth.role:admin', ['except' => ['index']]);
    }

    /**
     * The attributes that is for all products
     *
     *
     */
    public function all_product()
    {
        // $categories = Category::all();
        // $all_manufacture_info = Manufacture::all();
        // $products = Product::paginate(5);
        // return view('admin.product.index', compact('categories', 'all_manufacture_info', 'products'));

        $products = DB::table('products')
                    ->join('categories', 'products.category_id', '=', 'categories.category_id')
                    ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                    ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                    //->orderBy('product_id', 'asc')
                    ->oldest()
                    //->latest()
                    ->paginate(4);
        return view('admin.product.index', compact('products'));
    }

    public function index()
    {
        return $this->user = DB::table('products')
                   ->join('categories', 'products.category_id', '=', 'categories.category_id')
                   ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                   ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                   ->paginate(4);
                   //->toArray();
                   //->get();
        // return response()->json([
        //     'success' => true,
        //     'data' => $all_published_product,
        //     'message' => 'All Successfully Published Products !!!',
        // ], 200);
    }

    public function product_create()
    {
        $products = Product::all();
        //$categories = Category::all();
        $categories = Category::pluck('category_name', 'category_id');
        $all_manufacture_info = Manufacture::all();
        return view('admin.product.create', compact('products', 'categories', 'all_manufacture_info'));
    }

    public function show($product_id)
    {
        $show_product = Product::findOrFail($product_id);
        return view('admin.product.show', compact('show_product'));
    }

    public function showReview($id)
    {
        $product = Product::findOrFail($id);
        $review = Review::all()->where('product_id', $id);
        //return view('pages.showReview.show', compact('product', 'review'));
        return response()->json([
            'success' => true,
            'data' => $product, $review,
        ], 200);
    }

    public function show_product_by_id($product_id)
    {
        $product = Product::findOrFail($product_id);
        return response()->json($product, 200);
    }

    // public function show(Product $product)
    // {
    //     $product->load(['reviews' => function ($query) {
    //         $query->latest();
    //     }, 'user']);
    //     return response()->json(['product' => $product]);
    // }

    public function save_product(Request $request)
    {
        $this->validate($request, [
            'category' => 'required',
            'manufacture' => 'required',
            'product_name' => 'required',
            'product_description' => 'required',
            'product_price' => 'required | numeric',
            'stock' => 'required',
            'product_image' => 'required | file',
        ]);

        $image = $request->file('product_image');
        $slug = str_slug($request->name);

        if (isset($image))
        {
            $currentDate = Carbon::now()->toDateString();
            $imagename = $slug . '-' . $currentDate . '-' . uniqid() . '.' . $image->getClientOriginalExtension();
            if (!file_exists('uploads/products'))
            {
                mkdir('uploads/products', 0777, true);
            }
            $image->move('uploads/products', $imagename);
        }
        else {
            $imagename = 'default.png';
        }

        $data = new Product();
        $data->product_name = $request->product_name;
        $data->category_id = $request->category;
        $data->manufacture_id = $request->manufacture;
        $data->product_description = $request->product_description;
        $data->product_price = $request->product_price;
        $data->stock = $request->stock;
        $data->product_size = $request->product_size;
        $data->product_color = $request->product_color;
        $data->product_image = $imagename;

        if(isset($request->status))
        {
            $data->status = 'enable';
        } else {
            $data->status = 'disable';
        }
        $data->save();
        return Redirect::to('/all-product')->with('successMsg', 'Product Saved Successfully ):');
    }

    public function edit($product_id)
    {
        $product_info = Product::findOrFail($product_id);
        $categories = Category::all();
        $all_manufacture_info = Manufacture::all();
        return view('admin.product.edit', compact('product_info', 'categories', 'all_manufacture_info'));
    }

    public function update_product(Request $request, $product_id)
    {
        $product = Product::findOrFail($product_id);
        $product->category_id = $request->category;
        $product->manufacture_id = $request->manufacture;
        $product->product_name = $request->product_name;
        $product->product_description = $request->product_description;
        $product->product_price = $request->product_price;
        $product->stock = $request->stock;
        $product->product_size = $request->product_size;
        $product->product_color = $request->product_color;
        $product->status = $request->status;
        if(isset($request->status))
        {
            $product->status = 'enable';
        } else {
            $product->status = 'disable';
        }
        $product->save();
        return Redirect::to('/all-product')->with('successMsg', 'Product Updated Successfully ):');
    }

    public function delete_product($product_id)
    {
        $deleteP = Product::findOrFail($product_id);
        $deleteP->delete();
        return Redirect::to('/all-product')->with('successMsg', 'Product Deleted Successfully ):');
    }

    public function unactive_product($product_id)
    {
        $unactive_product = Product::findOrFail($product_id);
        $unactive_product->update(['status' => 'disable']);
        return Redirect::to('/all-product')->with('successMsg', 'Product Un-activated Successfully ):');
    }

    public function active_product($product_id)
    {
        $active_product = Product::findOrFail($product_id);
        $active_product->update(['status' => 'enable']);
        return Redirect::to('/all-product')->with('successMsg', 'Product Activated Successfully ):');
    }

    public function search(Request $request)
    {
        $data = Product::where('product_name', 'like', '%' . $request->input('query') . '%')
                        ->join('categories', 'products.category_id', '=', 'categories.category_id')
                        ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                        ->simplePaginate(2);
                        // ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                        //->get();
        //return view('pages.search', ['products' => $data]);
        //return $data;

        return response()->json([
            'success' => true,
            'data' => $data,
        ], 200);

    }
}


<file_sep>/app/Review.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Product;
use App\User;
use App\Customer;
//use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Collective\Html\Eloquent\FormAccessible;
use Illuminate\Support\Carbon;

class Review extends Model
{
    protected $table = 'reviews';

    protected $primaryKey = 'review_id';

    protected $fillable = [
        'review',
        //'rating',
        //'approved',
        //'spam',
    ];

    public $timestamps = true;

    /**
     * Get the product that owns the review.
     *
     *
     */
    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    /**
     * Get the user that made the review.
     *
     *
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    // public function scopeApproved($query)
    // {
    //     return $query->where('approved', true);
    // }

    // public function scopeSpam($query)
    // {
    //     return $query->where('spam', true);
    // }

    // public function scopeNotSpam($query)
    // {
    //     return $query->where('spam', false);
    // }

    public function getTimeagoAttribute()
    {
        //return Carbon::parse($value)->format('m/d/Y');
        $date = Carbon::createFromTimeStamp(strtotime($this->created_at))->diffForHumans();
        return $date;
    }

    public function storeReviewForProduct($product_id, $review, $rating)
    {
        $product = Product::find($product_id);

        // this will be added when we add user's login functionality
        $this->user_id = Auth::user()->id;

        $this->review = $review;
        $this->rating = $rating;
        $product->reviews()->save($this);

        // recalculate ratings for the specified product
        $product->recalculateRating();
    }

    public function getCreateRules()
    {
        return array(
            'review' => 'required|min:10',
            'rating' => 'required|integer|between:1,5'
        );
    }

}

<file_sep>/resources/Dummy/CartController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Cart;
use Illuminate\Support\Facades\Redirect;

class CartController extends Controller
{
    public function add_to_cart(Request $request)
    {
        $qty = $request->qty;
        $product_id = $request->product_id;
        $product_info = DB::table('products')
                        ->where('product_id', $product_id)
                        ->first();

        $data['qty'] = $qty;
        $data['id'] = $product_info->product_id;
        $data['name'] = $product_info->product_name;
        $data['price'] = $product_info->product_price;
        $data['options']['image'] = $product_info->product_image;

        $dataC = Cart::add($data);
        //return response()->json($dataC, 201);
        return response([
            'success' => $dataC,
            'Product' => 'Item Added To Cart Successfully!',
        ]);

    }

    public function show_cart()
    {
        $all_published_category = DB::table('category')
                                  ->where('publication_status', 1)
                                  ->get();

        return response([
            'success' => $all_published_category,
            'category' => 'Showing All Category Successfully!',
        ]);

    }

    public function delete_to_cart($rowId)
    {
        $deleteC = Cart::update($rowId, 0);

        return response([
            'success' => $deleteC,
            'product' => 'Item Deleted Successfully!!!',
        ]);

        //return Redirect::to('/show-cart');
        //Cart::destroy();
    }

    public function update_cart(Request $request)
    {
        $qty = $request->qty;
        $rowId = $request->rowId;
        //dd($rowId);
        $updateC = Cart::update($rowId, $qty);
        return response([
            'success' => $updateC,
            'product' => 'Item Updated Successfully!!!',
        ]);

        //return Redirect::to('/show-cart');
        //Cart::destroy();
    }


}

<file_sep>/app/Http/Controllers/ManufactureController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use App\Http\Requests;
use App\Manufacture;
use Carbon\Carbon;
use Session;
session_start();

class ManufactureController extends Controller
{
    public function all_manufacture()
    {
        $all_manufacture_info = DB::table('manufactures')->paginate(5); //->get();
        return view('admin.manufacture.index', compact('all_manufacture_info'));
    }

    public function manufacture_create()
    {
        return view('admin.manufacture.create');
    }

    public function index()
    {
        $dataM = Manufacture::paginate(4);
        return response()->json($dataM, 200);
    }

    public function show($manufacture_id)
    {
        $show_manufacture = Manufacture::findOrFail($manufacture_id);
        return view('admin.product.show', compact('show_manufacture'));

    }

    public function manufacture_by_id($manufacture_id)
    {
        $manufacture_by_id = Manufacture::findOrFail($manufacture_id);
        return response()->json($manufacture_by_id, 200);

    }

    public function save_manufacture(Request $request)
    {
        $data = new Manufacture();
        $data['manufacture_id'] = $request->manufacture_id;
        $data['manufacture_name'] = $request->manufacture_name;
        $data['manufacture_description'] = $request->manufacture_description;
        //$data['created_at']     = Carbon::now();
        if(isset($request->status))
        {
            $data->status = 'enable';
        } else {
            $data->status = 'disable';
        }

        $data->save();
        return Redirect::to('/all-manufacture')->with('successMsg', 'Brand Saved Successfully ):');
    }

    public function edit_manufacture($manufacture_id)
    {
        $manufacture_info = Manufacture::findOrFail($manufacture_id);
        return view('admin.manufacture.edit', compact('manufacture_info'));
    }

    public function update_manufacture(Request $request, $manufacture_id)
    {
        $manufacture = Manufacture::findOrFail($manufacture_id);
        $manufacture['manufacture_name'] = $request->manufacture_name;
        $manufacture['manufacture_description'] = $request->manufacture_description;
        $manufacture->updated_at     = Carbon::now();
        $manufacture->save();
        return Redirect::to('/all-manufacture')->with('successMsg', 'Brand Updated Successfully ):');
    }

    public function delete_manufacture($manufacture_id)
    {
        $deleteM = Manufacture::findOrFail($manufacture_id);
        $deleteM->delete();
        //Session::get('message', 'Manufacture Deleted successfully !!');
        return Redirect::to('/all-manufacture')->with('successMsg', 'Brand Deleted Successfully ):');
    }

    public function unactive_manufacture($manufacture_id)
    {
        $unactive_manufacture = Manufacture::findOrFail($manufacture_id);
        $unactive_manufacture->update(['status' => 'disable']);
        return Redirect::to('/all-manufacture')->with('successMsg', 'Brand Un-activated Successfully ):');
    }

    public function active_manufacture($manufacture_id)
    {
        $active_manufacture = Manufacture::findOrFail($manufacture_id);
        $active_manufacture->update(['status' => 'enable']);
        return Redirect::to('/all-manufacture')->with('successMsg', 'Brand Activated Successfully ):');
    }

    public function search($manufacture_name)
    {
        $search = Manufacture::where("manufacture_name", "like", "%" . $manufacture_name . "%")
                    ->get();
        return $search;
    }

}

<file_sep>/resources/Dummy/HomesController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
//use Illuminate\Support\Facades\Redirect;
//use App\Http\Requests;
use Session;
//session_start();

class HomesController extends Controller
{
    public function index()
    {
        $all_published_product = DB::table('products')
                   ->join('category', 'products.category_id', '=', 'category.category_id')
                   ->join('manufacture', 'products.manufacture_id', '=', 'manufacture.manufacture_id')
                   ->select('products.*', 'category.category_name', 'manufacture.manufacture_name')
                   ->where('products.publication_status', 1)
                   ->limit(9)
                   //->paginate(2);
                   ->get();

        return response()->json([
            'success' => true,
            'data' => $all_published_product
        ], 200);

    }

    public function show_product_by_category($category_id)
    {
        $product_by_category = DB::table('products')
                   ->join('category', 'products.category_id', '=', 'category.category_id')
                   //->join('manufacture', 'products.manufacture_id', '=', 'manufacture.manufacture_id')
                   ->select('products.*', 'category.category_name')
                   ->where('category.category_id', $category_id)
                   ->where('products.publication_status', 1)
                   ->limit(10)
                   //->paginate(2);
                   ->get();

        return response()->json([
            'success' => true,
            'data' => $product_by_category
        ], 200);

    }

    public function show_product_by_manufacture($manufacture_id)
    {
        $product_by_manufacture = DB::table('products')
                   ->join('category', 'products.category_id', '=', 'category.category_id')
                   ->join('manufacture', 'products.manufacture_id', '=', 'manufacture.manufacture_id')
                   ->select('products.*', 'category.category_name', 'manufacture.manufacture_name')
                   ->where('manufacture.manufacture_id', $manufacture_id)
                   ->where('products.publication_status', 1)
                   ->limit(18)
                   ->get();

        return response()->json([
            'success' => true,
            'data' => $product_by_manufacture,
        ], 200);

    }

    public function product_details_by_id($product_id)
    {
        $product_by_details = DB::table('products')
                   ->join('category', 'products.category_id', '=', 'category.category_id')
                   ->join('manufacture', 'products.manufacture_id', '=', 'manufacture.manufacture_id')
                   ->select('products.*', 'category.category_name', 'manufacture.manufacture_name')
                   ->where('products.product_id', $product_id)
                   ->where('products.publication_status', 1)
                   ->first();
                   //->limit(18)
                   //->get();

        return response()->json([
            'success' => true,
            'data' => $product_by_details,
        ], 200);

    }

}
<file_sep>/app/Category.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Product;

class Category extends Model
{
    protected $table = 'categories';

    protected $primaryKey = 'category_id';

    protected $fillable = [
        'category_name',
        'category_description',
        'status',
    ];

    public $timestamps = true;

    // public function products()
    // {
    //     return $this->hasMany(Product::class);
    // }

    public function product()
    {
        return $this->hasOne(Product::class);
    }

}
<file_sep>/app/Customer.php
<?php

namespace App;

use App\WishList;
use App\Review;
use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    protected $table = 'customer';

    protected $primaryKey = 'customer_id';

    protected $fillable = [
        'customer_name',
        'customer_email',
        '<PASSWORD>',
        'mobile_number',
    ];

    public function reviews()
    {
        return $this->hasMany(Review::class);
    }

    public function wishlists()
    {
        return $this->hasMany(WishList::class);
    }
}
<file_sep>/app/Http/Controllers/HomeController.php
<?php

namespace App\Http\Controllers;

use App\Customer;
use App\Product;
use App\Review;
use App\WishList;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;

//use Illuminate\Support\Facades\Redirect;
//use App\Http\Requests;
//use Session;
session_start();

class HomeController extends Controller
{
    public function index()
    {
        $all_published_product = DB::table('products')
                   ->join('categories', 'products.category_id', '=', 'categories.category_id')
                   ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                   ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                   ->where('products.status', 'enable')
                   ->limit(9)
                   ->get();
        //return view('pages.home_content', compact('all_published_product'));

        return response()->json([
            'success' => true,
            'data' => $all_published_product,
            'message' => 'All Successfully Published Products !!!',
        ], 200);

    }

    public function show_product_by_category($category_id)
    {
        $product_by_category = DB::table('products')
                   ->join('categories', 'products.category_id', '=', 'categories.category_id')
                   //->join('manufacture', 'products.manufacture_id', '=', 'manufacture.manufacture_id')
                   ->select('products.*', 'categories.category_name')
                   ->where('categories.category_id', $category_id)
                   ->where('products.status', 'enable')
                   ->limit(10)
                   ->get();
        //return view('pages.category_by_products', compact('product_by_category'));
        return response()->json([
            'success' => true,
            'data' => $product_by_category,
            'message' => 'All Successfully Published Product Category !!!',
        ], 200);

    }

    public function show_product_by_manufacture($manufacture_id)
    {
        $product_by_manufacture = DB::table('products')
                   ->join('categories', 'products.category_id', '=', 'categories.category_id')
                   ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                   ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                   ->where('manufactures.manufacture_id', $manufacture_id)
                   ->where('products.status', 'enable')
                   ->limit(18)
                   ->get();
        //return view('pages.manufacture_by_products', compact('product_by_manufacture'));
        return response()->json([
            'success' => true,
            'data' => $product_by_manufacture,
            'message' => 'All Successfully Published Product Manufacture !!!',
        ], 200);

    }

    public function product_details_by_id($product_id)
    {
        $product_by_details = DB::table('products')
                   ->join('categories', 'products.category_id', '=', 'categories.category_id')
                   ->join('manufactures', 'products.manufacture_id', '=', 'manufactures.manufacture_id')
                   ->select('products.*', 'categories.category_name', 'manufactures.manufacture_name')
                   ->where('products.product_id', $product_id)
                   ->where('products.status', 'enable')
                   ->first();

                   //->limit(18)
                   //->get();
        //return view('pages.product_details', compact('product_by_details'));
        return response()->json([
            'success' => true,
            'data' => $product_by_details,
            'message' => 'Products By Details !!!',
        ], 200);

    }

    public function productReview($product_id)
    {
       $product = Product::findOrFail($product_id);
       $review = Review::all()->where('product_id', $product_id);
       //return view('pages.reviews.show', compact('product', 'review'));
       return response()->json([
            'success' => true,
            'data' => $product, $review,
            'message' => 'Product Review !!!',
        ], 200);

    }

    public function wishList(Request $request)
    {
        // $this->validate($request, [
        //     'customer_name' => 'required',
        // ]);
        // $customer_name = $request->customer_name;
        // $customer_id = $request->customer_id;
        // $customer_id = DB::table('customer')
        //                         ->where('customer_name', $customer_name)
        //                         ->where('customer_id', $customer_id)
        //                         ->get();

        $wishList = new WishList();
        $wishList->customer_id = Session::get('customer_id');
        $wishList->product_id = $request->product_id;
        // $wishList->customer()->associate($customer_id);
        $wishList->save();

        //return redirect()->back()->with('success', 'Product Added To WishList');
        return response()->json([
            'success' => true,
            //'data' => $product_by_details,
            'message' => 'Wish List Saved Successfully !!!',
        ], 200);

    //    $products = DB::table('products')->where('product_id', $request->product_id)->get();
    //    return view('pages.product_details', compact('products'));

    }

    public function view_wishList()
    {
        $products = DB::table('wish_lists')->leftJoin('products', 'wish_lists.product_id', '=', 'products.product_id')->get();
        //return view('pages.wishList', compact('products'));
        return response()->json([
            'success' => true,
            'data' => $products,
            'message' => 'View Wish List !!!',
        ], 200);

    }

    public function removeWishList($id)
    {
        DB::table('wish_lists')->where('product_id', '=', $id)->delete();
        //return back()->with('success', 'Product Removed From WishList');
        return response()->json([
            'success' => true,
            // 'data' => $product_by_details,
            'message' => 'Products By Details !!!',
        ], 200);
    }

}


<file_sep>/app/AboutUs.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class AboutUs extends Model
{
    protected $table = 'about_us';

    protected $primaryKey = 'id';

    protected $fillable = [
        'name',
        'years_of_experience',
        'email',
        'company',
        'website',
        'status',
    ];

}

<file_sep>/app/Http/Controllers/SliderController.php
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use App\Http\Requests;
use App\Slider;
use Illuminate\Support\Carbon;
use Session;
session_start();

class SliderController extends Controller
{
    public function index()
    {
        $sliders = Slider::simplePaginate(4);
        return view('admin.slider.index', compact('sliders'));
    }

    public function create()
    {
        return view('admin.slider.create');
    }

    public function save_slider(Request $request)
    {
        $data = array();
        $data['status'] = $request->status;
        $data['created_at'] = Carbon::now(); //->toDateString();
        $data['updated_at'] = Carbon::now(); //->toDateString();
        //toDateTimeString

        $image = $request->file('slider_image');
        if ($image) {
            $image_name = str_random(20);
            $ext = strtolower($image->getClientOriginalExtension());
            $image_full_name = $image_name.'.'.$ext;
            $upload_path = 'slider/';
            $image_url = $upload_path.$image_full_name;
            $success = $image->move($upload_path, $image_full_name);
            if ($success) {
                $data['slider_image'] = $image_url;

                DB::table('sliders')->insert($data);
                Session::put('message', 'Slider Added Successfully!!');
                return Redirect::to('/sliders');
            }
        }
        $data['slider_image'] = '';

            DB::table('sliders')->insert($data);
                Session::put('message', 'Slider Added Successfully Without Image!!');
                return Redirect::to('/sliders');
    }

    // public function all_slider()
    // {
    //     $all_slider = DB::table('slider')->get();
    //     return view('admin.slider.index', compact('all_slider'));
    // }

    public function delete_slider($id)
    {
        DB::table('sliders')
            ->where('id', $id)
            ->delete();

        Session::get('message', 'Slider Deleted successfully !!');
        return Redirect::to('/sliders');
    }

    public function unactive_slider($id)
    {
        DB::table('sliders')
            ->where('id', $id)
            ->update(['status' => 0 ]);
        Session::put('message', 'Slider Unactivated successfully !!');
        return Redirect::to('/sliders');
    }

    public function active_slider($id)
    {
        DB::table('sliders')
            ->where('id', $id)
            ->update(['status' => 1 ]);
        Session::put('message', 'Slider Activated successfully !!');
        return Redirect::to('/sliders');
    }

}

<file_sep>/app/Http/Controllers/Admin/AdminController.php
<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;

class AdminController extends Controller
{
    public function registered()
    {
        $members = User::all();
        //return view('admin.register')->with('members', $members);
        return view('admin.auth.register', compact('members'));
    }

    public function edit(Request $request, $id)
    {
        $members = User::findOrFail($id);
        return view('admin.auth.edit', compact('members'));
    }

    public function update(Request $request, $id)
    {
        $members = User::findOrFail($id);
        $members->name = $request->input('username');
        $members->usertype = $request->input('usertype');
        $members->update();

        return redirect('/role-register')->with('successMsg', 'Your Data Was Successfully Updated ):');
    }

    public function delete($id)
    {
        $member = User::findOrFail($id);
        $member->delete();

        return redirect('/role-register')->with('successMsg', 'Your Data Was Successfully Deleted ):');
    }
}
<file_sep>/database/factories/ProductFactory.php
<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Category;
use App\Manufacture;
use App\Product;
use App\User;
use Faker\Generator as Faker;

$factory->define(Product::class, function (Faker $faker) {
    // return [
    //         'product_name' => $faker->word,
    //         'product_short_description' => $faker->paragraph,
    //         'product_long_description' => $faker->paragraph,
    //         'product_price' => $faker->numberBetween(1000, 20000),
    //         'product_size' => $faker->paragraph,
    //         'product_color' => $faker->paragraph,
    //         'publication_status' => $faker->numberBetween(0, 1),
            // 'user_id' => function() {
            //     return User::all()->random();
            // },
//             'category_id' => function() {
//                 return Category::all()->random();
//             },
//             'manufacture_id' => function() {
//                 return Manufacture::all()->random();
//         },
//     ];
});

<file_sep>/app/Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\User;
use App\Review;
use App\Category;
use App\Manufacture;

class Product extends Model
{
    protected $table = 'products';

    protected $primaryKey = 'product_id';

    protected $fillable = [
        'category_id',
        'manufacture_id',
        'product_name',
        'product_description',
        'product_price',
        'stock',
        'product_image',
        'product_size',
        'product_color',
        'status',
    ];

    public $timestamps = true;

    /**
     * Get the reviews of the product
     *
     *
     */
    public function reviews()
    {
        return $this->hasMany(Review::class, 'product_id');
    }

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function manufacture()
    {
        return $this->belongsTo(Manufacture::class);
    }

    public function recalculateRating()
    {
        //$reviews = $this->reviews()->notSpam()->approved();
        $avgRating = $reviews->avg('rating');
        $this->rating_cache = round($avgRating,1);
        $this->rating_count = $reviews->count();
        $this->save();
    }

    /**
     * Get the user that added the product.
     *
     *
     */
    // public function users()
    // {
    //     return $this->belongsToMany(User::class);
    //     // return $this->belongsTo(User::class, 'user_id');
    // }

}


<file_sep>/app/Http/Controllers/Admin/DashboardController.php
<?php

namespace App\Http\Controllers\Admin;

use App\Category;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Manufacture;
use App\Product;

class DashboardController extends Controller
{
    // public function dashboard()
    // {
    //     return view('admin.dashboard');
    // }

    public function index()
    {
        $categoryCount = Category::count();
        $manufactureCount = Manufacture::count();
        $productCount = Product::count();
        // $itemCount = Item::count();
        // $sliderCount = Slider::count();
        // $reservations = Reservation::where('status', false)->get();
        // $contactCount = Contact::count();
        return view('admin.dashboard', compact('categoryCount', 'manufactureCount', 'productCount'));
    }

}
<file_sep>/app/Appointment.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Service;

class Appointment extends Model
{
    protected $table = 'appointments';

    protected $primaryKey = 'id';

    protected $fillable = [
        'service_id',
        'firstName',
        'lastName',
        'date',
        'time',
        'gender',
        'email',
        'phone',
        'message',
        'status',
    ];

    public function service()
    {
        return $this->belongsTo(Service::class);
    }

}

<file_sep>/app/Manufacture.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Product;

class Manufacture extends Model
{
    protected $table = 'manufactures';

    protected $primaryKey = 'manufacture_id';

    protected $fillable = [
        'manufacture_name',
        'manufacture_description',
        'status',
    ];

    public $timestamps = true;

    public function products()
    {
        return $this->hasMany(Product::class);
    }
}
