mercredi 30 juin 2021

delete if password is correct

i need to create a condition that clears the record but with a password.

if the password is correct execute the delete();

controller:

      public function eliminar($id){

    $registros = \App\Models\Registro::findOrFail($id);
    $registros->delete();
     
    return redirect('sistema')->with('mensaje', 'Registro Borrado con exito');
}

    public function borrar($id){
        // return $request->all();
        $data = [
            'category_name' => 'datatable',
            'page_name' => 'multiple_tables',
        'has_scrollspy' => 0,
        'scrollspy_offset' => '',
        'fechax' => Carbon::now(),
        'borrar' => \App\Models\Registro::findOrFail($id),
        'password' => 'PASSCODE',
      

        ];
       
    

        return view('borrar')->with($data);
    }

blade.php:

  <h1>Do you want to delete the record?</h1>



<form action="" class="d-inline" method="POST">
    @method('DELETE')
    @csrf
    <button type="submit" class="btn btn-danger btn-sm">DELETE</button>


    <div class="form-group col-md-6">
                                                <label for="telefono">Password</label>
                                                <input name="password" type="password" class="form-control" id="telefono"  required>
                                            </div>
</form> 

the password is obtained statically

How can I make it delete without the password is identical?

help please



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire