anilkumarthakur60

Member Since 5 Months Ago

Experience Points
4,080
Total
Experience

920 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
3
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
4,080 XP
Feb
24
4 days ago
Activity icon

Awarded Best Reply on Fontawesome Is Not Working On Mobile Device "Laravel Website".

try with this

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


Feb
23
5 days ago
Activity icon

Replied to Fontawesome Is Not Working On Mobile Device "Laravel Website".

try with this

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


Activity icon

Replied to Summing Data

$entities = Entity::where('user_id', $user_id)->sum('bills_sum_pa_amount')->get();
Activity icon

Started a new Conversation Unable To Get Id From The Input Field

when I am doing @console.log(id) I am not getting the id of that input filed while view source everything is all right here is my code

  <div class="card-header">Ajax todo List <a href="" id="addnewlist" class=" btn btn-sm btn-danger float-right" data-toggle="modal" data-target="#mymodal"><i class="fa fa-plus" aria-hidden="true"></i></a> </div>
            <div class="card-body" id="items">
              <ul class="list-group">
                  @foreach ($items as $todoitem)
                  <li class="list-group-item ouritem"data-toggle="modal" data-target="#mymodal"><span class="badge badge-danger">{{ $todoitem->id }}</span> {{$todoitem->item  }}</li>
                  <input type="hidden" name="" id="itemid" value="{{ $todoitem->id }}">
                  @endforeach

              </ul>
               </div>
          </div>


<!-- Modal -->
<div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodal" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="title" >Todo add new item </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
          <input type="hidden" name="" id="id">
        <input type="text" name="" placeholder="Enter item here" class="form-control" id="additem">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-warning" data-dismiss="modal" id="delete" style="display: none" >Delete</button>
        <button type="button" class="btn btn-primary " style="display: none" id="savechanges">Save changes</button>
        <button type="button" class="btn btn-primary" id="addbutton" data-dismiss="modal">Add item</button>
      </div>
    </div>
  </div>
</div>
@csrf


    <script>
      $(document).ready(function(){
        $(document).on('click','.ouritem',function (event) {
            var text=$(this).text();
            // var id=$(document.getElementById('itemid')).val();
            var id=$(this).find('#itemid').val();
            $('#title').text('edit item');
            $('#additem').val(text);
            $('#delete').show('400');
            $('#savechanges').show('400');
            $('#addbutton').hide('400');
            $('#id').val(id);
            console.log(text);

        });

        //hide shavechanges and delete button on click addnewlist id
        $(document).on('click','#addnewlist',function (event) {
            $('#title').text('Add New item');
            $('#additem').val("");
            $('#delete').hide('400');
            $('#savechanges').hide('400');
            $('#addbutton').show('400');

          });

          //ajax add
        $('#addbutton').click(function(event){
            var text=$('#additem').val();
            $.post('list',{'text':text,'_token':$('input[name=_token]').val()},
                function (data, textStatus, jqXHR) {
                },
                "dataType"
            );
            console.log(text);
            $('#items').load(location.href +' #items');
        });

        $('#delete').click(function (event) {
            var id=$('#id').val();
            console.log(id); //unable to get id in console
          
        });







      });

    </script>

Feb
21
1 week ago
Activity icon

Awarded Best Reply on Image Not Showing In Blade File


@foreach ($products as $product)
<img src="{{asset('/storage/'.$product->image)}}" alt="">

@endforeach

make sure your storage folder is linked

Activity icon

Replied to Image Not Showing In Blade File


@foreach ($products as $product)
<img src="{{asset('/storage/'.$product->image)}}" alt="">

@endforeach

make sure your storage folder is linked

Activity icon

Awarded Best Reply on Pass Data From One Controller To Another

in 1st controller i put that data in session and access that data in second controller

Activity icon

Replied to Pass Data From One Controller To Another

in 1st controller i put that data in session and access that data in second controller

Activity icon

Started a new Conversation Check Passed Input Date And Database Created_at Date

in the blade file, I have a form with input as the date

 <form action="{{ route('searchreportresultdate') }}" method="POST" >
                             @csrf
                            <div class="modal-body pd-20">
                                <div class="form-group">
                                    <label for="brand name">Seach By Date</label>
                                    <input type="date" required name="date" id="name" value="" class="form-control">
                                </div>

                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-info pd-x-20">Submit</button>
                           </div>

                        </form>

in the controller, i want to check the date passed from the form and product created timestamp(created_at)

while dd($result) i am getting nothing

   public function searchreportresultdate(Request $request){
        $date=$request->date; //=2021-2-20
        $result=Product::where('status',1)->where('created_at',$date)->get();

        dd($result);

     }

i think the date in the database is in y-m-d h:m:s how that h:m:s can be excluded and get the only created_at in format=Y-m-d

Feb
20
1 week ago
Activity icon

Replied to How To Get Count Of Listings Without A Foreach

how about trying

  <a href="{{route('category.index', [$category->id, $category->slug])}}">
                {{$category->name}} <span>({{$category->count()}})</span>
              </a>
Activity icon

Started a new Conversation Sum Of Column Data ,field Data In Float

i want to get sum of column data when payment_status field=1

   public function gettotalvalue(){
    
        $received_amount=Order::where('payment_status',1)
                                ->select('orders.amt')
                                ->get();
        	//sum of $received_amount
        return view('admin.order.transactiondone')->with('amounts',$received_amount);

}
Feb
18
1 week ago
Activity icon

Replied to Pass Data From One Controller To Another

so i need to pass the data from first controller to second controller so that i can push that data from second controller to database

Feb
17
1 week ago
Activity icon

Awarded Best Reply on Storage Just Doesn't Seem To Work For Me

make sure you have done

php artisan storage:link

if you have linked then

<img src="{{ asset('/stoage/'.$p->document) }}"/> 

might work for you

Activity icon

Replied to Pass Data From One Controller To Another

order model is working fine ... need to insert shipping detail after successful payment

Feb
16
1 week ago
Activity icon

Started a new Conversation Pass Data From One Controller To Another

1st controller

class PaymentController extends Controller
{
    public function paymentprocess(paymentRequest $request){
        $name=$request->name;
		$email=$request->email;
$phone=$request->phone;
$city=$request->city;
$address=$request->address;
$payment=$request->payment;

        if ($payment=='esewa') {
            toastr()->success('payment method esewa');
           return view('pages.payment.esewa')->with('cartcontent',Cart::content());
        }
        elseif($request->payment=='khalti') {
            toastr()->success('payment method khalti');
            return view('pages.payment.khalti');
        }
        elseif($request->payment=='cashondelivery'){
            toastr()->success('payment method cash ondelivery');
            return view('pages.payment.cashondelivery');

        }

    }
    //
}

2nd controller

class EsewaController extends Controller
{
  public function success(Request $request){

        $setting=Setting::first();

        foreach (Cart::content() as $carts) {
            $rowid=$carts->rowId;
            }

        if(isset($request->oid) && isset($request->amt) && isset($request->refId)){


               $refId=$request->refId;
               if($request->session()->has('coupon')){
                $balance =$request->session()->get('coupon')['balance'];
                    $amt=number_format($balance*(1+$setting->vat/100)+$setting->shipping_charge,2);

                 }else{
                     $amt=Cart::subtotal()*(1+$setting->vat/100)+$setting->shipping_charge;
                 }

            $url = "https://uat.esewa.com.np/epay/transrec";

            $data =[

                    'amt'=>$amt,
                    'rid'=>$refId,
                    'pid'=>$rowid,
                    'scd'=> 'EPAYTEST'
                ];


                $curl = curl_init($url);
                curl_setopt($curl, CURLOPT_POST, true);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                $response = curl_exec($curl);

                curl_close($curl);


                if(strpos($response,'Success')==true){
                    $user_id=Auth::id();
                      Order::create(['user_id'=>$user_id,'amt'=>$request->amt,'oid'=>$request->oid,'refId'=>$request->refId,'status'=>1,'payment_method'=>'esewa']);
                     // $info=$this->paymentprocess(); i can access paymentprocess method data here i can insert here
                     // Shipping::create(['order_id'=>$info->oid,'name'=>$info->name,'phone'=>$info->phone,'email'=>$info->email,'city'=>$info->city,'address'=>$info->address,'payment'=>'esewa']);
                      toastr()->success('payment success and your order has been placed ');
                      return redirect(route('index'));

                }else{
                  toastr()->warning('Transaction failled try again');
                  return view('pages.payment')->with('cartconten',Cart::content());
                }

            }


    }
}

i want to get data from the controller PaymentController @paymentprocess method to EsewaController @success method in paymentprocess method data is being sent from the form as name email phone address city and these data is needed to insert in the shipping table after the successful payment . in success method i am geeting data from the online payment gateway so i need to access the data from the paymentprocess method how can i do that help me

Activity icon

Replied to Get Data From Another Controller

mistakely i clicked in the best answer i was trying to reply to you

Activity icon

Replied to Storage Just Doesn't Seem To Work For Me

make sure you have done

php artisan storage:link

if you have linked then

<img src="{{ asset('/stoage/'.$p->document) }}"/> 

might work for you

Activity icon

Replied to How To Return Array Of String After Using Group By Eloquent

you want to fetch only aba North and aba South, exclude rest?

Activity icon

Replied to How To Return Array Of String After Using Group By Eloquent

$lgas=Lga::orderBy('state')->select('tabe_name.lga')->get();
Activity icon

Replied to Get Data From Another Controller

in the second controller I am getting data from the online payment gateway, not from the form, I need to store data after successful payment in the second controller from the 1st controller

Activity icon

Started a new Conversation Get Data From Another Controller

1st controller is

 public function paymentprocess(paymentRequest $request){
  $data=array();
        $data['name']=$request->name;
        $data['phone']=$request->phone;
        $data['email']=$request->email;
        $data['city']=$request->city;
        $data['address']=$request->address;
        $data['payment']=$request->payment;

        if ($request->payment=='esewa') {
            toastr()->success('payment method esewa');
           return view('pages.payment.esewa')->with('cartcontent',Cart::content());
        }

    }

2nd controller is

i want to get $data value in 2nd controller from 1st controller

  public function success(Request $request){
//get data from $data array in this controller from  1st controller
}
Feb
15
1 week ago
Activity icon

Replied to Compact Json Data To Blade

$data= //your data ;

return  response()->json($data);

this will give you data in JSON format

Activity icon

Replied to Storage::url() Not Working

provie the view page source of image

Activity icon

Started a new Conversation Passing Session Data In Input Value

when i am passing the session data in to input value i am getting error invalid

@if (Session::has('coupon'))
 <input value="{{(Session::get('coupon')['balance'])*(1+$setting->vat/100)+$setting->shipping_charge}}" name="tAmt" type="hidden">
 <input value="{{(Session::get('coupon')['balance'])*(1+$setting->vat/100)+$setting->shipping_charge}}" name="amt" type="hidden">
  @else
        <input value="{{Cart::subtotal()*(1+$setting->vat/100)+$setting->shipping_charge}}" name="tAmt" type="hidden">
           <input value="{{Cart::subtotal()*(1+$setting->vat/100)+$setting->shipping_charge}}" name="amt" type="hidden">
  @endif

Activity icon

Replied to Storage::url() Not Working

<img src="{{ asset('/storage/'.$school->logo_path) }}" alt="">
Activity icon

Started a new Conversation How To Concatenate All Id In Blade And Controller

I have a shopping cart package, I want to get all id in the concatenated form to send all id in form for the payment also I want to have the same concatenate id in the controller to check for that id

@foreach ($cartcontent as $cart)
{{ $id=$cart->id }}
@endforeach
{{$id}} //in concatenate form 

