Skip to content

Commit

Permalink
Habilitado eliminar un edificio
Browse files Browse the repository at this point in the history
  • Loading branch information
Perer876 committed Mar 20, 2022
1 parent 17b14f6 commit 6e41e1d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/BuildingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public function update(Request $request, Building $building)
*/
public function destroy(Building $building)
{
//
$building->delete();

return redirect('/buildings');
}
}
8 changes: 1 addition & 7 deletions app/View/Components/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ class Modal extends Component
public $uuid;
public $type;
public $title;
public $close;
public $accept;
public $href;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type, $title, $close, $accept, $href)
public function __construct($type, $title)
{
$this->uuid = (string) Str::uuid();
$this->type = $type;
$this->title = $title;
$this->close = $close;
$this->accept = $accept;
$this->href = $href;
}

/**
Expand Down
17 changes: 15 additions & 2 deletions resources/views/buildings/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,21 @@
<div class="buttons">
<a href="/buildings" class="btn btn-primary">Ver todos</a>
<a href="/buildings/{{$building->id}}/edit" class="btn btn-warning">Editar</a>
<x-modal type="danger" title="Eliminar edificio" close="Cancelar" accept="Eliminar" href="/buildings">
¿Estas seguro que quieres eliminar este edificio?
<x-modal type="danger" title="Eliminar edificio">
<div class="modal-body">
¿Estas seguro que quieres eliminar este edificio?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light-secondary" data-bs-dismiss="modal">
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">Cancelar</span>
</button>
<form action="/buildings/{{$building->id}}" method="post">
@csrf
@method('DELETE')
<input class="btn btn-danger" type="submit" value="Eliminar">
</form>
</div>
</x-modal>
</div>
</div>
Expand Down
11 changes: 1 addition & 10 deletions resources/views/components/modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
{{ $title }}
</h5>
</div>
<div class="modal-body">
{{ $slot }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light-secondary" data-bs-dismiss="modal">
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">{{ $close }}</span>
</button>
<a href="{{ $href }}" class="btn btn-{{$type}}">{{ $accept }}</a>
</div>
{{ $slot }}
</div>
</div>
</div>
Expand Down

0 comments on commit 6e41e1d

Please sign in to comment.