0
I’m trying to do an UPDATE to change my user’s password, the function is returning me SUCCESS, but when I go in the database nothing has changed. I am doing a post via Postman, for the following route "http://localhost:8000/api/issuer/3", in my body I am sending the current password and the new password via x.www.form.urlencoded. When I do the validation if the current password is different from the one typed it returns me 'Passwords do not check' until then everything OK, but when it is to change the password via save() it does not change in the bank.
my route
Route::post("emitente/{emit}", "EmitsController@alteraSenha");
my model
namespace App;
use Illuminate\Database\Eloquent\Model;
class Emit extends Model
{
protected $table = 'emit';
protected $fillable = ['senhaUsu'];
}
my controller
public function alteraSenha(request $request , Emit $emit){
if(($emit->senhaUsu == $request->input('atual')) AND (!empty($request->input('nova')))){
$emit->senhaUsu = $request->input('nova');
if($emit->save()){
return response()->json(['status'=>'sucesso']);
}
}else{
return response()->json(['status'=>'Senhas não conferem']);
}
}
includes the return of
var_dump($emit)
(beforeif($emit->save())
) in the question so that there is more information and so we can help– 13dev
I put var_dump($Emit), it returns me 2 objects, one with the changes I just made in the password fieldUsu, and another "original" with the information coming from the bank. Object(App Emit)#263 (26) {[ "passwordUsu" ]=> string(4) "1233" [} "original":protected ]=>[ "passwordUsu" ]=> string(7) "dom1234" [
– Leandro Gardin
Obs: I am using Clickable localhost, and my bank is online
– Leandro Gardin