in controller

foreach (Cart::content() as $carts) {
    $id=$carts->id;
}
$id= ? // concatenate form 
Feb
11
2 weeks ago
Activity icon

Replied to A Non Well Formed Numeric Value Encountered

this might be error due to type casting ...thousand separator in cart.php ...without removing thousand separator in cart.php can't be done

Activity icon

Started a new Conversation A Non Well Formed Numeric Value Encountered

   public function coupon(Request $request){
        $coupon=$request->coupon;
        $check=Coupons::where('coupon',$coupon)->first();
        if($check){
            $name=$check->coupon;
            $discount=$check->discount;
            $balance=Cart::subtotal()-$discount;
            Session::put('coupon',['name'=>$name,'discount'=>$discount,'balance'=>$balance]);
            toastr()->success('Coupon applied successfully');
            return  redirect()->back();
        }
        else{
            toastr()->error('Coupon invalid or  unavailable');
            return redirect()->back();
        }


     }
Feb
08
2 weeks ago
Activity icon

Replied to Tenant Roles And Permissions

make middleware for each role

Activity icon

Started a new Conversation Updating The Multiple Image Gets Deleted Non-updated Image

i am doing ecommerce project ,for the product i have setup 4 images per products but while updating the product image it gets updated but non updated imge gets deleted my model is


    public function delete_images(){
        Storage::delete($this->product_image_1);
        Storage::delete($this->product_image_2);
        Storage::delete($this->product_image_3);
        Storage::delete($this->product_image_4);
    }

controller is

  public function update(editProductRequest $request, Products $product)
    {
        $data=$request->only([
                                'category_id',
                                'subcategory_id',
                                'brand_id',
                                'product_name',
                                'product_code',
                                'product_quantity',
                                'product_detail',
                                'product_color',
                                'product_size',
                                'selling_price',
                                'discount_price',
                                'video_link',
                                'main_slider',
                                'hot_deal',
                                'best_rated',
                                'mid_slider',
                                'hot_new',
                                'trend',

                                'status']);

        if($request->hasFile('product_image_1')){

            $product_image_1=$request->product_image_1->store('products','public');
            $product->delete_images();
            $data['product_image_1']=$product_image_1;

        }
        if($request->hasFile('product_image_2')){
            $product_image_2=$request->product_image_2->store('products','public');
            $product->delete_images();

            $data['product_image_2']=$product_image_2;

        }
        if($request->hasFile('product_image_3')){
            $product_image_3=$request->product_image_3->store('products','public');
            $product->delete_images();

            $data['product_image_3']=$product_image_3;

        }
        if($request->hasFile('product_image_4')){
            $product_image_4=$request->product_image_4->store('products','public');
            $product->delete_images();

            $data['product_image_4']=$product_image_4;

        }
        $product->update($data);
        toastr()->success('Product updated successfully');
        return redirect(route('products.index'));



    }

how can i correct it

Activity icon

Awarded Best Reply on Add To Cart Using Ajax Is Not Working

use Cart;

in addtocart controller resolved my problem

Activity icon

Replied to Add To Cart Using Ajax Is Not Working

use Cart;

in addtocart controller resolved my problem

Activity icon

Started a new Conversation Add To Cart Using Ajax Is Not Working

i installed the package shopping cart package

bumbummen99/shoppingcart

blade file with ajax ,

@foreach($products as $product)
  <button class="addwishlist" data-id="{{ $product->id }}">
                                                    <div class="product_fav"><i class="fas fa-heart"></i></div>
     </button>
@endforeach

  <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>

