Skip to content

Commit

Permalink
last
Browse files Browse the repository at this point in the history
  • Loading branch information
SgcWeb2 committed Oct 18, 2021
1 parent 967efca commit a523865
Show file tree
Hide file tree
Showing 59 changed files with 1,787 additions and 106 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/Admin/CtrUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;

class CtrUser extends Controller
{
public function __invoke()
public function index()
{
return view('admin.user.index');
}

public function show(User $usuario) {
return view('admin.user.show', compact('usuario'));
}
}
16 changes: 16 additions & 0 deletions app/Http/Controllers/CtrEnfermedad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers;

use App\Models\Enfermedad;

class CtrEnfermedad extends Controller
{
public function index() {
return view('enfermedad.index');
}

public function show(Enfermedad $enfermedad) {
return view('enfermedad.show', compact('enfermedad'));
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/CtrInicio.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CtrInicio extends Controller
{
public function __invoke()
{
$comunicados = Comunicado::orderBy('created_at', 'desc')->take(4)->get();
$comunicados = Comunicado::orderBy('created_at', 'desc')->take(5)->get();

return view('welcome', compact('comunicados'));
}
Expand Down
16 changes: 16 additions & 0 deletions app/Http/Controllers/CtrMedicamento.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers;

use App\Models\Medicamento;

class CtrMedicamento extends Controller
{
public function index() {
return view('medicamento.index');
}

public function show(Medicamento $medicamento) {
return view('medicamento.show', compact('medicamento'));
}
}
16 changes: 16 additions & 0 deletions app/Http/Livewire/Admin/Usuario/ShowUsuario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Livewire\Admin\Usuario;

use App\Models\User;
use Livewire\Component;

class ShowUsuario extends Component
{
public User $usuario;

public function render()
{
return view('livewire.admin.usuario.show-usuario');
}
}
4 changes: 2 additions & 2 deletions app/Http/Livewire/Categoria/NuevaCategoria.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NuevaCategoria extends Component
{
public $abierto = false;
public $open = false;

public $nombre, $descripcion;

Expand All @@ -31,7 +31,7 @@ public function save()
]);

$this->reset([
'abierto',
'open',
'nombre',
'descripcion',
]);
Expand Down
5 changes: 0 additions & 5 deletions app/Http/Livewire/Categoria/TablaCategoria.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ public function updatingCantidad() {
$this->resetPage();
}

public function loadCategorias()
{
$this->readyToLoad = true;
}

public function orden($orden)
{
if ($this->orden == $orden) {
Expand Down
61 changes: 61 additions & 0 deletions app/Http/Livewire/Enfermedad/NuevaEnfermedad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\Http\Livewire\Enfermedad;

use App\Models\Enfermedad;
use Livewire\Component;

class NuevaEnfermedad extends Component
{
public $open = false;

public $nombre;
public $descripcion;

protected $rules = [
'nombre' => 'required|max:25',
'descripcion' => 'max:255',
];

public function updated($propertyName)
{
$this->validateOnly($propertyName);
}

public function save()
{
$this->validate();

$enfermedad = Enfermedad::withTrashed()->where('nombre', $this->nombre)->first();

if ($enfermedad === null) {

Enfermedad::create([
'nombre' => $this->nombre,
'descripcion' => $this->descripcion,
]);
} else {
$enfermedad->restore();

$enfermedad->nombre = $this->nombre;
$enfermedad->descripcion = $this->descripcion;

$enfermedad->save();
}

$this->reset('open');

$this->reset([
'nombre',
'descripcion',
]);

$this->emitTo('enfermedad.tabla-enfermedad', 'render');
$this->emit('alert', 'La enfermedad se creó satisfactoriamente');
}

public function render()
{
return view('livewire.enfermedad.nueva-enfermedad');
}
}
19 changes: 19 additions & 0 deletions app/Http/Livewire/Enfermedad/ShowEnfermedad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Livewire\Enfermedad;

use App\Models\Enfermedad;
use Livewire\Component;
use Livewire\WithPagination;

class ShowEnfermedad extends Component
{
use WithPagination;

public Enfermedad $enfermedad;

public function render()
{
return view('livewire.enfermedad.show-enfermedad');
}
}
108 changes: 108 additions & 0 deletions app/Http/Livewire/Enfermedad/TablaEnfermedad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

namespace App\Http\Livewire\Enfermedad;

use App\Models\Enfermedad;
use Livewire\Component;
use Livewire\WithPagination;

class TablaEnfermedad extends Component
{
use WithPagination;

public Enfermedad $enfermedad;

public $busqueda = '';
public $orden = 'nombre';
public $direccion = "asc";
public $cantidad = '10';

public $readyToLoad = false;

public $openEdit = false;
public $openDestroy = false;

protected $rules = [
'enfermedad.nombre' => 'required|max:25',
'enfermedad.descripcion' => 'max:255',
];

protected $listeners = ['render'];

public function render()
{
if ($this->readyToLoad) {
$enfermedades = Enfermedad::where('nombre', 'like', '%' . $this->busqueda . '%')
->orWhere('descripcion', 'like', '%' . $this->busqueda . '%')
->orderBy($this->orden, $this->direccion)
->paginate($this->cantidad);
} else {
$enfermedades = [];
}

return view('livewire.enfermedad.tabla-enfermedad', compact('enfermedades'));
}

public function updated($propertyName)
{
$this->validateOnly($propertyName);
}

public function updatingBusqueda()
{
$this->resetPage();
}

public function updatingCantidad()
{
$this->resetPage();
}

public function orden($orden)
{
if ($this->orden == $orden) {
if ($this->direccion == 'desc') {
$this->direccion = 'asc';
} else {
$this->direccion = 'desc';
}
} else {
$this->orden = $orden;
$this->direccion = 'asc';
}
}

public function edit(Enfermedad $enfermedad)
{
$this->enfermedad = $enfermedad;
$this->openEdit = true;
}

public function update()
{
$this->validate();

$this->enfermedad->save();

$this->reset('openEdit');

$this->emitTo('enfermedad.tabla-enfermedad', 'render');
$this->emit('alert', 'La enfermedad se actualizó satisfactoriamente');
}

public function destroy(Enfermedad $enfermedad)
{
$this->enfermedad = $enfermedad;
$this->openDestroy = true;
}

public function delete()
{
$this->enfermedad->delete();

$this->reset('openDestroy');

$this->emitTo('enfermedad.tabla-enfermedad', 'render');
$this->emit('alert', 'La enfermedad se eliminó satisfactoriamente');
}
}
61 changes: 61 additions & 0 deletions app/Http/Livewire/Medicamento/NuevoMedicamento.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\Http\Livewire\Medicamento;

use App\Models\Medicamento;
use Livewire\Component;

class NuevoMedicamento extends Component
{
public $open = false;

public $nombre;
public $descripcion;

protected $rules = [
'nombre' => 'required|max:25',
'descripcion' => 'max:255',
];

public function updated($propertyName)
{
$this->validateOnly($propertyName);
}

public function save()
{
$this->validate();

$medicamento = Medicamento::withTrashed()->where('nombre', $this->nombre)->first();

if ($medicamento === null) {

Medicamento::create([
'nombre' => $this->nombre,
'descripcion' => $this->descripcion,
]);
} else {
$medicamento->restore();

$medicamento->nombre = $this->nombre;
$medicamento->descripcion = $this->descripcion;

$medicamento->save();
}

$this->reset('open');

$this->reset([
'nombre',
'descripcion',
]);

$this->emitTo('medicamento.tabla-medicamento', 'render');
$this->emit('alert', 'El medicamento se creó satisfactoriamente');
}

public function render()
{
return view('livewire.medicamento.nuevo-medicamento');
}
}
19 changes: 19 additions & 0 deletions app/Http/Livewire/Medicamento/ShowMedicamento.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Livewire\Medicamento;

use App\Models\Medicamento;
use Livewire\Component;
use Livewire\WithPagination;

class ShowMedicamento extends Component
{
use WithPagination;

public Medicamento $medicamento;

public function render()
{
return view('livewire.medicamento.show-medicamento');
}
}
Loading

0 comments on commit a523865

Please sign in to comment.