Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\DB;
- class Dbs extends Model
- {
- public function doInsert($vUserid, $vName, $vPass , $vLevel, $vStatus){
- $vSQL = " Insert Into usermasters (userid, username, password, userlevel, status) ";
- $vSQL .= " values (?, ?, ?, ?, ?) ";
- DB::insert($vSQL, [$vUserid, $vName, $vPass, $vLevel, $vStatus ] );
- echo "Success!";
- }
- public function doUpdate($vUserid, $vName, $vPass , $vLevel, $vStatus){
- $vSQL = " Update usermasters set username = ?, password = ?, userlevel = ?, status = ? ";
- $vSQL .= " where userid = ? ";
- DB::update($vSQL, [$vName, $vPass , $vLevel, $vStatus, $vUserid] );
- echo "Update Success!";
- }
- public function doDelete($vUserid){
- $vSQL = " Delete From usermasters where userid = ? ";
- DB::delete($vSQL, [$vUserid] );
- echo "Record Deleted!";
- }
- public function doShow(){
- return "showlisitng";
- }
- }
- -------------------------------------------------------------
- <html>
- <head>
- <title>Untitled Document</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <center>
- <br><br>
- {!! Form::open(['url' => action('Crud@doCRUD'), 'id' => 'submitcalculator' ]) !!}
- {{ Form::text('txtuserid', null, array('placeholder'=>'User ID')) }} <br><br>
- {{ Form::text('txtusername', null, array('placeholder'=>'User Name')) }} <br><br>
- {{ Form::text('txtpassword', null, array('placeholder'=>'Password')) }} <br><br>
- {{ Form::text('txtuserlevel', null, array('placeholder'=>'User Level')) }} <br><br>
- {{ Form::text('txtstatus', null, array('placeholder'=>'Status')) }} <br><br>
- {!! Form::submit('Add', ['name'=>'btnSubmit', 'value'=>'Add', 'onclick' => 'submit()' ] ) !!}
- {!! Form::submit('Delete', ['name'=>'btnSubmit', 'value'=>'Delete', 'onclick' => 'submit()' ] ) !!}
- {!! Form::submit('Update', ['name'=>'btnSubmit', 'value'=>'Update', 'onclick' => 'submit()' ] ) !!}
- {!! Form::submit('Show', ['name'=>'btnSubmit', 'value'=>'Show', 'onclick' => 'submit()' ] ) !!}
- {!! Form::close() !!}
- <br>
- <br>
- </center>
- </body>
- </html>
- --------------------------------------------------------------
- <?php
- namespace App\Http\Controllers;
- use App\Dbs;
- use Illuminate\Http\Request;
- class Crud extends Controller
- {
- public function index(){
- $data = array("vMessage"=>"");
- return view('dataentry')->with($data);
- }
- public function doCRUD(Request $request){
- $vUserID = $request->input('txtuserid');
- $vUserName = $request->input('txtusername');
- $vPassword = $request->input('txtpassword');
- $vUserlevel = $request->input('txtuserlevel');
- $vStatus = $request->input('txtstatus');
- $oper = $request->input('btnSubmit');
- $opt = new Dbs();
- $rtnValue = "";
- switch($oper){
- case "Add" : $rtnValue = $opt->doInsert($vUserID, $vUserName, $vPassword, $vUserlevel, $vStatus); break;
- case "Delete" : $rtnValue = $opt->doDelete($vUserID); break;
- case "Update" : $rtnValue = $opt->doUpdate($vUserID, $vUserName, $vPassword, $vUserlevel, $vStatus); break;
- case "Show" : $rtnValue = $opt->doShow(); break;
- }
- if($oper == "Show"){
- return redirect($rtnValue); //showlisting
- } else {
- $data = array("vMessage"=>$rtnValue);
- return view('dataentry')->with($data);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement