borrado lógico
This commit is contained in:
parent
7e0a2eda42
commit
ac8b3b8615
|
|
@ -11,7 +11,7 @@ class CategoriasController extends Controller
|
|||
{
|
||||
public function index(Request $request){
|
||||
|
||||
$categorias = Categorias::onlyTrashed()->get();
|
||||
$categorias = Categorias::withTrashed()->get();
|
||||
|
||||
// $categorias = Categorias::findOrFail(13);
|
||||
//$cat = Categorias::where('id_categoria', 1)->first();
|
||||
|
|
@ -70,6 +70,12 @@ class CategoriasController extends Controller
|
|||
return redirect('/categorias');
|
||||
}
|
||||
|
||||
public function restaurar(Request $request, $id){
|
||||
$categorias = Categorias::withTrashed()->findOrfail($id);
|
||||
$categorias->restore();
|
||||
return redirect('/categorias');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
— {{ $cat->descripcion }}
|
||||
(ID: {{ $cat->id_categoria}})
|
||||
|
|
||||
|
||||
@if($cat->deleted_at == null)
|
||||
<a href="{{ route('categorias.show', $cat->id_categoria) }}">Ver Más</a>
|
||||
|
|
||||
<a href="{{ route('categorias.edit', $cat->id_categoria) }}">Editar </a>
|
||||
|
|
@ -26,7 +26,17 @@
|
|||
Eliminar
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<form action="{{ route('categorias.restaurar', $cat->id_categoria) }}"
|
||||
method="POST" >
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<button onclick="return confirm('¿Restaurar esta categoría?')">
|
||||
Restaurar
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,3 +28,4 @@ Route::put('categorias/{categoria}', [CategoriasController::class, 'update'])->n
|
|||
|
||||
|
||||
Route::resource('categorias', CategoriasController::class);
|
||||
Route::put('categorias/restaurar/{categoria}', [CategoriasController::class, 'restaurar'])->name('categorias.restaurar');
|
||||
Loading…
Reference in New Issue
Block a user