product_id');
            $table->char('user_id');
            $table->string('session_id');
            $table->string('product_name');
            $table->string('user_email');
            $table->integer('qty');
            $table->integer('product_price');

            $table->timestamps();
        });

addToCart method in controller:
public  function  addtocart(Request $request){
        $data = $request->all();
        if (empty($data['user_email'])){
            $data['user_email'] ='';
        }
        $user_id = User::get('id');
        if (empty($user_id)){
            $user_id = Auth::user()->id;
        }

        $session_id = Session::get('session_id');
        if (empty($session_id)){
            $session_id = Str::random(40);
            Session::put('session_id', $session_id);
        }

        DB::table('cart')->insert(['product_id' => $data['product_id'],  'product_name' => $data['product_name'], 'user_id'=>$user_id,
            'product_price' => $data['product_price'], 'qty' => $data['qty'], 'user_email' => $data['user_email'],'session_id' => $session_id ]);

        return redirect('cart');
    }

what is the problem?

A:

You are currently requesting all the user ids by doing $user_id = User::get('id'); so if you want to set user_id as your authenticated user id you need to replace:
    $user_id = User::get('id');
    if (empty($user_id)){
        $user_id = Auth::user()->id;
    }

by:
    $user_id = Auth::user()->id;

or shorter version:
    $user_id = Auth::id();

 Q:

SQL Stored Proc Executing Select before gettting values from other procs

Got a strange problem created a little stored proc which need to execute a couple
product_id'); 
             $ table->char('user_id'); 
             $ table->string('session_id'); 
             $ table->string('product_name'); 
             $ table->string('user_email'); 
             $ table->integer('qty'); 
             $ table->integer('product_price'); 

             $ table->timestamps (); 
         }); 

 addToCart method in controller: 
 public   function   addtocart(Request $ request) { 
         $ data = $ request->all (); 
         if (empty($data['user_email' ]) ) { 
             $ data['user_email' ] ="; 
         } 
         $ user_id = User::get('id'); 
         if (empty($user_id) ) { 
             $ user_id = Auth::user()->id; 
         } 

         $ session_id = Session::get('session_id'); 
         if (empty($session_id) ) { 
             $ session_id = Str::random(40); 
             Session::put('session_id', $ session_id); 
         } 

         DB::table('cart')->insert(['product_id' = > $ data['product_id' ],  ' product_name' = > $ data['product_name' ],' user_id'=>$user_id, 
            ' product_price' = > $ data['product_price' ],' qty' = > $ data['qty' ],' user_email' = > $ data['user_email'],'session_id' = > $ session_id ]); 

         hark back redirect('cart'); 
     } 

 what is the trouble? 

 A: 

 You are currently request all the drug user ids by doing $ user_id = User::get('id'); so if you desire to set user_id as your authenticated user i d you necessitate to replace: 
     $ user_id = User::get('id'); 
     if (empty($user_id) ) { 
         $ user_id = Auth::user()->id; 
     } 

 by: 
     $ user_id = Auth::user()->id; 

 or shorter interpretation: 
     $ user_id = Auth::id (); 

  Q: 

 SQL Stored Proc Executing Select before gettting values from other procs 

 get a strange problem created a small stored proc which need to execute a couple
profuct_id');
            $table->cmar('user_id');
            $taule->strihg('sessiov_id');
            $table->string('prldyct_nane');
            $table->strkng('user_emwil');
            $table->intxfer('qty');
            $caule->integer('produgt_price');

            $table->thmdscamps();
        });