<script>
    $(document).ready(function(){
        $('.addtocart').on('click',function(){
            var id=$(this).data('id');

            if(id){
                $.ajax({
                    url:"{{url('add/to/cart/')}}/"+id,
                    type:"GET",
                    dataType:'json',

                    success:function(data){

                        const Toast = Swal.mixin({
                                toast: true,
                                position: 'top-end',
                                showConfirmButton: false,
                                timer: 3000,
                                timerProgressBar: true,
                                didOpen: (toast) => {
                                    toast.addEventListener('mouseenter', Swal.stopTimer)
                                    toast.addEventListener('mouseleave', Swal.resumeTimer)
                                }
                                })
                                if($.isEmptyObject(data.error)){

                                Toast.fire({
                                icon: 'success',
                                title: data.success
                                    })
                                }
                                else{
                                    Toast.fire({
                                icon: 'error',
                                title: data.error
                                 })
                                }
                    },
                });
            }else{
                alert('danger');
            }
        });

    });
</script>

route & controller

Route::get('add/to/cart/{id}','Addtocart\[email protected]')

 public function addtocart($id){

        $product=Products::where('id',$id)->first();
        
        $data=array();

        if($product->discount_price==null){
        $data['id']=$product->id;
        $data['name']=$product->product_name;
        $data['qty']=1;
        $data['price']=$product->product_price;
        $data['weight']=1;
        $data['option']['image']=$product->product_image_1;
        Cart::add($data);

        return response()->json(['success'=>'product added to cart']);
        }
        else{
            $data['id']=$product->id;
            $data['name']=$product->product_name;
            $data['qty']=1;
            $data['price']=$product->discount_price;
            $data['weight']=1;
            $data['option']['image']=$product->product_image_1;
            Cart::add($data);
           return response()->json(['success'=>'product added to cart']);

        }


        }
Feb
07
3 weeks ago
Activity icon

Replied to How To Pass Variable To Register View Jetstream

<select class="form-control form-select form-select-sm" name="select_name" aria-label="Default select example">
                        <option selected>Open this select menu</option>
                @foreach($institutions as $institution)
                        <option value="{{ $institution->name }}">{{ $institution->name }}</option>
                @endforeach
</select>

use that name="select_name" in your controller

Activity icon

Replied to Pass Variable To Component Tag Name

$section->field_name

Activity icon

Replied to Realrashid/sweet-alert Not Displayed In Laravel 8?

composer require realrashid/sweet-alert
'providers' => [
    /*
    * Package Service Providers...
    */
    RealRashid\SweetAlert\SweetAlertServiceProvider::class,
],

Also, add the Alert facade to the aliases array in your app configuration file:


'Alert' => RealRashid\SweetAlert\Facades\Alert::class,

in blade file

@include('sweetalert::alert')

use sweetalert in controller instead in web.php


Route::get('/','[email protected]')

in WelcomeController showalert method as

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Alert;
class WelcomeController extends Controller
{
    public function showalert(){
        alert()->info('Title','Lorem Lorem Lorem');

        return view('welcome');

    }
    //
}

hope this will work

Activity icon

Replied to Realrashid/sweet-alert Not Displayed In Laravel 8?

<script>
@if (session('alert'))
    swal("{{ session('alert') }}");
@endif
</script>
Activity icon

Replied to Realrashid/sweet-alert Not Displayed In Laravel 8?

shoe me your origional php file where you want to use it may be i can help you

Activity icon

Replied to Realrashid/sweet-alert Not Displayed In Laravel 8?

use cdn for sweetalert2

<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/10.14.0/sweetalert2.all.min.js" integrity="sha512-LXVbtSLdKM9Rpog8WtfAbD3Wks1NSDE7tMwOW3XbQTPQnaTrpIot0rzzekOslA1DVbXSVzS7c/lWZHRGkn3Xpg==" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/10.14.0/sweetalert2.min.css" integrity="sha512-A374yR9LJTApGsMhH1Mn4e9yh0ngysmlMwt/uKPpudcFwLNDgN3E9S/ZeHcWTbyhb5bVHCtvqWey9DLXB4MmZg==" crossorigin="anonymous" />
const swalWithBootstrapButtons = Swal.mixin({
  customClass: {
    confirmButton: 'btn btn-success',
    cancelButton: 'btn btn-danger'
  },
  buttonsStyling: false
})

swalWithBootstrapButtons.fire({
  title: 'Are you sure?',
  text: "You won't be able to revert this!",
  icon: 'warning',
  showCancelButton: true,
  confirmButtonText: 'Yes, delete it!',
  cancelButtonText: 'No, cancel!',
  reverseButtons: true
}).then((result) => {
  if (result.isConfirmed) {
    swalWithBootstrapButtons.fire(
      'Deleted!',
      'Your file has been deleted.',
      'success'
    )
  } else if (
    /* Read more about handling dismissals below */
    result.dismiss === Swal.DismissReason.cancel
  ) {
    swalWithBootstrapButtons.fire(
      'Cancelled',
      'Your imaginary file is safe :)',
      'error'
    )
  }
})
Activity icon

Started a new Conversation Migration Prolem

i am using the shopping cart package as

https://packagist.org/packages/bumbummen99/shoppingcart

while migrating the it throws the error

 SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

  1   C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")

  2   C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
      PDO::prepare("create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
PS C:\xampp\htdocs\laraecommerce> php artisan vendor:publish --provider="Gloudemans\Shoppingcart\ShoppingcartServiceProvider" --tag="migrations"
Copied Directory [\vendor\bumbummen99\shoppingcart\src\Database\migrations] To [\database\migrations]
Publishing complete.
PS C:\xampp\htdocs\laraecommerce> php artisan migrate
Migrating: 2018_12_23_120000_create_shoppingcart_table

   Illuminate\Database\QueryException 

  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

  1   C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")

  2   C:\xampp\htdocs\laraecommerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
      PDO::prepare("create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
Activity icon

Replied to How To Deal With Shopping Cart Processing?

while migrating the data base it says the error

 SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

i am using the package called

https://packagist.org/packages/bumbummen99/shoppingcart
Feb
03
3 weeks ago
Activity icon

Started a new Conversation Undefined Variable: Categories

i have list of categories in the backend which i want to show in me frondend but its showing error showing as

Undefined variable: categories (View: C:\xampp\htdocs\laraecommerce\resources\views\layouts\menubar.blade.php)

my route is

Route::get('/','frontend\index\[email protected]');

my list of blade file are

app.blade.php inside layouts directory

<!doctype html>
<html lang="en">
  <head>
    <title>Title</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  </head>
  <body>
      
      @yield('content)

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>

inside pages directory index.blade.php

@extends('layouts.app')
@section('content')

@include('layouts.menubar')
	//content here 
@endsection

menubar.blade.php inside layouts directory

 @foreach ($categories as $category)
                        <ul class="cat_menu">
                            <li class="hassubs">
                                <a href="#">{{ $category->name }}<i class="fas fa-chevron-right"></i></a>
                                <ul>
                                    <li class="hassubs"><a href="#">Menu Item<i class="fas fa-chevron-right"></i></a>  </li>                                </li>
                                    <li><a href="#">Menu Item<i class="fas fa-chevron-right"></i></a></li>
                                    <li><a href="#">Menu Item<i class="fas fa-chevron-right"></i></a></li>
                                    <li><a href="#">Menu Item<i class="fas fa-chevron-right"></i></a></li>
                                </ul>
                            </li>
                        </ul>
 @endforeach

my controller is

class FrontEndIndexController extends Controller
{
    public function index(){
        return view('pages.index');
    }

    public function category(){
        return view('layouts.menubar')->with('categories',Category::all());
    }
}

help me to solve this issue

Activity icon

Awarded Best Reply on Get List Of Subcategory While Clicking In The Category

using ajax

<script type="text/javascript">
    $(document).ready(function(){
   $('select[name="category_id"]').on('change',function(){
        var category_id = $(this).val();
        if (category_id) {

          $.ajax({
            url: "{{ url('/get/subcategory/') }}/"+category_id,
            type:"GET",
            dataType:"json",
            success:function(data) {
            var d =$('select[name="subcategory_id"]').empty();
            $.each(data, function(key, value){

            $('select[name="subcategory_id"]').append('<option value="'+ value.id +'">' + value.name + '</option>');

            });
            },
          });

        }else{
          alert('danger');
        }

          });
    });

</script>

route

Route::get('get/subcategory/{category_id}','Admin\Products\[email protected]');

controller is

 public function GetSubcate($category_id){
      
        $cat=SubCategory::where('category_id',$category_id)->get();
        return json_encode($cat);
        //using route model binding

    }
Activity icon

Replied to Get List Of Subcategory While Clicking In The Category

using ajax

<script type="text/javascript">
    $(document).ready(function(){
   $('select[name="category_id"]').on('change',function(){
        var category_id = $(this).val();
        if (category_id) {

          $.ajax({
            url: "{{ url('/get/subcategory/') }}/"+category_id,
            type:"GET",
            dataType:"json",
            success:function(data) {
            var d =$('select[name="subcategory_id"]').empty();
            $.each(data, function(key, value){

            $('select[name="subcategory_id"]').append('<option value="'+ value.id +'">' + value.name + '</option>');

            });
            },
          });

        }else{
          alert('danger');
        }

          });
    });

</script>

route

Route::get('get/subcategory/{category_id}','Admin\Products\[email protected]');

controller is

 public function GetSubcate($category_id){
      
        $cat=SubCategory::where('category_id',$category_id)->get();
        return json_encode($cat);
        //using route model binding

    }
Activity icon

Started a new Conversation While Doing Edit Products , Getting List Of All Subcategory With Category

i want to get only list of subcategories under the selected category while editing the product categories

here is my controller for edit

 public function edit(Products $product)
    {
        return view('admin.products.add')->with('product',$product)->with('categories',Category::all())->with('brands',Brand::all())->with('subcategories',SubCategory::all());
        //
    }

here is my blade file

 <div class="col-lg-4">
                      <div class="form-group mg-b-10-force">
                        <label class="form-control-label">Category: <span class="tx-danger">*</span></label>
                        <select class="form-control select2" required name="category_id" data-placeholder="Choose Category">
                            <option label="Choose Category">Choose Category</option>
                            @foreach ($categories as $category)
                            <option value="{{ $category->id }}" @if (isset($product))
                                @if($category->id==$product->category_id) selected  @endif
                            @endif   >{{$category->name  }}</option>
                            @endforeach

                        </select>
                      </div>
                    </div><!-- col-4 -->


                    <div class="col-lg-4">
                        <div class="form-group mg-b-10-force">
                          <label class="form-control-label">Sub Category: <span class="tx-danger">*</span></label>
                          <select class="form-control select2" required name="subcategory_id" data-placeholder="Choose Sub Category">

                              @if (isset($product))
                                 @foreach ($subcategories. as $subcategory)
                                 <option value="{{ $subcategory->id }}" @if($subcategory->id==$product->subcategory_id) selected  @endif >{{ $subcategory->name }}</option>
                                 @endforeach
                              @endif

                          </select>
                        </div>
                    </div><!-- col-4 -->

<script type="text/javascript">
    $(document).ready(function(){
   $('select[name="category_id"]').on('change',function(){
        var category_id = $(this).val();
        if (category_id) {

          $.ajax({
            url: "{{ url('/get/subcategory/') }}/"+category_id,
            type:"GET",
            dataType:"json",
            success:function(data) {
            var d =$('select[name="subcategory_id"]').empty();
            $.each(data, function(key, value){

            $('select[name="subcategory_id"]').append('<option value="'+ value.id +'">' + value.name + '</option>');

            });
            },
          });

        }else{
          alert('danger');
        }

          });
    });

</script>

while editing the any product, while clicking in the subcategory list it shows list of all subcategories under the selected category

for example i have 20 subcategory under 1st category there is 4 subcategory but while editing list of all categories is showing under previous selected catetegory

Feb
02
3 weeks ago
Activity icon

Replied to Problem With Display Data In Blade Using Two Table With Same Field Using Join

$product=DB::table('products') ->join('categories','products.category_id','categories.id') ->join('brands','products.brand_id','brands.id') ->select('products.*','categories.name as category_name','brands.name as brand_name') ->get();

Activity icon

Replied to Problem With Display Data In Blade Using Two Table With Same Field Using Join

i dont know how to do that ..help me with code

Activity icon

Started a new Conversation Problem With Display Data In Blade Using Two Table With Same Field Using Join

Category table is

Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique();
            $table->timestamps();
        });

brand table is

Schema::create('brands', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique();
            $table->string('logo');
            $table->timestamps();
        });

my product controller is

      public function index()
    {   
		  $product=DB::table('products')
                ->join('categories','products.category_id','categories.id')
                ->join('brands','products.brand_id','brands.id')
                ->select('products.*','categories.name','brands.name')
                ->get();
                // return response()->json($product);

    	    return view('admin.products.index')->with('products',$product);
        //
    }

my blade file is

 @foreach ($products as $product)
                    <tr>
                        <td>{{ $product->id }} </td>
                        <td>{{ $product->product_name }} </td>
                        <td>{{ $product->category->name }} </td>{{--  display category name --}}
						
                        <td>{{ $product->brand->name }} </td>{{-- display brand name --}}
                        <td>{{ $product->subcategory_id }} </td>
                        <td>{{ $product->brand_id }} </td>
                        <td><img src="{{ asset('/storage/'.$product->product_image_1) }}" height="50px" alt=""> </td>

                        <td>{{ $product->selling_price }} </td>
                        <td>{{ $product->discount_price }} </td>
                        <td>{{ $product->product_code }} </td>

                        <td>@if ($product->status==1)
                                    active
                                    @else
                                    deactive
                                @endif
                        </td>
                        <td>
                            <a href="{{ route('products.edit',$product->id) }}" class="btn btn-sm btn-info mr-2 float-left">Edit</a>
                            <form action="{{ route('products.destroy',$product->id) }}" method="POST">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-danger delete-confirm pull-left">Delete</button>
                            </form>
                        </td>
                    </tr>
                    @endforeach

