Register now or log in to join your professional community.
Create an Instance of Model Class then Assign the values to the respected fields and the save
$data = new Staff(); $data->sfullname = $request['fullname']; $data->susername = $request['username']; $data->spassword = openssl_encrypt($request['password'], $ciphering, $encryption_key, $options, $encryption_iv); $data->scontact = $request['phone']; $data->semail = $request['email']; $data->sdoj = $request['doj']; $data->sdob = $request['dob']; $data->sdesignation = $request['designation']; $data->scompany = $request['companyname']; $data->sreporting = $request['reporting']; $data->ssecurity = $request['security'] ? '7' : '2'; $data->smultiple = $request['multiplesite'] ? '1' : '0'; $data->active = "1"; $data->sgrouplevel = "0"; $data->sgroupowner = "Self"; $data->save();
For laravel 5
First define fillables in model
App\\ModelName::create(["field1"=>"value1","field2"=>"value2"]);
\\DB::table('users')->insert([
'id'=>1,
'name'=>'Web technology',
'city_id'=>10
]);
two ways to insert statement or data in laravel:
1- Use create method
2- Use save method
For more you can study on it in laravel docs.
Use Save() , If you want to update also