SHARE
TWEET

Untitled

a guest Jun 12th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Support\Facades\DB;
  6.  
  7. class Dbs extends Model
  8. {
  9.     public function doInsert($vUserid, $vName, $vPass , $vLevel, $vStatus){  
  10.         $vSQL = " Insert Into usermasters (userid, username, password, userlevel, status) ";
  11.         $vSQL .= " values (?, ?, ?, ?, ?) ";
  12.         DB::insert($vSQL, [$vUserid, $vName, $vPass, $vLevel, $vStatus ] );        
  13.         echo "Success!";               
  14.    }
  15.      
  16.   public function doUpdate($vUserid, $vName, $vPass , $vLevel, $vStatus){  
  17.         $vSQL = " Update usermasters set username = ?, password = ?, userlevel = ?, status = ? ";
  18.         $vSQL .= " where userid = ? ";     
  19.         DB::update($vSQL, [$vName, $vPass , $vLevel, $vStatus, $vUserid] );  
  20.         echo "Update Success!";    
  21.    }  
  22.    
  23.   public function doDelete($vUserid){
  24.         $vSQL = " Delete From usermasters where userid = ? ";                          
  25.         DB::delete($vSQL, [$vUserid] );  
  26.         echo "Record Deleted!";    
  27.    }  
  28.   public function doShow(){
  29.     return "showlisitng";
  30.   }
  31. }
  32.  
  33.  
  34. -------------------------------------------------------------
  35.  
  36.  
  37. <html>
  38. <head>
  39. <title>Untitled Document</title>
  40. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  41. </head>
  42.  
  43. <body>
  44. <center>   
  45.     <br><br>
  46.     {!! Form::open(['url' => action('Crud@doCRUD'), 'id' => 'submitcalculator'  ]) !!} 
  47.     {{ Form::text('txtuserid', null, array('placeholder'=>'User ID')) }} <br><br>  
  48.     {{ Form::text('txtusername', null, array('placeholder'=>'User Name')) }} <br><br>  
  49.     {{ Form::text('txtpassword', null, array('placeholder'=>'Password')) }} <br><br>   
  50.     {{ Form::text('txtuserlevel', null, array('placeholder'=>'User Level')) }} <br><br>
  51.     {{ Form::text('txtstatus', null, array('placeholder'=>'Status')) }} <br><br>   
  52.    
  53.     {!! Form::submit('Add', ['name'=>'btnSubmit', 'value'=>'Add', 'onclick' => 'submit()' ]  ) !!}
  54.     {!! Form::submit('Delete', ['name'=>'btnSubmit', 'value'=>'Delete', 'onclick' => 'submit()' ]  ) !!}
  55.     {!! Form::submit('Update', ['name'=>'btnSubmit', 'value'=>'Update', 'onclick' => 'submit()' ]  ) !!}
  56.     {!! Form::submit('Show', ['name'=>'btnSubmit', 'value'=>'Show', 'onclick' => 'submit()' ]  ) !!}
  57.            
  58.     {!! Form::close() !!}
  59.     <br>
  60.     <br>   
  61.  
  62.    
  63. </center>  
  64. </body>
  65. </html>
  66.  
  67.  
  68.  
  69. --------------------------------------------------------------
  70.  
  71. <?php
  72.  
  73. namespace App\Http\Controllers;
  74. use App\Dbs;
  75. use Illuminate\Http\Request;
  76.  
  77. class Crud extends Controller
  78. {  
  79.     public function index(){
  80.             $data = array("vMessage"=>"");
  81.             return view('dataentry')->with($data);
  82.     }
  83.    
  84.     public function doCRUD(Request $request){
  85.        
  86.         $vUserID    = $request->input('txtuserid');
  87.         $vUserName  = $request->input('txtusername');
  88.         $vPassword  = $request->input('txtpassword');
  89.         $vUserlevel = $request->input('txtuserlevel');
  90.         $vStatus    = $request->input('txtstatus');    
  91.         $oper       = $request->input('btnSubmit');
  92.        
  93.        
  94.         $opt = new Dbs();
  95.         $rtnValue = "";
  96.         switch($oper){
  97.             case "Add"      : $rtnValue = $opt->doInsert($vUserID, $vUserName, $vPassword, $vUserlevel, $vStatus);  break;
  98.             case "Delete"   : $rtnValue = $opt->doDelete($vUserID); break;         
  99.             case "Update"   : $rtnValue = $opt->doUpdate($vUserID, $vUserName, $vPassword, $vUserlevel, $vStatus); break;
  100.             case "Show"     : $rtnValue = $opt->doShow(); break;           
  101.         }
  102.         if($oper == "Show"){
  103.             return redirect($rtnValue); //showlisting
  104.         } else {
  105.             $data = array("vMessage"=>$rtnValue);
  106.             return view('dataentry')->with($data);     
  107.         }                  
  108.                
  109.        
  110.     }
  111. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top