We are not allowed to delete any other objects unless there are 2 or more objects active in database. But, if $object == 'dtr_codes' we should be able to delete/disable everything in database.
if($object == 'dtr_codes'){
DB::table($object)->where('id', $id)
->update(['deleted' => 1]);
$success = true;
} else {
if(DB::table($object)->where('deleted', 0)->whereNull('deleted_at')->count() > 1) {
DB::table($object)->where('id', $id)
->update(['deleted' => 1);
$success = true;
} else {
$success = false;
} //end if
}//end if
My initial code is working. I just need help to make code shorter.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire