forked from ansu92/sgcweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
1,787 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
Oops, something went wrong.