both category field (name) and brand field (name) are same how can i acces both of them in blade file

Feb
01
3 weeks ago
Activity icon

Started a new Conversation Get List Of Subcategory While Clicking In The Category

how can i get the subcategory list while clicking in the category list

here is my route

Route::resource('admindashboard/subcategory','Admin\SubCategory\SubCategoryController');
Route::resource('admindashboard/category','Admin\Category\CategoryController');
Route::resource('admindashboard/products','Admin\Products\ProductController');

here is my blade file

 <div class="col-lg-4">
                      <div class="form-group mg-b-10-force">
                        <label class="form-control-label">Category: <span class="tx-danger">*</span></label>
                        <select class="form-control select2" name="category_id" data-placeholder="Choose Category">
                            <option label="Choose Category">Choose Category</option>
                            @foreach ($categories as $category)
                            <option value="{{ $category->id }}">{{$category->name  }}</option>
                            @endforeach

                        </select>
                      </div>
                    </div><!-- col-4 -->


                    <div class="col-lg-4">
                        <div class="form-group mg-b-10-force">
                          <label class="form-control-label">Sub Category: <span class="tx-danger">*</span></label>
                          <select class="form-control select2" name="subcategory_id" data-placeholder="Choose Sub Category">
			//get list of sub categories while selecting category
                          </select>
                        </div>
                    </div><!-- col-4 -->

here is my product controller

 public function index()
    {
        return view('admin.products.index');
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.products.add')->with('categories',Category::all())->with('brands',Brand::all());
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * 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)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

field name in categories and subcategories are

 public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique();
            $table->timestamps();
        });
    }

 public function up()
    {
        Schema::create('sub_categories', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->integer('category_id');
            $table->timestamps();
        });
    }

i think this can be done through ajax but i dont know help me with code

Jan
29
4 weeks ago