Closed danilodorgam closed 2 years ago
@danilodorgam what does dd($projeto)
give you? do you get a result?
@mstaack
ProjetoModel {#247
#table: "PROJETO"
#primaryKey: "ID_PROJETO"
#fillable: array:3 [
0 => "NM_PROJETO"
1 => "SG_PROJETO"
2 => "ID_RESPONSAVEL"
]
#guarded: array:4 [
0 => "ID_PROJETO"
1 => "ST_EXCLUIDO"
2 => "ST_CRIADO"
3 => "ST_ATUALIZADO"
]
#connection: null
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:7 [
"id_projeto" => "2"
"nm_projeto" => "PF"
"sg_projeto" => "pf"
"id_responsavel" => "1"
"st_criado" => "2017-07-26 19:14:02"
"st_atualizado" => "2017-07-27 19:14:02"
"st_excluido" => null
]
#original: array:7 [
"id_projeto" => "2"
"nm_projeto" => "PF"
"sg_projeto" => "pf"
"id_responsavel" => "1"
"st_criado" => "2017-07-26 19:14:02"
"st_atualizado" => "2017-07-27 19:14:02"
"st_excluido" => null
]
#casts: []
#dates: []
#dateFormat: null
#appends: []
#events: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
}
try looking what sql is produced and on which connection u are making the call..
try
\DB::listen(function($sql) {
var_dump($sql);
});
in appserviceprovider
and then check your sql...
@danilodorgam also keep in mind you are using SoftDelete Trait!
u can also install https://github.com/barryvdh/laravel-debugbar to have some better overview whats going on your db side :)
Yes, but the DELETED_AT field remains null.
I realized that the same happens when I try to update the registry. It does not change.
check your logs... what return value do you get from the delete call? if none were delete it should be 0...
maybe this is related to https://github.com/yajra/laravel-oci8/issues/312
give running a manual delete via laravel query builder a try
DB::table('projeto')->where('ID_PROJETO', '=', 3)->delete();
So physically deleted from the bank
manually deleting as @mstaack noted works fine, but I don't like it, because I have to type the table name in lots of queries instead of using the protected $table
property on the model.
Neither Project::findOrFail($id)->delete()
nor Project::destroy($id)
works.
Delete works fine on all my projects. Maybe you have some event / model listeners that cancels the delete command?
I found the solution.. I've overridden the primary key in my model protected $primaryKey = 'IDNR'
(columnname uppercase). In Eloquent\Model
the function setKeysForSaveQuery()
fetches the key which returned null
in my case. After changing protected $primaryKey = 'idnr'
(lowercase) both, deleting and updating, works as expected.
However, it's still weird it returns "true" even if I tried to delete a db record where IDNR = null
. It could be a correct Statement, but only if I pass null
as value. Also every SELECT
and INSERT
works with uppercase primary key.
Thanks @jchn-codes, you really saved my day! 👍
Summary of problem or feature request
The laravel does not show any error but also does not delete.
Code snippet of problem
Controller
Model
System details