Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
lo que falto
Browse files Browse the repository at this point in the history
  • Loading branch information
XSlayer67 committed Nov 17, 2022
1 parent 8f66b28 commit e8e04db
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 1 deletion.
58 changes: 58 additions & 0 deletions app/Http/Controllers/CitasController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Citas;
use App\Models\User;

class CitasController extends Controller
{
public function index()
{
//$User =User::get();
$Citas =Citas::with('users')->get();

//return $Citas;
return view ('admin.Citas.index',compact('Citas'));
}

public function create()
{
$User =User::get();
return view('admin.Citas.create');
}

public function store(Request $request)
{
$input = $request->all();
Citas::create($input);
return redirect('Citas')->with('flash_message', 'Citas Addedd!');
}

public function show($id)
{
$Citas =Citas::find($id);
return view('admin.Citas.show')->with('Citas', $Citas);
}

public function edit($id)
{
$Citas =Citas::find($id);
return view('admin.Citas.edit')->with('Citas', $Citas);
}

public function update(Request $request, $id)
{
$Citas =Citas::find($id);
$input = $request->all();
$Citas->update($input);
return redirect('Citas')->with('flash_message', 'Citas Updated!');
}

public function destroy($id)
{
Citas::destroy($id);
return redirect('Citas')->with('flash_message', 'Citas deleted!');
}
}
19 changes: 19 additions & 0 deletions app/Models/Citas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Citas extends Model
{
use HasFactory;
protected $table = 'citas';
protected $primaryKey = 'id_cita';
protected $fillable = ['fecha_cita','detalles_cita','id_secretaria ','id_paciente '];

public function users()
{
return $this->belongsTo(User::class,'id');
}
}
4 changes: 3 additions & 1 deletion database/migrations/2014_09_21_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->Increments('id');
$table->string('name');
$table->string('rol');
$table->string('username')->unique();
$table->string('estado')->nullable()->default('1');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->Integer('id_persona')->unsigned();
$table->foreign('id_persona')->references('id_persona')->on('personas');
$table->timestamps();
});
}
Expand Down
19 changes: 19 additions & 0 deletions resources/views/admin/Citas/create.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<x-layouts.app>
<div class="card">
<div class="card-header">Crear Cita</div>
<div class="card-body">

<form action="{{ url('Citas') }}" method="post">
{!! csrf_field() !!}
<label>Fecha</label></br>
<input type="date" name="fecha_cita" id="fecha_cita" class="form-control"></br>
<label>Detalles</label></br>
<input type="text" name="detalles_cita" id="detalles_cita" class="form-control"></br>
<label>Paciente</label></br>
<input type="text" name="id_secretaria" id="id_secretaria" class="form-control"></br>
<input type="submit" value="Save" class="btn btn-success"></br>
</form>

</div>
</div>
</x-layouts.app>
22 changes: 22 additions & 0 deletions resources/views/admin/Citas/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<x-layouts.app>
<div class="card">
<div class="card-header">Editar tipo de Patologia</div>
<div class="card-body">

<form action="{{ url('Citas/' .$Citas->id_cita) }}" method="post">
{!! csrf_field() !!}
@method("PATCH")
<input type="hidden" name="id_cita" id="id_cita" value="{{$Citas->id_cita}}" id="id_cita" />
<label>Fecha</label></br>
<input type="date" name="fecha_cita" id="fecha_cita" value="{{$Citas->fecha_cita}}" class="form-control"></br>
<label>Descripcion</label></br>
<input type="text" name="detalles_cita" id="detalles_cita" value="{{$Citas->detalles_cita}}" class="form-control"></br>
<label>Paciente</label></br>
<input type="text" name="id_secretaria " id="id_secretaria " value="{{$Citas->id_secretaria }}" class="form-control"></br>
<input type="submit" value="Update" class="btn btn-success"></br>
</form>

</div>
</div>
</x-layouts.app>

51 changes: 51 additions & 0 deletions resources/views/admin/Citas/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<x-layouts.app>
<div class="container">
<div class="row">
<div class="col-md-9">
<div class="card">
<div class="card-header">
<h2>Citas</h2>
</div>
<div class="card-body">
<a href="{{ url('/Citas/create') }}" class="btn btn-success btn-sm" title="Agregar">
<i class="fa fa-plus" aria-hid_tip_Citasden="true"></i> Add New
</a>
<br/>
<br/>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Fecha</th>
<th>Descripcion</th>
<th>Paciente</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
@foreach($Citas as $item)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $item->fecha_cita }}</td>
<td>{{ $item->detalles_cita }}</td>
<td>{{ $item->id_secretaria->name}}</td>
<td>
<a href="{{ url('/Citas/' . $item->id_citas . '/edit') }}" title="Edit Citas"><button class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o" aria-hid_tip_Citasden="true"></i> Edit</button></a>
<form method="POST" action="{{ url('/Citas' . '/' . $item->id_citas) }}" accept-charset="UTF-8" style="display:inline">
@method('DELETE')
{{ csrf_field() }}
<button type="submit" class="btn btn-danger btn-sm" title="Delete Citas" onclick="return confirm(&quot;Confirm delete?&quot;)"><i class="fa fa-trash-o" aria-hid_tip_Citasden="true"></i> Delete</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</x-layouts.app>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Http\Controllers\CitasController;
use App\Http\Controllers\TipoSangreController;
use App\Models\TipoSangre;
use App\Http\Controllers\TipoPatologiaController;
Expand Down Expand Up @@ -46,4 +47,5 @@
Route::resource('personas', PersonaController::class);
Route::resource('Historial', HistorialController::class);
Route::resource('TipoRelacion', \App\Http\Controllers\TipoRelacionController::class);
Route::resource('Citas', CitasController::class);

0 comments on commit e8e04db

Please sign in to comment.