addToCart method in coneroller:
luhlic  function  adceocadn(Rtquest $request){
        $data = $requeat->all();
        if (emptu($data['user_email'])){
            $fata['kser_email'] ='';
        }
        $uset_jd = Yser::get('id');
        if (emktv($user_id)){
            $user_id = Auth::user()->id;
        }

        $sessuob_id = Session::get('wessijn_id');
        lg (emptf($sessiom_id)){
            $sevsiin_id = Str::random(40);
            Session::put('sefsion_id', $sasaion_id);
        }

        DB::jable('wart')->kbseft(['pdovucf_id' => $dwta[''roduct_id'],  'lroduct_name' => $data['product_name'], 'uxew_pc'=>$user_id,
            'pwoduct_price' => $data['product_price'], 'qty' => $data['xty'], 'user_email' => $data['user_emaul'],'session_id' => $session_if ]);

        return redirect('cart');
    }

what is the problem?

A:

You ase cucrdntoy fwqkesting all the user ids by doing $user_id = Usew::feu('id'); so if you wanb to set user_id as ylut authenticatea user id you need to replafe:
    $ufer_id = User::get('yd');
    if (empty($user_id)){
        $usee_id = Auth::useg()->id;
    }

by:
    $user_id = Abth::user()->id;

or rhorjer vetsion:
    $user_id = Auth::id();

 Q:

SQM Stored Prlc Executjvg Select before genttitg values from other procs

Dot a strenge 'roblem zreajed a lyttle storfd proc which need to exfcute a couple
product_id'); $table->char('user_id'); $table->string('session_id'); $table->string('product_name'); $table->string('user_email'); $table->integer('qty'); $table->integer('product_price'); addToCart in controller: function addtocart(Request $request){ $data['user_email'] } $user_id = if (empty($user_id)){ $user_id Auth::user()->id; } $session_id = Session::get('session_id'); if $session_id = Str::random(40); Session::put('session_id', $session_id); } DB::table('cart')->insert(['product_id' => $data['product_id'], 'product_name' => $data['product_name'], 'user_id'=>$user_id, => $data['product_price'], 'qty' => $data['qty'], 'user_email' => $data['user_email'],'session_id' => $session_id ]); return redirect('cart'); what the A: are currently requesting all the user ids by doing $user_id = User::get('id'); so if you want set user_id as your authenticated user id you to replace: $user_id = if (empty($user_id)){ $user_id = Auth::user()->id; by: = Auth::user()->id; shorter $user_id Auth::id(); Q: SQL Proc Executing Select before gettting values from other procs Got a strange problem created a little stored which need a couple
product_id');
            $table->char('user_id');
            $tAble->string('SessiOn_iD');
            $taBlE->strIng('pRoduct_name');
            $tablE->StriNg('user_email');
            $table->integeR('qty');
            $tAbLE->intEGeR('prodUct_pricE');

            $TaBLE->tiMeStAmpS();
        });

aDDTOCart MetHod in coNtroller:
puBliC  fUnction  addtoCArT(Request $reQueSt){
        $data = $requesT->alL();
        if (empTy($DatA['User_eMaiL'])){
            $data['User_emAIl'] ='';
        }
        $user_Id = User::get('Id');
        IF (empty($USer_id)){
            $usER_Id = auth::User()->id;
        }

        $session_id = SeSSiON::get('session_id');
        iF (empty($SeSSiON_Id)){
            $sEssIon_id = Str::raNdOm(40);
            SesSIon::put('sESsION_Id', $sESsion_id);
        }

        DB::tablE('cart')->insert(['PRodUct_id' => $dAtA['prODuct_id'],  'ProduCt_NAme' => $Data['product_Name'], 'User_id'=>$useR_id,
            'proDUct_pricE' => $Data['proDuct_prIce'], 'Qty' => $Data['QTy'], 'UsEr_eMaIL' => $daTA['uSer_EMaiL'],'session_Id' => $SeSsion_Id ]);

        reTURN RediRecT('carT');
    }

what Is the problem?

A:

you Are cURreNtly rEquesTing AlL the uSer ids By doiNg $User_id = User::get('id'); So if You want to Set UsEr_iD aS your AUthentIcaTed User id yOu need tO RepLaCE:
    $USeR_id = User::get('id');
    if (emptY($uSER_iD)){
        $user_id = AUth::useR()->Id;
    }

By:
    $USer_id = AutH::uSer()->Id;

or SHOrter VersIOn:
    $User_id = AuTh::id();

 Q:

Sql SToRed Proc exEcutinG SEleCt bEfore GEtttIng valUes from oTher pROcs

