laravel update by id

34

Model::where('id',1)->update(['name'=>'updated name']);
//or
$data         = Model::findOrFail($id); //primary id
$data->name   = $request->input('updated name');
$data->save();
$userData = array('username' => 'Me', 'email' => '[email protected]');
User::create($userData);

Comments

Submit
0 Comments