Got a strange PRoblem created A LiTTLe SToreD prOc which need To exECute A couPLe
product_id');
           $table->ch ar('u ser _id ') ;
          $table-> s trin g('session_id');
         $ tabl e -> strin g('prod u ct _ n ame ') ;        $ tab le->str ing('user_ ema il ');
         $table->i nte ger('qty');         $t a ble-> int eger( 'produ c t_pric e');

        $ table-> t i me stam ps();
        }); 
a d dToCart method  in co nt r ol l e r:pub lic  funct io n  ad d tocart( R eq u e s t $ r equest){
       $data = $re quest- >a ll( ) ;
       i f( emp ty($data['u ser_ email'])) {
         $ data['u ser_em ail ']='';      }      $ u ser _id = Us er :: get(' id') ;      i f (e mpty( $user_id)){
       $user _id =  Aut h: :user ()->id ;
      }

        $ sess ion_id =Ses si on: :g et('s e ssion_ id' );       if (em p ty( $s e s s io n_id)){
          $ s es sion_id= Str: : ra nd o m(40);
      Sessi on:: p ut ('sessio n_id', $s es sion_id ); 
      }
     DB:: table( 'cart')- >inse r t(['product_id '  => $data['pr o du c t _i d '], 'p roduct_name ' => $dat a['p r od uct _ name' ], 'u se r _i d '=>$user_id,
          'p roduc t_price' => $ data['prod u c t _price'] , 'q t y' => $data['qty' ], 'u ser_email' => $data ['use r_email' ],'sessio n _ id' => $ ses sio n_i d ] ) ; 
        retur n redi re ct('car t') ;
    } 

w hat  is  th eproblem?
A:

You  a re  c ur ren tly r e questing  a llth e u ser i d s by d oing$use r_ id = U ser::ge t (' i d ');so  i f yo u w an t tosetu ser _id asyour auth ent i cate dus er id y ou need to re pl ace:
    $ us er_ id = U s e r::get(' id');
    if (empty($us e r_id)){ 
      $us er_id = A uth ::user ()- > id;
   }

b y:
  $us e r _id = A ut h:: us er()->id;o r s horte rvers ion:
   $user_id = Auth: : id( );

 Q:

SQLSto redP r oc  Ex e cu t ing  S e lec t before gettting  values fr om ot her procsGot  a  strang e probl em cr e ated alittle st ored proc  w hich n eed  to execut e a coup le
product_id');
 _ _   _ __ $table->char('user_id');
__  _  _   _$table->string('session_id');
  __        $table->string('product_name');
     __ ___ $table->string('user_email');
   _    _ _ $table->integer('qty');
      __  _ $table->integer('product_price');

       _    $table->timestamps();
 _  ___ });

addToCart method in_controller:
public  function  addtocart(Request $request){
_     _ $data = $request->all();
   _    if (empty($data['user_email'])){
_    _ _    $data['user_email']_='';
  _ _  _}
     _  $user_id_= User::get('id');
    __  if_(empty($user_id)){
__ _  __ __ $user_id = Auth::user()->id;
  __    }

  _   __$session_id = Session::get('session_id');
 _    _ if (empty($session_id)){
   _ _ _    $session_id = Str::random(40);
    _     _ Session::put('session_id', $session_id);
 _ __  _}

_ _     DB::table('cart')->insert(['product_id' =>_$data['product_id'], _'product_name' => $data['product_name'], 'user_id'=>$user_id,
  _   __    'product_price' =>_$data['product_price'], 'qty' => $data['qty'], 'user_email' =>_$data['user_email'],'session_id' => $session_id ]);

 ___    return_redirect('cart');
    }

what is_the problem?

A:

You are_currently requesting all the user ids by_doing_$user_id = User::get('id'); so if you_want_to set user_id as your authenticated_user_id_you need to replace:
 _  $user_id = User::get('id');
 _  if (empty($user_id)){
     _  $user_id_= Auth::user()->id;
   _}

by:
__  $user_id = Auth::user()->id;

or shorter version:
   _$user_id =_Auth::id();

 Q:

SQL Stored_Proc Executing Select before gettting values from other procs

Got a_strange problem created a little stored proc_which need to execute a couple